asclogit后estat mfx的边际效应

时间:2018-05-23 22:07:33

标签: stata

我试图了解在使用estat mfx估算McFadden /条件logit模型后,Stata如何计算选择替代方案的概率和边际效应计算平均值asclogit时的平均值。

例如:

asclogit H t, case(ID) alternatives(AQ) casevars(Medicaid) /// 
basealternative(1) vce(cluster Medicaid) 

estat mfx, varlist(Medicaid)

我的目标是通过使用clogit估算相同模型并手动计算等效边际效应来重新创建结果。我能够使用asclogit重现由clogit生成的条件logit估计值,但是我很难再现后估计计算。

我无法重新生成所选择的每个备选项的计算概率,从阅读estat mfx的文档我学到的是在表输出中标记为X的值进行评估。

以下是estat概率数字:

enter image description here

如果图片没有出来:

. matrix baseline = r(pr_1)\r(pr_2)\r(pr_3)\r(pr_4)\r(pr_5)

. matrix list baseline

baseline[5,1]
           c1
r1  .04077232
r2  .15206384
r3  .01232535
r4  .10465885
r5  .69017964

请记住,以ValphaVMedicaid开头的变量是我为clogit命令创建的特定于案例的变量。它们分别是医疗补助覆盖的拦截和指标。

这就是我所拥有的:

clogit H t  Valpha* i.VMedicaid_2 i.VMedicaid_3 i.VMedicaid_4 i.VMedicaid_5 , ///
group(ID) vce(cluster Medicaid) 

* Reproducing probability an alternative selected calculated by estat mfx

// calculate covariate means to plug into probability calculations

local V t Valpha* VMedicaid_* Medicaid

foreach var of varlist `V' {
    summarize `var'
    scalar `var'_MN = r(mean)
}

// alternative specific ZB
scalar zb = _b[t]*t_MN


// numerators attempt 1

foreach j of numlist 2/5 {
    scalar XB`j' = exp(zb + (_b[Valpha_`j']*Valpha_`j'_MN) + ///
    (_b[1.VMedicaid_`j']*VMedicaid_`j'_MN))

    di "this is `j': " XB`j'
}

// numerators attempt 2, documentation for estat mfx said that probably was 
// evaluated with Medicaid= 0.68 which is the Medicaid coverage rate across cases 
// rather than the mean of the various VMedicaid_ variables are used to estimate 
// clogit. Replaced intercept mean with 1

foreach j of numlist 2/5 {
    scalar XB`j' = exp(zb + (_b[Valpha_`j']) + (_b[1.VMedicaid_`j' *Medicaid_MN))
    di "this is `j': " XB`j'
}

scalar XB1 =exp(zb)

// denominator
scalar DNM  = XB1+ XB2+ XB3+ XB4 + XB5

// Baseline 
foreach j of numlist 1/5 {
    scalar PRB`j' = XB`j'/DNM
    di "The probability of choosing hospital `j' is: " PRB`j'
}

我得到的结果如下:

The probability of choosing hospital 1 is: .14799075
The probability of choosing hospital 2 is: .21019437
The probability of choosing hospital 3 is: .09046377
The probability of choosing hospital 4 is: .18383085
The probability of choosing hospital 5 is: .36752026

0 个答案:

没有答案