我目前正在使用R中的mlogit包进行(条件(多项逻辑回归分析。这些模型的标准输出是系数、标准误差及其显著性水平。由于这些系数可能很难解释,我还使用包中包含的effects((函数计算边际效应。然而,effects((函数只提供边际效应(或弹性(,而没有提供其他信息。理想情况下,我还会介绍一些关于重要性和置信区间的信息。有没有一个函数或简单的方法来计算effect((计算的边际效应的标准误差和显著性水平?
使用mlogit包中包含的MC数据集的示例
# loading packages
library(mlogit)
library(Formula)
# loading dataset on mode of travel from mlogit package
data("ModeCanada", package = "mlogit")
# only include choice sets with all four alternatives
MC <- dfidx(ModeCanada, subset = noalt == 4)
# formula of a multinomial model with income as a predictor of
# the mode of travel
ml.MC1 <- mlogit(choice ~ 1 | income | 1, MC)
# calculate model
summary(ml.MC1)
# output includes coefficients of the model but also standard
# error, z-values, and level of significance
Coefficients :
Estimate Std. Error z-value Pr(>|z|)
(Intercept):air -1.5035093 0.1963055 -7.6590 1.865e-14 ***
(Intercept):bus -1.7715605 0.6643887 -2.6665 0.007666 **
(Intercept):car 0.7371313 0.1572490 4.6877 2.763e-06 ***
income:air 0.0414857 0.0034315 12.0896 < 2.2e-16 ***
income:bus -0.0510644 0.0181427 -2.8146 0.004884 **
income:car 0.0053445 0.0029496 1.8120 0.069991 .
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Log-Likelihood: -2779.2
# calculate marginal effects (an absolute increase of predictor as absolute
# change in predicted outcome probability)(at sample means).
# However, the output only includes the marginal effect of changes in
# income, but no info on standard errors, etc.
effects(ml.MC1, covariate = "income", type = "aa")
train air bus car
-0.0029162845 0.0086781323 -0.0001209537 -0.0056408941
我没有R
解决方案,但这里有一个Stata解决方案,可以用来比较未来的R
答案或您自己的例程。在任何情况下;手动";R的解决方案是将德尔塔定理应用于Kenneth的书第3.6节(导数和弹性(中导出的弹性表达式。我希望这能帮助你开始。
条件logit复制
. asclogit choice if noalt==4 ,case(case) casev(income) alternatives(alt) base(train) nolog
Alternative-specific conditional logit Number of obs = 11,116
Case ID variable: case Number of cases = 2779
Alternatives variable: alt Alts per case: min = 4
avg = 4.0
max = 4
Wald chi2(3) = 212.63
Log likelihood = -2779.2424 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
choice | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
air |
income | .0414857 .0034315 12.09 0.000 .03476 .0482113
_cons | -1.503509 .1963055 -7.66 0.000 -1.888261 -1.118758
-------------+----------------------------------------------------------------
bus |
income | -.0510649 .0181427 -2.81 0.005 -.0866239 -.0155059
_cons | -1.771551 .6643887 -2.67 0.008 -3.073729 -.4693731
-------------+----------------------------------------------------------------
car |
income | .0053445 .0029496 1.81 0.070 -.0004365 .0111255
_cons | .7371313 .157249 4.69 0.000 .4289289 1.045334
-------------+----------------------------------------------------------------
train | (base alternative)
------------------------------------------------------------------------------
边际效应
. margins ,dydx(income)
Average marginal effects Number of obs = 11,116
Model VCE : OIM
Expression : Pr(alt|1 selected), predict()
dy/dx w.r.t. : income
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
income |
_outcome |
air | .0081304 .0004962 16.38 0.000 .0071578 .009103
bus | -.0002234 .0000904 -2.47 0.014 -.0004007 -.0000461
car | -.0052056 .0005082 -10.24 0.000 -.0062017 -.0042095
train | -.0027014 .000358 -7.55 0.000 -.0034031 -.0019997
------------------------------------------------------------------------------