本文介绍了混合后在estTab中添加二级组数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Stata14
SE中的mixed
命令运行多级随机拦截模型。
我想用社区贡献的命令esttab
导出结果,但我想不出如何将二级组的数量添加到输出中,这在我的情况下是相当重要的。
更具体地说,如果我运行ereturn list
,似乎找不到组的数量,即使Stata在mixed
命令后显示它。
以下是代码的一个示例:
mixed defect c.cenretrosoc c.centrust i.wave || countrywave:
est sto H1A_
mixed defect c.centrust i.wave##c.cenretrosoc || countrywave:
est sto H1A_2
mixed defect c.cenretrosoc i.wave##c.centrust || countrywave:
est sto H1A_3
mixed defect i.wave##c.centrust##c.cenretrosoc || countrywave:
est sto H1A_4
esttab H1A_1 H1A_2 H1A_3 H1A_4 using "defect_all.rtf", b(a1) nobaselevels nocons aic bic ///
scalars("ll Log lik." "nrgroups") label title(Defection - EU members) interact(*) ///
nonumbers mtitles("Baseline" "Econ*Wave" "Misrep*Wave" "Econ*Misrep*Wave") ///
starlevels(~ 0.10 * 0.05 ** 0.01 *** 0.001) nonote replace
如何执行此操作?
推荐答案
使用estadd
将返回矩阵中的二级组数添加为e()
中的标量:
webuse nlswork, clear
estimates clear
mixed ln_w age c.age#c.age tenure c.tenure#c.tenure || id:
estimates store H1A_1
matrix A = e(N_g)
estadd scalar ngrps = A[1,1]
mixed ln_w grade age tenure c.tenure#c.tenure || id:
estimates store H1A_2
matrix A = e(N_g)
estadd scalar ngrps = A[1,1]
mixed ln_w grade age c.age#c.age ttl_exp || id:
estimates store H1A_3
matrix A = e(N_g)
estadd scalar ngrps = A[1,1]
mixed ln_w grade age ttl_exp tenure || id:
estimates store H1A_4
matrix A = e(N_g)
estadd scalar ngrps = A[1,1]
然后只需将其与所需的其余标量一起提供给esttab
:
esttab H1A_1 H1A_2 H1A_3 H1A_4, b(a1) nobaselevels nocons aic bic ///
scalars("ll Log lik." "ngrps") label title(My custom title) interact(*) ///
nonumbers mtitles("First" "Second" "Third" "Fourth") ///
starlevels(~ 0.10 * 0.05 ** 0.01 *** 0.001) nonote
My custom title
------------------------------------------------------------------------------------
First Second Third Fourth
------------------------------------------------------------------------------------
ln(wage/GNP deflat~)
age in current year 0.05*** 0.010*** 0.04*** -0.004***
(16.63) (26.17) (16.56) (-6.78)
age in current yea~e -0.0006*** -0.0009***
(-12.69) (-19.58)
job tenure, in years 0.05*** 0.05*** 0.01***
(29.95) (32.73) (15.96)
job tenure, in yea~, -0.002*** -0.002***
(-15.32) (-18.32)
current grade comp~d 0.08*** 0.07*** 0.07***
(42.11) (39.29) (41.23)
total work experie~e 0.04*** 0.03***
(43.82) (26.92)
------------------------------------------------------------------------------------
Observations 28101 28099 28508 28099
AIC 20726.5 19381.0 19263.8 19002.3
BIC 20784.2 19438.7 19321.6 19060.0
Log lik. -10356.3 -9683.5 -9624.9 -9494.2
ngrps 4699 4697 4708 4697
------------------------------------------------------------------------------------
这篇关于混合后在estTab中添加二级组数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!