mlogit in R - coefficients and unknown random parameter

自作多情 提交于 2020-08-26 07:04:07

问题


I'm trying to run mlogit on my data. My data is:

> head(df[c(1:3, 33:45)])
      ID Gender Age Option equipment.A equipment.B equipment.C clean.A clean.B clean.C people.A people.B people.C price.A price.B
1 108630      M  56      A        3        3        1      1      3      3         2         3         2     4     3
2 115547      F  34      B        3        3        1      1      3      3         2         3         2     4     3
3 118359      F  51      C        3        3        1      1      3      3         2         3         2     4     3
4 126656      F  40      C        3        3        1      1      3      3         2         3         2     4     3
5 127439      F  26      C        3        3        1      1      3      3         2         3         2     4     3
6 130846      M  69      C        3        3        1      1      3      3         2         3         2     4     3
  price.C
1     4
2     4
3     4
4     4
5     4
6     4

My code is:

Result <- mlogit.data(mydata, shape = "wide", choice = "Option", varying = 34:45)
Result.mxl <- mlogit(Option ~ equipment + clean + people + price | 0, Result)
summary(Result.mxl)

Then, my output is:

Frequencies of alternatives:
     A      B      C 
0.3745 0.3525 0.2730 

nr method
4 iterations, 0h:0m:0s 
g'(-H)^-1g = 3.12E-07 
gradient close to zero 

Coefficients :
         Estimate Std. Error z-value  Pr(>|z|)    
equipment2  0.467333   0.100203  4.6639 3.103e-06 ***
equipment3  0.431747   0.089822  4.8067 1.535e-06 ***
clean2    1.278133   0.094188 13.5701 < 2.2e-16 ***
clean3    1.603504   0.118145 13.5724 < 2.2e-16 ***
people2 0.438747   0.094280  4.6537 3.261e-06 ***
people3 0.292673   0.115142  2.5419   0.01103 *  
price2     0.641272   0.111956  5.7279 1.017e-08 ***
price3     0.786393   0.100451  7.8286 4.885e-15 ***
price4     1.045555   0.151903  6.8830 5.859e-12 ***
price5     1.965825   0.211786  9.2821 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Log-Likelihood: -2009.3

So the problem is that I want to get a table with just one observation of 'equipment', 'clean', 'people' and 'price', as well as table of random coefficients. (something like this example: https://cran.r-project.org/web/packages/mlogit/vignettes/e3mxlogit.html)

I tried to add another parameters to my code and run:

Result.mxl <- mlogit(Option ~ equipment + clean + people + price | 0, Result, 
                   rpar = c(equipment = 'n', clean = 'n', people = 'n', price = 'n'), 
                   panel = TRUE, id.var = "id", alt.levels = c("A","B", "C"))

but now I get an error:

Error in mlogit.start(formula = formula, data = data, mf = mf, start = start,  : 
  unknown random parameter

I would appreciate very much your help!

来源:https://stackoverflow.com/questions/60713637/mlogit-in-r-coefficients-and-unknown-random-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!