mlogit()为R

时间:2015-10-01 19:37:32

标签: r mlogit

我正在尝试使用nests = countriesalternatives = provinces来估算公司选址选择的嵌套logit模型,该模型基于一些特定于替代的特征以及一些公司特定的特征。我将数据格式化为" long"结构使用:

data <- mlogit.data(DB, choice="Occurrence", shape="long", chid.var="IDP", varying=6:ncol(DB), alt.var="Prov")

以下是数据样本:

     IDP         Occurrence From       Prov ToC Dist     Price     Yield
     5p1.APY 5p1      FALSE Sao Paulo  APY  PY 0.0000000 0.3698913 0.0000000
     5p1.BOQ 5p1      FALSE Sao Paulo  BOQ  PY 0.6495493 0.3698913 0.0000000
     5p1.CHA 5p1      FALSE Sao Paulo  CHA  AR 0.7870593 0.4622464 0.4461496
     5p1.COR 5p1      FALSE Sao Paulo  COR  AR 0.3747480 0.4622464 0.5536546
     5p1.FOR 5p1      FALSE Sao Paulo  FOR  AR 0.6822188 0.4622464 0.4402772
     5p1.JUY 5p1      FALSE Sao Paulo  JUY  AR 1.0000000 0.4622464 0.3617038

请注意,为了清晰起见,我已将表格缩小为几个变量,但通常会使用更多变量。

我用于嵌套logit的代码如下:

nests <- list(Bolivia="SCZ",Paraguay=c("PHY","BOQ","APY"),Argentina=c("CHA","COR","FOR","JUY","SAL","SFE","SDE"))

nml <- mlogit(Occurrence ~ DistComp + PriceComp + YieldComp, data=data, nests=nests, unscaled=T)
summary(nml)

运行此模型时,我得到以下输出:

> summary(nml)

Call:
mlogit(formula = Occurrence ~ DistComp + PriceComp + YieldComp, 
    data = data, nests = nests, unscaled = T)

Frequencies of alternatives:
      APY       BOQ       CHA       COR       FOR       JUY       PHY       
SAL       SCZ       SDE       SFE 
0.1000000 0.0666667 0.1333333 0.0250000 0.0750000 0.0083333 0.0083333 
0.1166667 0.2583333 0.1750000 0.0333333 

bfgs method
1 iterations, 0h:0m:0s 
g'(-H)^-1g = 1E+10 
last step couldn't find higher value 

Coefficients :
                Estimate Std. Error t-value Pr(>|t|)
BOQ:(intercept) -0.29923         NA      NA       NA
CHA:(intercept) -1.25406         NA      NA       NA
COR:(intercept) -1.76020         NA      NA       NA
FOR:(intercept) -1.97083         NA      NA       NA
JUY:(intercept) -4.14476         NA      NA       NA
PHY:(intercept) -2.63961         NA      NA       NA
SAL:(intercept) -1.72047         NA      NA       NA
SCZ:(intercept) -0.15714         NA      NA       NA
SDE:(intercept) -0.57449         NA      NA       NA
SFE:(intercept) -2.47345         NA      NA       NA
DistComp         2.44322         NA      NA       NA
PriceComp        2.45202         NA      NA       NA
YieldComp        3.15611         NA      NA       NA
iv.Bolivia       1.00000         NA      NA       NA
iv.Paraguay      1.00000         NA      NA       NA
iv.Argentina     1.00000         NA      NA       NA

Log-Likelihood: -221.84
McFadden R^2:  0.10453 
Likelihood ratio test : chisq = 51.79 (p.value = 2.0552e-09)

考虑到我使用mlogit.data()准备数据,我不明白导致输出中的NA的原因。任何有关这方面的帮助将不胜感激。

最佳,

0 个答案:

没有答案