0

I am currently learning about the multinomial logit estimator and I want to use it to estimate a model in R with the mlogit package. After reading extensively on the subject, it was clear that an important step in the process is the reshaping of the data using the mlogit.data() function. My data frame contains the following information:

  1. satisfaction: which is a categorical variable from 1 (very dissatisfied) to 5 (very satisfied.
  2. education: which is the number of years of education of the individual
  3. country: which is the country of origin of the individual
  4. average_income: which is the average income in the country

Here is a visual represention of the data frame:

> dat
   country satisfaction education income
1        1            3        12    750
2        1            5        13    750
3        1            2        10    750
4        3            4        13    675
5        3            5        14    675
6        3            4        11    675
7        3            1        14    675
8        2            1        11    820
9        2            5        14    820
10       2            3        12    820

The mlogit() function does not seem to like it in this form. I am trying to estimate the model with satisfaction as the dependent variable and education as the independent variable.

How can I reshape it to make it work?

SavedByJESUS
  • 3,262
  • 4
  • 32
  • 47
  • 1
    Please post your code and the error message. – Peter Flom Apr 12 '13 at 17:09
  • 2
    It's not clear to me what your response variable is. Is it `satisfaction`? If so, it seems like [*ordinal* logistic regression](http://en.wikipedia.org/wiki/Ordered_logit) would be more appropriate than multinomial. The UCLA stats website has a guide to [ordinal logistic regression in R](http://www.ats.ucla.edu/stat/r/dae/ologit.htm) that might be helpful to you as well. – gung - Reinstate Monica Apr 12 '13 at 17:22
  • 1
    Consider using the `multinom` function in the `nnet` package instead. `multinom(satisfaction ~ ..., data=dat)` will automatically reshape `satisfaction` into a multinomial array with *minimum* being treated as the referent level (as opposed to SAS using the first value in the data). – AdamO Apr 12 '13 at 17:32
  • 1
    Try to first reshape your data into person-choice (long) format with `datL <- mlogit.data(dat, choice="satisfaction", shape="wide", varying=NULL)`. Then call `mlogit(satisfaction ~ 0 | education, reflevel="1", data=datL)`. More info can be found with `vignette("mlogit")` - especially on page 3ff. – caracal Apr 12 '13 at 19:26

1 Answers1

0

I would include an alt variable that would indicate the alternative 1 to 5. Your dependent variable is the "mode" variable that should be either TRUE or FALSE after you have reshaped your data into the mlogit format.

Yannis
  • 3
  • 3