jingju11 发表于 2012-9-25 08:42 
略微补充一下:
在sas新近的版本里,proc genmod也包含0-inflated 模型(poisson 和nb)。如果使用sas9.3, ...
Jingju,想请教你一段代码。我看你博客写的,然后按你写的编了下。
但proc countreg和proc nlmixed求解参数估计结果不一样,不知道是哪里出错了?
更奇怪的是当P和协变量不相关时,P为常数时,两个过程得到的结果是一样的。
/*-- Zero-Inflated Negative Binomial Model */
proc countreg data=clmfreq covest=hessian method=nra;
model CLM_FREQ=new_CAR_USE new_MARRIED new_DENSITY new_INCOME new_GENDER/ dist=ZINB;
zeromodel CLM_FREQ ~new_CAR_USE new_MARRIED new_DENSITY new_INCOME new_GENDER /link=logistic;
run;
/*--Proc Nlmixed--*/
proc nlmixed data=clmfreq;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 a0=0 a1=0 a2=0 a3=0 a4=0 a5=0 infprinfl=0 k=1;
infprinfl= a0+a1*new_CAR_USE+ a2*new_MARRIED+a3*new_DENSITY+a4*new_INCOME+a5* new_GENDER;
infprob=1/(1+exp(-infprinfl));
linp=b0+b1*new_CAR_USE+ b2*new_MARRIED+b3*new_DENSITY+b4*new_INCOME+b5* new_GENDER;
mu=exp(linp);
p=1/(1+mu*k);
ll=(CLM_FREQ=0)*(log(infprob+(1-infprob)*pdf('negbinomial',CLM_FREQ,p,1/k)))+
(CLM_FREQ^=0)*(log(1-infprob)+log(pdf( 'negbinomial',CLM_FREQ,p,1/k)));
model CLM_FREQ~general(ll);
predict exp(ll) out=nb0Out(keep=CLM_FREQ pred);
run;