【问题标题】:How to get the standard errors for marginal effects calculated by effects() in mlogit如何在 mlogit 中获取由 effects() 计算的边际效应的标准误差
【发布时间】:2021-08-06 14:55:54
【问题描述】:

我目前正在使用 R 中的 mlogit 包进行(条件)多项逻辑回归分析。这些模型的标准输出是系数、标准误差及其显着性水平。由于这些系数可能难以解释,我还使用包中包含的 effects() 函数计算边际效应。然而,effects() 函数只提供边际效应(或弹性),而没有提供其他信息。理想情况下,我还会提供一些关于显着性和置信区间的信息。 有没有一种函数或简单的方法可以计算通过 effects() 计算的边际效应的标准误和显着性水平?

使用 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 multinomial mlogit


    【解决方案1】:

    我没有R 解决方案,但这里有一个Stata 解决方案,可能有助于比较未来的R 答案或您自己的例程。在任何情况下,“手动”R 解决方案是将Delta Theorem 应用于Kenneth's Book 的第 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
    ------------------------------------------------------------------------------
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-01
      • 2014-11-08
      • 2015-05-26
      • 2019-06-04
      • 2020-05-07
      • 2019-06-02
      • 2022-01-21
      • 2018-12-18
      相关资源
      最近更新 更多