LZ,小弟也是刚刚入门,所说的也不一定正确,下面是小弟用 SAS 软件就你所提的问题所做的另外一种解答,希望能够对你有所帮助。
设变量 X(自变量)、 Y(因变量)、 SEX(性别 1=女 2=男),现做 Y 对 X、SEX、X*SEX (注:表示 X 与 SEX 交叉作用项),程序如下:
data reg01;
input x y;
if _n_<=8 then sex=1;
else sex=2;
cards;
13 3.54
11 3.01
9 3.09
6 2.48
8 2.56
10 3.36
12 3.18
7 2.65
10 3.01
9 2.83
11 2.92
12 3.09
15 3.98
16 3.89
8 2.21
7 2.39
10 2.74
15 3.36
;
proc print;
run;
proc glm;
model y=x sex x*sex;
class sex;
run;
proc glm;
model y=x sex;
class sex;
run;
以下是程序运用结果:
第一部分:展示数据表
The SAS System 09:20 Thursday, September 25, 2008 16
Obs x y sex
1 13 3.54 1
2 11 3.01 1
3 9 3.09 1
4 6 2.48 1
5 8 2.56 1
6 10 3.36 1
7 12 3.18 1
8 7 2.65 1
9 10 3.01 2
10 9 2.83 2
11 11 2.92 2
12 12 3.09 2
13 15 3.98 2
14 16 3.89 2
15 8 2.21 2
16 7 2.39 2
17 10 2.74 2
18 15 3.36 2
第二部分:回归模型 y 对 x sex x*sex 三个变量的回归模型及模型检验:注意,对于 x*sex
F=0.74 P=0.4052>0.05,说明x*sex交叉作用不显著,可从模型中剔除!
The GLM Procedure
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 3 3.44201996 1.14733999 27.18 <.0001
Error 14 0.59100782 0.04221484
Corrected Total 17 4.03302778
R-Square Coeff Var Root MSE y Mean
0.853458 6.812167 0.205463 3.016111
Source DF Type I SS Mean Square F Value Pr > F
x 1 3.19449983 3.19449983 75.67 <.0001
sex 1 0.21641720 0.21641720 5.13 0.0400
x*sex 1 0.03110293 0.03110293 0.74 0.4052
Source DF Type III SS Mean Square F Value Pr > F
x 1 0.10560791 0.10560791 2.50 0.1360
sex 1 0.08377358 0.08377358 1.98 0.1807
x*sex 1 0.03110293 0.03110293 0.74 0.4052
Standard
Parameter Estimate Error t Value Pr > |t|
Intercept 2.227601211 0.67034373 3.32 0.0050
x 0.106097238 0.06707929 1.58 0.1360
sex -0.565934544 0.40174018 -1.41 0.1807
x*sex 0.033069429 0.03852642 0.86 0.4052
第三部分:回归模型 y 对 x sex 二个变量的回归模型及模型检验:注意,剔除x*sex交叉项后,回归方程为 Y=1.68+0.16X-0.23SE
注意:sex的回归系数为-0.23,说明 sex取值越大,Y就会越小,本例 sex=1 代表"女", sex=2 代表"男",这是不是可以表明 女性 对 绩效的贡献比 男性 大呢?
以上仅供LZ参考,谢谢!
The SAS System 09:20 Thursday, September 25, 2008 20
The GLM Procedure
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 2 3.41091703 1.70545851 41.12 <.0001
Error 15 0.62211075 0.04147405
Corrected Total 17 4.03302778
R-Square Coeff Var Root MSE y Mean
0.845746 6.752131 0.203652 3.016111
Source DF Type I SS Mean Square F Value Pr > F
x 1 3.19449983 3.19449983 77.02 <.0001
sex 1 0.21641720 0.21641720 5.22 0.0373
Source DF Type III SS Mean Square F Value Pr > F
x 1 3.39583675 3.39583675 81.88 <.0001
sex 1 0.21641720 0.21641720 5.22 0.0373
Standard
Parameter Estimate Error t Value Pr > |t|
Intercept 1.681485396 0.20924925 8.04 <.0001
x 0.161560338 0.01785458 9.05 <.0001
sex -0.232558609 0.10180632 -2.28 0.0373