BookmarkSubscribeRSS Feed
Visiting
Obsidian | Level 7

Is there a sample code available to run random effect zero inflated negative binomial model for count data?

I found a program for random effect zero inflated poison from here: https://stats.oarc.ucla.edu/sas/faq/how-do-i-run-a-random-effect-zero-inflated-poisson-model-using-n...

How to modify it to run negative binomial zero inflated data? code was pasted below. Thank you!

proc nlmixed data = hdp method=gauss qpoints=25;
  parms b0=1.0569 b1=-0.0020 b2=0.0094 b3=0.0122 b4=0.0239 b5=0.0530 b6=0.1322
        a0=-1.6766 a1=-0.0116 a2=0.7479 a3=1.2588 a4=-0.8077 a5=-2.1410 a6=-2.7530 	
        sigma2=0.2414;
  logit0 = a0 + a1*Age + a2*SmokingHx2 + a3*SmokingHx3 +
    a4*CancerStage2 + a5*CancerStage3 + a6*CancerStage4;
  prob0 = 1 / (1 + exp(-logit0));
  mu = exp(b0 + u + b1*Age + b2*LengthofStay + b3*BMI + 
    b4*CancerStage2 + b5*CancerStage3 + b6*CancerStage4);
  if nmorphine = 0 then
    ll = log(prob0 + (1 - prob0)*exp(-mu));
  else
	ll = nmorphine*log(mu) + log(1 - prob0) - mu - lgamma(nmorphine + 1);
  model nmorphine ~ general(ll);
  random u ~ normal(0, sigma2) subject=DID;
run;

  

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Advice: Using tabs leads to the misaligned code you provided. Use spaces to keep formatting consistent. 

 

Sorry, I cannot answer the question itself.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 688 views
  • 0 likes
  • 2 in conversation