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:
satisfaction
: which is a categorical variable from 1 (very dissatisfied) to 5 (very satisfied.education
: which is the number of years of education of the individualcountry
: which is the country of origin of the individualaverage_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?