楼主: kittymou
23792 10

[其他] [求助]STATA中ttest如何检验两组样本回归系数的差异 [推广有奖]

  • 1关注
  • 4粉丝

已卖:113份资源

教授

45%

还不是VIP/贵宾

-

威望
0
论坛币
3842 个
通用积分
24.0016
学术水平
2 点
热心指数
2 点
信用等级
2 点
经验
48198 点
帖子
678
精华
0
在线时间
815 小时
注册时间
2006-2-27
最后登录
2024-7-8

楼主
kittymou 发表于 2009-2-2 21:12:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请教各位高人,一个模型两组样本回归系数(包括截距项)的差异如何在stata中用ttest实现呢?两组样本用一个模型(这个模型中最后一个变量是分别求出来的,其他的变量相同,我不知道这算不算是一个模型,这个变量就是用HECKMAN针对两组样本分别求出来的lamda)分别进行回归,然后比较组一和组二的回归系数,用ttest如何比较两组系数之间的差异呢?我想知道具体的stata操作方法,非常感谢。<br/>

[此贴子已经被作者于2009-2-3 10:18:56编辑过]

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Stata ttest 回归系数 tata test 我不知道 如何 样本 模型

回帖推荐

rdzr 发表于6楼  查看完整内容

LZ,偶来兑现承诺。示例如下:设有变量 x、y、c(用于区别数据来不同的自样本,其取值分别为 1、2),程序如下:data a;input x y c @@;cards;13 3.54 1 11 3.01 1 9 3.09 1 6 2.48 1 8 2.56 1 10 3.36 1 12 3.18 1 7 2.65 1 10 3.01 2 9 2.83 2 11 2.92 2 12 3.09 2 15 3.98 2 16 3.89 2 8 2.21 2 7 2.39 2 10 2.74 2 15 3.36 2;proc glm; class c; model y=x c x*c;/* 交叉项x*c用于考虑两条回归直线的回归系数是否具 ...

本帖被以下文库推荐

沙发
kittymou 发表于 2009-2-3 13:14:00
自已顶一下,希望有人回贴。

藤椅
zhouzhao1984 发表于 2009-3-15 12:40:00
我也想问这个 呵呵

板凳
rdzr 发表于 2009-3-17 12:06:00
lz,你这个问题 在  stata中 偶不知道该如何解决,但如果 LZ 了解 SAS 的 话,偶倒可以给出一个参考答案。LZ,请问了解 SAS 吗?

报纸
kittymou 发表于 2009-3-18 14:08:00

我学过一点,您要是能用它来解决问题可以啊,非常感谢您啊!期待您的回复。

[此贴子已经被作者于2009-3-18 14:09:19编辑过]

地板
rdzr 发表于 2009-3-20 21:07:00

LZ,偶来兑现承诺。示例如下:

设有变量 x、y、c(用于区别数据来不同的自样本,其取值分别为 1、2),程序如下:

data a;

input x y c @@;

cards;

13 3.54 1 11 3.01 1 9 3.09 1 6 2.48 1 8 2.56 1 10 3.36 1 12 3.18 1 7 2.65 1 10 3.01 2 9 2.83 2 11 2.92 2 12 3.09 2 15 3.98 2 16 3.89 2 8 2.21 2 7 2.39 2 10 2.74 2 15 3.36 2

;

proc glm;

 class c;

 model y=x c x*c;/* 交叉项x*c用于考虑两条回归直线的回归系数是否具有显著差异*/

run;

proc glm;

 class c;

 model y=x c;/* 没有交叉项x*c,用于考虑两条回归直线的回归截距是否具有显著差异*/

run;

运行结果如下(其他部分略,只显示 系数假设检验部分) 

Source              DF     Type III SS     Mean Square    F Value    Pr > F

x                   1      2.75799086      2.75799086      65.33    <.0001
c                   1      0.08377358      0.08377358       1.98    0.1807
x*c              1      0.03110293    0.03110293     0.74    0.4052


(注:对于交叉项x*c, p=.04052>0.05,说明回归系数差异不具有统计学意义!)

Source           DF     Type III SS     Mean Square    F Value    Pr > F

x                1      3.39583675      3.39583675      81.88    <.0001
c              1     0.21641720    0.21641720     5.22    0.0373

(注:对于c, p=.0373<0.05,说明回归截距差异具有统计学意义!)

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
aileendeng + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

7
kittymou 发表于 2009-3-30 22:21:00
非常感谢!偶要好好学一学。

8
tmdxyz 发表于 2009-3-31 06:57:00

那假如说两个回归方程的截距和系数都没有显著性差异,能否将它们合并?应该怎么做呢?

谢谢先!

9
newtype050 发表于 2009-4-12 01:47:00

How do you test the equality of regression coefficients that are generated from two different regressions, estimated on two different samples?

Title  Testing the equality of coefficients across independent areas
Author Allen McDowell, StataCorp
Date April 2001; updated July 2005

You must set up your data and regression model so that one model is nested in a more general model. For example, suppose you have two regressions,

 y = a1 + b1*x 

and

 z = a2 + b2*x 

You rename z to y and append the second dataset onto the first dataset. Then, you generate a dummy variable, call it d, that equals 1 if the data came from the second dataset and 0 if the data came from the first dataset. You then generate the interaction between x and d, i.e., w = d*x. Next, you estimate

 y = a1 + a2*d + b1*x + b2*w 

You can now test whether a2 and b2 are separately or jointly zero. This method generalizes in a straightforward manner to regressions with more than one independent variable.

Here is an example:

 . set obs 10 obs was 0, now 10 . set seed 2001 . generate x = invnormal(uniform()) . generate y = 10 + 15*x + 2*invnormal(uniform()) . generate d=0 . regress y x Source | SS df MS Number of obs = 10 -------------+------------------------------ F( 1, 8) = 1363.66 Model | 2369.31814 1 2369.31814 Prob > F = 0.0000 Residual | 13.8997411 8 1.73746764 R-squared = 0.9942 -------------+------------------------------ Adj R-squared = 0.9934 Total | 2383.21788 9 264.801986 Root MSE = 1.3181 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | 14.88335 .4030394 36.93 0.000 13.95394 15.81276 _cons | 10.15211 .4218434 24.07 0.000 9.179336 11.12488 ------------------------------------------------------------------------------ . save first file first.dta saved . clear . set obs 10 obs was 0, now 10 . set seed 2002 . generate x = invnormal(uniform()) . generate y = 19 + 17*x + 2*invnormal(uniform()) . generate d=1 . regress y x Source | SS df MS Number of obs = 10 -------------+------------------------------ F( 1, 8) = 177.94 Model | 1677.80047 1 1677.80047 Prob > F = 0.0000 Residual | 75.4304659 8 9.42880824 R-squared = 0.9570 -------------+------------------------------ Adj R-squared = 0.9516 Total | 1753.23094 9 194.803438 Root MSE = 3.0706 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | 17.3141 1.297951 13.34 0.000 14.32102 20.30718 _cons | 18.37409 .9710377 18.92 0.000 16.13488 20.61331 ------------------------------------------------------------------------------ . save second file second.dta saved . append using first . generate w = x*d . regress y x w d Source | SS df MS Number of obs = 20 -------------+------------------------------ F( 3, 16) = 275.76 Model | 4618.88818 3 1539.62939 Prob > F = 0.0000 Residual | 89.330207 16 5.58313794 R-squared = 0.9810 -------------+------------------------------ Adj R-squared = 0.9775 Total | 4708.21839 19 247.800968 Root MSE = 2.3629 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | 14.88335 .7224841 20.60 0.000 13.35176 16.41495 w | 2.430745 1.232696 1.97 0.066 -.1824545 5.043945 d | 8.221983 1.06309 7.73 0.000 5.968334 10.47563 _cons | 10.15211 .756192 13.43 0.000 8.549053 11.75516 ------------------------------------------------------------------------------ 

Notice that the constant and the coefficient on x are exactly the same as in the first regression. Here is a simple way to test that the coefficients on the dummy variable and the interaction term are jointly zero. This is, in effect, testing if the estimated parameters from the first regression are statistically different from the estimated parameters from the second regression:

 . test _b[d] =0, notest ( 1) d = 0 . test _b[w] = 0, accum ( 1) d = 0 ( 2) w = 0 F( 2, 16) = 31.04 Prob > F = 0.0000 

Here is how you construct the constant from the second regression from the estimated parameters of the third regression:

 . lincom _b[_cons] + _b[d] ( 1) d + _cons = 0 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 18.37409 .7472172 24.59 0.000 16.79006 19.95812 ------------------------------------------------------------------------------ 

Here is how you construct the coefficient on x from the second regression using the estimated parameters from the third regression.

 . lincom _b[x] + _b[w] ( 1) x + w = 0 ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 17.3141 .9987779 17.34 0.000 15.19678 19.43141 ------------------------------------------------------------------------------ 

10
tmdxyz 发表于 2009-4-12 07:20:00
谢谢您的解答!获益匪浅!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-6 04:37