BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DID
Fluorite | Level 6 DID
Fluorite | Level 6

I'm conducting a difference-in-difference analysis to assess the impact of an intervention on violent crime.My outcome is violent crime, inputted as a count that is converted to a rate via an offset of (ln of population years) to account for a changing population over time.

 

I want to asses whether my count outcome data are overdispersed to confirm that I am appropriately using a negative binomial distribution. I'm using proc glimmix (SAS 9.4). I read about using the standard "Gener. Chi-Square/DF" output to determine whether data are overdispersed, with a value closer to 1.0 showing that the data are not overdispersed; but I was cautioned not to use this calculation to determine whether I should use a negative binomial model instead of a Poisson model.

 

I have been advised to assess whether my outcome data are overdispersed by dividing the residual deviance by the predicted mean. Is there SAS code I can add to my glimmix model to calculate this? Here is my present code for a difference-in-difference model with a negative binomial distribution.

 

proc glimmix data=main.simple_model;
class tract post (ref='0') exposed (ref='0');
model totcrime = post exposed post*exposed covariates/
solution
dist = negbin
link = log
offset = logpopyrs
cl;
random int/subject=tract type=un s;
covtest 'var(tract)=0' . 0;
run;

 

Would another possibility be to run the model as a Poisson model and then a negative binomial model and do a likelihood ratio test?

 

Thank you.

 
1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

You might try adding PLOTS=pearsonpanel(conditional marginal) to the PROC GLIMMIX statement.  Not sure that is what you are going after but it will produce plots of the Pearson residuals versus the predicted values, both conditional and marginal.

 

You can also use the OUTPUT statement for something like:

 

output out=out1 pred(/* choose what predicted value you want*/)=predicted 
pearson/* choose what predicted value you want, but make sure it is the same as for the predicted value*/) =pearson;

That ought to give you a similar dataset where you could use PROC SGPLOT.

 

 

SteveDenham

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

The link gives an R approach to answering the question using a likelihood ratio test: https://www.statology.org/negative-binomial-vs-poisson/  To accomplish the same thing in SAS, use the converged log likelihood value from the two choices. The difference should be distributed as a chi-squared variate with a single degree of freedom.  But the big thing that is in this website is "LOOK AT THE RESIDUALS GRAPHICALLY".  Over or underdispersion to the degree that inferences may be affected should be readily apparent from a plot of residuals vs. predicted values.

 

SteveDenham

DID
Fluorite | Level 6 DID
Fluorite | Level 6

Thank you Steve.This is helpful.

 

When I used proc genmod for another project I used the code:

 

output out=residuals
stdreschi = Stdreschi;
Proc plot data=residuals;
plot stdreschi*time_yrs_t;
run;

 

This code doesn't seem to be available for/work in proc glimmix. Do you know of code with me that will enable proc glimmix to output the residuals and predicted values so that I can plot them?

 

SteveDenham
Jade | Level 19

You might try adding PLOTS=pearsonpanel(conditional marginal) to the PROC GLIMMIX statement.  Not sure that is what you are going after but it will produce plots of the Pearson residuals versus the predicted values, both conditional and marginal.

 

You can also use the OUTPUT statement for something like:

 

output out=out1 pred(/* choose what predicted value you want*/)=predicted 
pearson/* choose what predicted value you want, but make sure it is the same as for the predicted value*/) =pearson;

That ought to give you a similar dataset where you could use PROC SGPLOT.

 

 

SteveDenham

DID
Fluorite | Level 6 DID
Fluorite | Level 6

This has all been very helpful Steve! Thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1132 views
  • 2 likes
  • 2 in conversation