楼主: shiyc2010
13035 5

[原创博文] 请问怎么在回归模型中加入虚拟变量 [推广有奖]

  • 0关注
  • 0粉丝

高中生

37%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
236 点
帖子
24
精华
0
在线时间
30 小时
注册时间
2010-9-24
最后登录
2012-2-6

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
我进行逻辑回归时想分别加入三个虚拟变量,应该怎么加?谢谢指教
二维码

扫码加我 拉你入群

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

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

关键词:回归模型 虚拟变量 逻辑回归 模型

沙发
greattiger 发表于 2010-10-20 13:09:01 |只看作者 |坛友微信交流群
大概将虚拟变量作为自变量就可以了!一般虚拟变量设为0,1,测度虚拟变量对因变量的影响程度!
心如止水!

使用道具

藤椅
yarhan2012 发表于 2010-10-20 16:48:25 |只看作者 |坛友微信交流群
如楼上所说

使用道具

板凳
bobguy 发表于 2010-10-21 08:45:00 |只看作者 |坛友微信交流群
shiyc2010 发表于 2010-10-20 13:02
我进行逻辑回归时想分别加入三个虚拟变量,应该怎么加?谢谢指教
In many SAS procedures, you may define them as a class variables.

Here is an example.

data tmp;
  do i=1 to 200;
    if mod(i,3) =0 then cat='a';
    else if mod(i,3) =1 then cat='b';
    else cat='c';
    x=rannor(99);
    y=1+ ( cat='a' ) * 1 + ( cat='b' ) *-1+( cat='c' ) * 0 + 1*x > rannor(99);
    output;
end;
run;

proc logistic data=tmp;
  class cat /param=glm;
  model y (event='1') = cat x/link=probit;
  run;

*****************************
                                           The SAS System      20:39 Wednesday, October 20, 2010   1

                                       The LOGISTIC Procedure

                                         Model Information

                           Data Set                      WORK.TMP
                           Response Variable             y
                           Number of Response Levels     2
                           Model                         binary probit
                           Optimization Technique        Fisher's scoring


                              Number of Observations Read         200
                              Number of Observations Used         200


                                          Response Profile

                                 Ordered                      Total
                                   Value            y     Frequency

                                       1            0            56
                                       2            1           144

                                    Probability modeled is y=1.


                                      Class Level Information

                                Class     Value     Design Variables

                                cat       a          1      0      0
                                          b          0      1      0
                                          c          0      0      1


                                      Model Convergence Status

                           Convergence criterion (GCONV=1E-8) satisfied.


                                        Model Fit Statistics

                                                            Intercept
                                             Intercept            and
                               Criterion          Only     Covariates

                               AIC             239.181        149.280
                               SC              242.480        162.474
                               -2 Log L        237.181        141.280



                                           The SAS System      20:39 Wednesday, October 20, 2010   2

                                       The LOGISTIC Procedure

                              Testing Global Null Hypothesis: BETA=0

                      Test                 Chi-Square       DF     Pr > ChiSq

                      Likelihood Ratio        95.9009        3         <.0001
                      Score                   73.9988        3         <.0001
                      Wald                    53.4961        3         <.0001


                                     Type 3 Analysis of Effects

                                                     Wald
                             Effect      DF    Chi-Square    Pr > ChiSq

                             cat          2       34.6958        <.0001
                             x            1       40.7798        <.0001


                             Analysis of Maximum Likelihood Estimates

                                                Standard          Wald
               Parameter      DF    Estimate       Error    Chi-Square    Pr > ChiSq

               Intercept       1      1.0395      0.2123       23.9756        <.0001
               cat       a     1      0.9981      0.3593        7.7172        0.0055
               cat       b     1     -1.1190      0.2819       15.7598        <.0001
               cat       c     0           0           .         .             .
               x               1      1.1290      0.1768       40.7798        <.0001


                   Association of Predicted Probabilities and Observed Responses

                         Percent Concordant     89.7    Somers' D    0.794
                         Percent Discordant     10.3    Gamma        0.795
                         Percent Tied            0.1    Tau-a        0.322
                         Pairs                  8064    c            0.897

使用道具

报纸
欣芯馨 在职认证  发表于 2012-7-14 17:07:06 |只看作者 |坛友微信交流群
顶楼上的

使用道具

地板
布丁圆子 发表于 2015-8-26 22:25:19 |只看作者 |坛友微信交流群

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 19:11