BookmarkSubscribeRSS Feed
lk7200
Calcite | Level 5
Hi,

Is it possible to estimate the residual deviance of a Poisson model with random effects using PROC NLMIXED?

Thank you.
2 REPLIES 2
Dale
Pyrite | Level 9
It is possible to generate deviance residuals from the NLMIXED procedure. But the deviance residuals have to be written to an output data set where they can be examined and the total deviance generated. For a Poisson response, code for computing deviance residuals and writing them to an output data set would be:

proc nlmixed data=mydata;
  eta = b0 + b1*x1 + b2*x2 + ... + u;
  lambda = exp(eta);
  ll_model = -lambda + y*log(lambda) - lgamma(y+1);
  if y>0 then ll_sat = -y + y*log(y) - lgamma(y+1);
  else ll_sat = 0;
  resid_dev = sign(y - lambda) * sqrt(2*(ll_sat - ll_model));
  model y ~ general(ll_model);
  random u ~ normal(0, V_u) subject=id;
  predict resid_dev out=deviance;
run;

Total deviance can then be obtained as:

data _null_;
  set deviance end=lastrec;
  deviance + resid_dev**2;
  if lastrec then put deviance=;
run;


Of course, you don't have to use the GENERAL log likelihood specification on the MODEL statement. You could specify that the distribution is POISSON. But it is necessary to construct the model log likelihood along with the saturated log likelihood in order to obtain the deviance residual. Once you have computed the model log likelihood, you have already done a lot of the work which the NLMIXED procedure would do if you specified a POISSON model. So, it would be computationally efficient to indicate that you want to maximize the likelihood that you have already constructed.
lk7200
Calcite | Level 5
Thank you very much!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2495 views
  • 0 likes
  • 2 in conversation