混合后在esttab中添加二级组数
Add number of second level groups in esttab after mixed
我在 Stata 14
SE 中使用 mixed
命令运行宁多级随机拦截模型。
我想用 community-contributed 命令导出结果 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
从返回的矩阵N_g
中添加二级组的数量作为
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
------------------------------------------------------------------------------------
我在 Stata 14
SE 中使用 mixed
命令运行宁多级随机拦截模型。
我想用 community-contributed 命令导出结果 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
从返回的矩阵N_g
中添加二级组的数量作为
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
------------------------------------------------------------------------------------