1

I would like to use the R mlogit package. The documentation (http://cran.r-project.org/web/packages/mlogit/vignettes/mlogit.pdf) is well written, but I still have a question.

Suppose I have a dataset composed of three categorical variables: mode, age, cost. mode has three levels (mode1, mode2, mode3), and the other two variables have two levels (age1, age2 and cost1, cost2).

Basically, it is in the following form:

R> head(df)
  mode   age   cost
1 mode2  age1  cost2
2 mode1  age1  cost2
3 mode1  age2  cost1
4 mode3  age1  cost1  

With the command mlogitSample <- mlogit.data(df, choice = "mode", shape = "wide") I am able to "convert" this dataset to the mlogit format: every row is expanded into three rows (corresponding to the three different response categories), with the mode column converted to a sequence of TRUE or FALSE. This is perfect for using mlogit; however, I think it is also why I obtain the error Lapack routine dgesv: system is exactly singular: U[8,8] = 0, given that I have multiple rows which are no more independent.

Since I know that it is possible to apply the multinomial logit method to my case, I would like to know how I can do it with this package. To a similar aim, the function multinom of package nnet works fine, but it does not fit the same model I have in mind: I would like to fit the model $\log(\pi_j(x)) = \alpha_j + \beta\cdot x$, with an intercept $\alpha_j$ varying for each mode category $j$, and a vector of constant coefficients $\beta$).

smci
  • 32,567
  • 20
  • 113
  • 146
Pippo
  • 1,543
  • 3
  • 21
  • 40
  • 1
    1) Please post a reproducible sample dataset showing this error. 2) How do you "know" it works? What other software or pencil+paper method succeeded? – Carl Witthoft Mar 21 '14 at 11:36
  • 1) Post a reproducible example 2) Tell us your package versions, upgrade to the latest, open a clean R session, reverify you still see your issue. Mine are *mlogit 0.2.4 (maxLik 1.2.0) / mnlogit 1.1.1* 3) Try also ***mnlogit*** package. – smci May 18 '14 at 18:41

0 Answers0