全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
16724 5
2012-12-26
悬赏 10 个论坛币 已解决
多项logit模型好像默认的自变量都是连续变量吧,那么,如果自变量中有分类变量,用stata如何针对此变量设置参照组呢?求解,谢谢。

最佳答案

dachuan520 查看完整内容

用tab var,gen(var)试试生成虚拟变量
二维码

扫码加我 拉你入群

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

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

全部回复
2012-12-26 11:17:53
用tab var,gen(var)试试生成虚拟变量
二维码

扫码加我 拉你入群

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

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

2012-12-27 00:22:35
还是看楼下的指导。
二维码

扫码加我 拉你入群

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

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

2012-12-27 01:19:07
看帮助Factor variables的解释
Title

    [U] 11.4.3 Factor variables


Base levels

    You can specify the base level of a factor variable by using the ib. operator.  The syntax is

           Base         
           operator(*)    Description
           ---------------------------------------------------------------------------------------------------------
           ib#.           use # as base, #=value of variable
           ib(##).        use the #th ordered value as base (**)
           ib(first).     use smallest value as base (the default)
           ib(last).      use largest value as base
           ib(freq).      use most frequent value as base
           ibn.           no base level
           ---------------------------------------------------------------------------------------------------------
            (*) The i may be omitted.  For instance, you may type ib2.group or b2.group.
           (**) For example, ib(#2). means to use the second value as the base.

    If you want to use group==3 as the base in a regression, you can type,

        . regress y  i.sex ib3.group


    You can also permanently set the base levels of categorical variables by using the fvset command.


Selecting levels

    You can select a range of levels -- a range of virtual variables -- by using the i(numlist). operator.

         Examples          Description
         -----------------------------------------------------------------------------------------------------------
         i2.cat            a single indicator for cat==2

         2.cat             same as i2.cat

         i(2 3 4).cat      three indicators, cat==2, cat==3, and cat==4;
                             same as i2.cat i3.cat i4.cat

         i(2/4).cat        same as i(2 3 4).cat

         2.cat#1.sex       a single indicator that is 1 when cat==2 and sex==1, and is 0 otherwise

         i2.cat#i1.sex     same as 2.cat#1.sex
         -----------------------------------------------------------------------------------------------------------



二维码

扫码加我 拉你入群

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

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

2012-12-28 10:39:58
xi: 是专门生成分类变量dummy的命令,还用来生成分类变量和其它变量的交叉项,分类变量放在前面,比如 i.rep78*gear_ratio,
xi: regress mpg i.rep78
生成的变量有 (每个都是判断变量,比如_Irep78_2 , 如果rep78==2,则回馈1,否则0)
_Irep78_2      
_Irep78_3      
_Irep78_4      
_Irep78_5  
rep78==1的自动作为参照组,省去(omitted),为避免多重共线性,即变量间可以用线性关系表示。
这样,所有回归出的分类变量上的系数都是相对于参照组rep78==1而言的。

二维码

扫码加我 拉你入群

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

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

2013-1-1 07:17:04
learning.
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群