打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
跨数据比较回归系数技巧



https://stats.idre.ucla.edu/stata/code/comparing-regression-coefficients-across-groups-using-suest/

 

Comparing Regression Coefficients Across Groups using Suest | Stata Code Fragments


The FAQ at https://stats.idre.ucla.edu/stat/stata/faq/compreg3.htm shows how you can compare regression coefficients across three groups using xi and by forming interactions.  This can also be done using suest as shown below.(这里的链接给了用哑变量交互项来比较不同数据的回归系数的方法,下面的方法用suest命令来实现。)


*从互联网读入数据

use https://stats.idre.ucla.edu/stat/stata/faq/compreg3

*用年龄为1 的数据组进行回归

regress weight height if age==1

*存储第一组回归的结果到age1

est store age1


*用年龄为2 的数据组进行回归

regress weight height if age==2

*存储第一组回归的结果到age2

est store age2


*用年龄为3 的数据组进行回归

regress weight height if age==3

*存储第一组回归的结果到age3

est store age3


*利用suest进行这三个模型的同时估计

suest age1 age2 age3


*利用test检验不同模型的beta是否相等

test [age1_mean]height=[age2_mean]height

 

 ( 1)  [age1_mean]height - [age2_mean]height = 0

 

           chi2(  1) =   24.04

         Prob > chi2 =    0.0000


*利用test检验不同模型的beta是否相等,多个模型可以用accum参数

test [age2_mean]height=[age3_mean]height, accum


跨数据比较回归系数之Binary Choice(Logit and Probit):

参考文献:

Williams R. Using Heterogenous Choice Models to Compare Logit and Probit Coefficients Across Groups[J]. Sociological Methods & Research, 2009, 37(4):531-559.

 

*首先安装oglm的第三方程序

ssc install oglm

 

Appendix: Stata Code

The following code replicates parts of the analysis in this paper. The user-written oglm and mfx2 commands must be installed; from within Stata type help findit. For more information, see the author‟s web page at http://www.nd.edu/~rwilliam/oglm/index.html.

 

Stata Code for Tables 1 & 2:

* Step 1. 无约束模型,所有的回归系数可以随性别而改变    Unconstrained models, all coefficients can differ by gender.

use 'http://www.indiana.edu/~jslsoc/stata/spex_data/tenure01.dta', clear


* Allison(原文作者)将样本限制在前10年会获得终身教职的   Allison limited the sample to the first 10 years untenured

keep if pdasample


* 选择男性样本进行模型估计  Males Only

oglm tenure year yearsq select articles prestige if male, store(step1male)


* 选择女性样本进行模型估计  Females Only

oglm tenure year yearsq select articles prestige if female, store(step1fem)


* 采用了交互项的等价的混合模型 Equivalent pooled model, using interactions.

oglm tenure year yearsq select articles prestige f_year f_yearsq f_select f_articles f_prestige female, store(step1)


* Step 2. 混合模型,只有截距项因性别而改变 Pooled model; only the intercepts differ by gender.


* Allison提到了该模型但并未在文中汇报 Allison refers to this model but does not present it in the paper.

oglm tenure year yearsq select articles prestige female, store(step2)


* Step 3. 残差方差允许根据性别而改变 Residual variances allowed to differ by gender.


* Allison的模型实际上是异质选择模型的一个特例,用oglm包可以很方便的计算delta 


* Allison’s model is actually a special case of a heterogeneous choice model,


* and it is easy to compute Allison’s delta using oglm.


* Allison文章中的表2的结果进行对比 Compare these results with the first half of Allison’s Table 2.


oglm tenure female year yearsq select articles prestige , het(female) store(step3)


* 计算delta Compute delta

display (1 - exp(.3022305))/ exp(.3022305)


* Step 4A. 检验残差方差不同时alphas是否相等  Test that the Alphas are = but residual variances differ.

lrtest step2 step3, stats


* Step 4B. 检验跨组的alpha在残差方差不同时alpha是否相等 

* Test whether any Alphas differ across groups given that residual variances differ.

lrtest step1 step3, stats


* Step 4C. 检验文章的效果是否存在组间差异 Test whether the effect of articles differs across groups.


*首先需要估计带交互项的模型 First have to estimate the model with the interaction term added.


* Allison文章中的表2结果进行对比  Compare this with the second half of Allison’s Table 2.

oglm tenure female year yearsq select articles prestige f_articles, het(female) store(step4c)


* 计算delta  Compute delta

display (1 - exp(.1774193))/ exp(.1774193)


*现在进行female*articles交互项的检验 Now do the formal test of the female*articles interaction term.

lrtest step3 step4c, stats

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
R语言生存分析数据分析可视化案例
Female?2012年夏季刊(部分我喜欢的款)
【佳作】HG AGE1 卡斯巴尔专用配色
AGE高达场景还原“救世主
Female №5 1991
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服