I'm stuck with running a multinomial logit regression in R. The data preview is attached for the reference. How should I run it? I'm new to R, and need to do this for applied econometrics using R. Can you help me with reshaping data and running multinomial regression?
> head(data)
marketindex x1_prod1 x2_prod1 x3_prod1 x1_prod2 x2_prod2 x3_prod2 x1_prod3 x2_prod3 x3_prod3 x1_prod0 x2_prod0 x3_prod0 choice
1 1 7.459917 1 7.267866 6.67054 1 7.633743 8.444682 0 11.30016 0 0 0 3
2 1 7.459917 1 7.267866 6.67054 1 7.633743 8.444682 0 11.30016 0 0 0 2
3 1 7.459917 1 7.267866 6.67054 1 7.633743 8.444682 0 11.30016 0 0 0 3
4 1 7.459917 1 7.267866 6.67054 1 7.633743 8.444682 0 11.30016 0 0 0 2
5 1 7.459917 1 7.267866 6.67054 1 7.633743 8.444682 0 11.30016 0 0 0 2
6 1 7.459917 1 7.267866 6.67054 1 7.633743 8.444682 0 11.30016 0 0 0 2
Running multinomial logit model in R can be done in several packages, including
multinompackage andmlogitpackage. The tutorial at UCLA website recommended by mhmtsrmn prefersmultinomtomlogitHowever, the data you provided have been in a shape compatible with the format required by
mlogitpackage, so in case you want to usemlogit, you don't need reshaping anymore. Nevertheless, you do need to change the coding in thechoicecolumn as follows:2must be changed toprod23must be changed toprod3, and so on.This is necessary because in the other columns you use
prod2,prod3, etc.I tried to run
mlogitfunction to your data sample, but it failed, most probably because this sample doesn't have enough variation in its values. So I change the values to random values and assigned the data frame tochoice_datname, like this:Then, I run
mlogitto the data: