程序如下:
proc nlmixed data=sasuser.c7;/*多水平零膨胀负二项(logistic yn)*/
parms A0=-0.2285 Asex=-0.5112 Aage=-0.00767 aedu=0.07857 aq32=0.2301 avolun1=-0.2291 adrink=-0.4512
ac10new=0.2190 ac11new=-0.2265 apress=-0.1642
B0=-0.09054 bsex=-0.4259 bage=-0.00888 bvolun1=-0.2152 bc10new=0.1656 bc11new=-0.2021
v_u1=-107E-14,cov_u12=1,v_u2=0.2758 k=1.3513;
s1=A0+Asex*sex+Aage*age++Aedu*edu+aq32*q32+avolun1*volun1+adrink*drink+ac10new*c10new+ac11new*c11new+apress*press+u1;
p=1/(1+exp(-s1));
s2=B0+Bsex*sex+Bage*age+Bvolun1*volun1+Bc10new*c10new+Bc11new*c11new+u2;
lambda=exp(s2);
pdf=gamma(n+1/k)/(gamma(n+1)*(gamma(1/k)))*(((k*lambda)**n)/(1+k*lambda)**(n+1/k));
if n=0 then pdf=p+(1-p)*pdf;
else pdf=(1-p)*pdf;
if pdf>1e-8 then ll=log(pdf);
else ll=-1e20;
model n~general(ll);
random u1 u2~normal([0,0],[v_u1,cov_u12,v_u2]) subject=site;
run;