BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
WangYucheng
Calcite | Level 5

Dear SAS professionals, 

 

I am currently using proc genmod for negative binomial regression with an offset variable. When I tried to produce some graphs I found MOFF option is not available for the negative binomial model. I have two questions: 

1) Does offset function in negative binomial model the same way as in Poisson model? Why couldn't I use MOFF in NB?

2) Can I get the rate estimates by dividing count estimates by offset (exponent)?

Here is my code: 

proc genmod data=workdata;
	model count = WS log_d age_65 log_hhi unemployment bed 
		WS*log_hhi /
		dist=nb offset=log_p;
	store store1;
run;
proc plm restore=store1;
	effectplot slicefit (x=WS sliceby=log_hhi) / clm moff;
run;

And this is the warning I got: 

ERROR: The MOFF option is only available for Poisson regression with an offset variable and the log link.

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

Using the same DATA step to compute the predicted rates and confidence limits as shown in this note, the following statements produce the plot for the negative binomial model.

proc genmod data=insure;
  class age;
  model c = carnum age / dist=negbin link=log offset=ln;
  output out=out xbeta=xb stdxbeta=std;
  run;
data predrates;
  set out;
  obsrate=c/n;         /* observed rate */
  lograte=xb-ln;
  prate=exp(lograte);  /* predicted rate */
  lcl=exp(lograte-probit(.975)*std);
  ucl=exp(lograte+probit(.975)*std);
  run;
proc sort; 
  by age carnum; 
  run;
proc sgplot;
  band upper=ucl lower=lcl x=carnum / group=age;
  series y=prate x=carnum / group=age;
  xaxis grid; yaxis grid; 
  run;

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

My documentation may be out of date (SAS/STAT 14.1), but it appears to me that MOFF needs either an ILINK or LINK option to be effective (although that ERROR message seems to indicate something else).  Your proposed solution appears to be the equivalent of adding the ILINK option.

 

So, you should be able to get this from the OUTPUT statement with a PRED option, or the XBETA option.  It appears that the XBETA value includes the offset, so you might (emphasis on might) get rates by exponentiating XBETA.

 

SteveDenham

STAT_Kathleen
SAS Employee

An offset can be used in negative binomial models in exactly the same way and for the same purpose as it is used in Poisson models. This is discussed and illustrated in this note. However, keep in mind PROC PLM procedure only supports the MOFF option with Poisson distribution as described next.

 

NOOFFSET
MOFF

moves the offset for a Poisson regression model to the response side of the equation. If the ILINK option is also specified, then the rate is displayed on the Y axis; if the LINK option is also specified, then the log of the rate is displayed on the Y axis. Without the NOOFFSET option, the predicted values are computed and displayed only for the observations.

 

StatDave
SAS Super FREQ

Using the same DATA step to compute the predicted rates and confidence limits as shown in this note, the following statements produce the plot for the negative binomial model.

proc genmod data=insure;
  class age;
  model c = carnum age / dist=negbin link=log offset=ln;
  output out=out xbeta=xb stdxbeta=std;
  run;
data predrates;
  set out;
  obsrate=c/n;         /* observed rate */
  lograte=xb-ln;
  prate=exp(lograte);  /* predicted rate */
  lcl=exp(lograte-probit(.975)*std);
  ucl=exp(lograte+probit(.975)*std);
  run;
proc sort; 
  by age carnum; 
  run;
proc sgplot;
  band upper=ucl lower=lcl x=carnum / group=age;
  series y=prate x=carnum / group=age;
  xaxis grid; yaxis grid; 
  run;
WangYucheng
Calcite | Level 5

Thanks for all the replies! That's very inspiring. Additionally, when estimating the effect, are we using a fixed offset? For example, a mean or a median, like other covariates, in order to make an effectplot.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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