楼主: Silence.
4952 11

[问答] 求大神帮忙,零膨胀模型zeromodel如果协变量是定性变量的处理方法? [推广有奖]

  • 3关注
  • 1粉丝

博士生

51%

还不是VIP/贵宾

-

威望
0 级
论坛币
816 个
通用积分
1.1800
学术水平
3 点
热心指数
3 点
信用等级
3 点
经验
5152 点
帖子
144
精华
0
在线时间
402 小时
注册时间
2010-8-6
最后登录
2022-10-11

楼主
Silence. 发表于 2012-9-28 12:58:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
零膨胀模型zeromodel如果协变量是定性变量的处理方法。看了很多代码,比如如果是性别,直接就女性为1,男性为2,感觉这样做不对,男性不一定是女性的一倍比例。
data zinb;
input id count family diabetes gender age hr esv@@;
cards;
1 0 0 0 2 69 89 28
2 0 0 0 1 52 91 49
3 0 1 1 1 35 86 23
......
;
proc countreg data=zinb covest=hessian  method=nra;
model count=family diabetes gender age hr esv/dist=zinb;
zeromodel count~family diabetes gender age hr esv/link=logistic;
run;
比如这段代码,它将gender赋值为1和2。如何解释?
我想写一个zeromodel的程序,里面的协变量基本上都是定性变量,该如何处理?求各位大神帮帮忙呀!
二维码

扫码加我 拉你入群

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

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

关键词:model zero mode 处理方法 ODE diabetes family method count 女性

回帖推荐

ziyenano 发表于5楼  查看完整内容

二分类变量在回归模型中,设不设置成分类变量,效果是一样的; https://bbs.pinggu.org/thread-1539337-1-1.html; 我在这里做过详细解释; 楼主要尝试设置分类变量的话,试试genmod; proc genmod data=zinb; model count=family diabetes gender age hr esv/dist=zip link=log;/*zinb我不知道新版本支持不支持*/ zeromodel family diabetes gender age hr esv; run;

本帖被以下文库推荐

沙发
FB_FLORA 发表于 2012-9-28 15:52:52
这个用虚拟变量不行吗?class列出你的定型变量,sas会处理的,我最近刚好看到那

藤椅
Silence. 发表于 2012-9-28 17:10:46
FB_FLORA 发表于 2012-9-28 15:52
这个用虚拟变量不行吗?class列出你的定型变量,sas会处理的,我最近刚好看到那
CLASS是放在proc coutreg里面吗?我放里面会报错呀!

板凳
jingju11 发表于 2012-9-28 21:28:57
countreg not accept class statement. you can move the model to proc genmod.
about gender: f vs. m, 0 vs. 1, 1 vs 2, for main effect only model, should be no difference in the model, except for some absorption to the intercept. all in all, making gender dummy is a general way for dealing with no CLASS variable allowed, such reg procedure in sas. jingju

报纸
ziyenano 发表于 2012-9-28 21:50:36
二分类变量在回归模型中,设不设置成分类变量,效果是一样的;
https://bbs.pinggu.org/thread-1539337-1-1.html;
我在这里做过详细解释;
楼主要尝试设置分类变量的话,试试genmod;
proc genmod data=zinb;
model count=family diabetes gender age hr esv/dist=zip link=log;/*zinb我不知道新版本支持不支持*/
zeromodel  family diabetes gender age hr esv;
run;
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

地板
Silence. 发表于 2012-9-29 14:23:32
ziyenano 发表于 2012-9-28 21:50
二分类变量在回归模型中,设不设置成分类变量,效果是一样的;
https://bbs.pinggu.org/thread-1539337-1-1 ...
你好,我按你说的方法,运行出这样的结果:
写模型时是不是
=exp(intercept+a1car_use+a2MARRIED+a3DENSITY1+a4DENSITY2+a5DENSITY3+a6INCOME+a7GENDER)
比如car_use取1代表Commercial ,取0代表Private。再如DENSITY,当是Highly Rural的时候DENSITY1取1,并且此时a3=0.1263。当Highly Urban时,DENSITY2取1,并且a4=-0.0365 。依次下去。当为Urban时,DENSITY1=DENSITY2=DENSITY3=0.是这样理解吗?
还有我用的是SAS9.2版本,好像不能genmod里直接用zinb,9.3版本有这个功能吗?

Parameter                  DF   Estimate      Error          Limits         Chi-Square   Pr > ChiSq

Intercept                   1     0.5203     0.0707     0.3818     0.6588        54.18       <.0001
CAR_USE     Commercial      1     0.0272     0.0577    -0.0860     0.1403         0.22       0.6377
CAR_USE     Private         0     0.0000     0.0000     0.0000     0.0000          .          .
MARRIED     No              1     0.0156     0.0550    -0.0921     0.1234         0.08       0.7760
MARRIED     Yes             0     0.0000     0.0000     0.0000     0.0000          .          .
DENSITY     Highly Rural    1     0.1263     0.1921    -0.2501     0.5028         0.43       0.5108
DENSITY     Highly Urban    1    -0.0365     0.0551    -0.1445     0.0715         0.44       0.5079
DENSITY     Rural           1    -0.1641     0.1333    -0.4254     0.0972         1.52       0.2183
DENSITY     Urban           0     0.0000     0.0000     0.0000     0.0000          .          .
INCOME                      1     0.0000     0.0000    -0.0000     0.0000         0.20       0.6567
GENDER      F               1    -0.0153     0.0562    -0.1254     0.0949         0.07       0.7861
GENDER      M               0     0.0000     0.0000     0.0000     0.0000          .          .
Scale                       0     1.0000     0.0000     1.0000     1.0000

7楼
Silence. 发表于 2012-9-29 14:37:04
jingju11 发表于 2012-9-28 21:28
countreg not accept class statement. you can move the model to proc genmod.
about gender: f vs. m, ...
When there is no Class statement in the countreg procedure, could I define some new variables to treat qualitative variables.Such as DENSITY has four levels,Highly Rural,Highly Urban,Rural and Urban. Define density1=1 if   DENSITY is Highly Rural,density2=1 if   DENSITY is Highly Urban,density3=1 if   DENSITY is Rural ,density4=1 if   DENSITY is Urban or if   DENSITY is Urban density1=density2=density3=0.Then we use proc countreg to model with this new variable. Is this method correct? and Is there any difference between using Proc genmod and this method?

8楼
ziyenano 发表于 2012-9-29 14:51:05
Silence. 发表于 2012-9-29 14:23
你好,我按你说的方法,运行出这样的结果:
写模型时是不是
=exp(intercept+a1car_use+a2MARRIED+a3DE ...
不是density取1,那里的1是DF(自由度);
设置成分类变量,以density为例;
如果一个观测,它的density是highly rural,那此时模型该项的系数是0.1263;
如果它的density是highly urban,此时模型该项系数为-0.0365;
如果density是urban,此时模型该项系数为0

9楼
Silence. 发表于 2012-9-29 15:15:57
ziyenano 发表于 2012-9-29 14:51
不是density取1,那里的1是DF(自由度);
设置成分类变量,以density为例;
如果一个观测,它的density是 ...
谢谢你的回复!

10楼
Silence. 发表于 2012-9-29 16:08:09
ziyenano 发表于 2012-9-29 14:51
不是density取1,那里的1是DF(自由度);
设置成分类变量,以density为例;
如果一个观测,它的density是 ...
还想请教一下,看这本书的Generalized Linear Models for Insurance Data(Piet De Jong)里

When a potential explanatory variable is categorical, then it is “dummied up”
for inclusion into a multiple linear regression. For example, suppose the area of
residence of a policyholder is considered to be a potential explanatory variable
in a model for claim size y. If there are three areas A, B and C, then two
indicator (dummy) variables x1 and x2 are defined:
Area x1 x2
A 1 0
B 0 1
C 0 0
Suppose area is the only explanatory variable. Then the relationship ismodeled
as
y ≈ β0 + β1x1 + β2x2 .
This states that y ≈ β0 in area C, y ≈ β0 + β1 in area A, and y ≈ β0 + β2
in area B. Thus β1 is the difference between areas C and A, while β2 is the
difference between areas C and B.
这个虚拟变量该如何解释呢?

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-10-25 21:55