在SAS 的logistic过程中,对于自变量是分类变量时,该如果选择Class选项??
有无Class及Class后的参数不同结果相差很大,并且,2分类及3分类又不相同。
为了什么问题,我设计程序如下,希望高人回答。
/*
sex: 取值0、1
sex1:取值F、M
test:取值0、1、2
数据中,sex对应sex1,其中sex=1对应sex1="M",sex=0对应sex1="F"。
*/
data a;
input y sex sex1$ test @@;
cards;
0 1 M 1
1 1 M 2
0 1 M 2
0 1 M 1
1 1 M 0
0 1 M 1
0 0 F 0
0 0 F 0
0 1 M 1
0 1 M 1
0 1 M 1
0 1 M 1
1 0 F 0
0 1 M 1
0 1 M 2
0 1 M 2
0 1 M 2
0 1 M 1
1 1 M 1
0 1 M 1
0 1 M 1
0 0 F 0
0 1 M 1
0 1 M 1
1 1 M 1
0 1 M 1
1 1 M 2
0 0 F 0
0 1 M 1
0 1 M 2
0 1 M 1
0 1 M 2
0 1 M 1
0 1 M 1
1 0 F 2
0 1 M 2
0 1 M 2
0 1 M 1
0 0 F 0
0 1 M 1
0 1 M 2
1 1 M 1
0 1 M 1
0 0 F 0
0 1 M 1
0 1 M 2
0 1 M 1
0 0 F 0
0 1 M 1
1 1 M 1
;
run;
proc logistic data=a desc;
title '例1:SEX1 F and M 有class Ref=“M”';
class sex1(param=ref ref="M");
model y=sex1;
run;
proc logistic data=a desc;
title '例2:SEX1 F and M 有class Ref=“F”';
class sex1(param=ref ref="F");
model y=sex1;
run;
proc logistic data=a desc;
title '例3:SEX 0 and 1 有 class ref="1"';
class sex(param=ref ref="1");
model y=sex;
run;
proc logistic data=a desc;
title '例4:SEX 0 and 1 有 class ref="0"';
class sex(param=ref ref="0");
model y=sex;
run;
proc logistic data=a desc;
title '例5:SEX 0 and 1 无 class';
model y=sex;
run;
proc logistic data=a desc;
title '例6:SEX 0 and 1 有 class ref=last';
class sex(param=ref ref=last);
model y=sex;
run;
proc logistic data=a desc;
title '例7:SEX 0 and 1 有 class ref=first';
class sex(param=ref ref=first);
model y=sex;
run;
proc logistic data=a desc;
title '例8:SEX 0 and 1 有 class 有param无ref参数';
class sex(param=ref);
model y=sex;
run;
proc logistic data=a desc;
title '例9:SEX 0 and 1 有 class 无任何参数';
class sex;
model y=sex;
run;
proc logistic data=a desc;
title '例10:Test 0、1、2 有 class ref="2"';
class Test(param=ref ref="2");
model y=Test;
run;
proc logistic data=a desc;
title '例11:Test 0、1、2 有 class ref="0"';
class Test(param=ref ref="0");
model y=Test;
run;
proc logistic data=a desc;
title '例12:Test 0、1、2 无 class';
model y=Test;
run;
proc logistic data=a desc;
title '例13:Test 0、1、2 有 class ref=last';
class Test(param=ref ref=last);
model y=Test;
run;
proc logistic data=a desc;
title '例14:Test 0、1、2 有 class ref=first';
class Test(param=ref ref=first);
model y=Test;
run;
proc logistic data=a desc;
title '例15:Test 0、1、2 有 class 有param无ref参数';
class Test(param=ref);
model y=Test;
run;
proc logistic data=a desc;
title '例16:Test 0、1、2 有 class 无任何参数';
class Test;
model y=Test;
run;