BookmarkSubscribeRSS Feed
BayzidurRahman
Obsidian | Level 7

Hi, I am trying to obtain adjusted rate with 95% CI from a Poisson model for each cluster in the dataset. Please see the attached dataset. I am fitting the following GEE model. I am also happy to consider a random effects model if that helps.

PROC GENMOD data=ForIndQ.sample_data;
  CLASS x1 cid;
  MODEL y=x1-x4 /d=poisson link=log offset=log_offset;
  REPEATED subject=cid/ type=exch;
RUN;

Here CID is the cluster id and I want to get the adjusted rates from the model with 95% CI for each of the CID.

5 REPLIES 5
Ksharp
Super User
You could check %margin macro :
https://support.sas.com/kb/63/038.html

EXAMPLE 4: Margins and marginal effects in a GEE model

or %nlmeas macro:
https://support.sas.com/kb/62/362.html
StatDave
SAS Super FREQ

The easiest way to obtain an estimated rate for each CID is to simply average the predicted rates within each CID.  Using the SCORE statement in PROC PLM to obtain the predicted rates as described in this note, the following produces a data set of the average predicted rates for the CIDs:

PROC GENMOD data=sample_data;
  CLASS x1 cid;
  MODEL y=x1-x4 /d=poisson link=log offset=log_offset;
  REPEATED subject=cid/ type=exch;
  store out=mod;
  run;
proc plm source=mod;
  score data=sample_data out=pred pred stderr lclm uclm / nooffset ilink;
  run;
proc means data=pred; class cid; var predicted; run;

This is essentially a predictive margin, which is an average predicted value, but averaged only over the predicted values in a CID. It might be slightly better to get the sum of the predicted counts, not rates, in a CID and then divide it by the sum of the offset values in the CID. You can use the P= option in the OUTPUT statement to get the predicted counts.

 

But the above only provides point estimates, not standard errors. To obtain predictive margin point estimates and standard errors and confidence intervals, you could use the Margins macro including the WITHIN= option to identify a specify CID. For example:

%margins(data=sample_data, class=x1 cid, response=y, 
     model=x1 x2 x3 x4, dist=poisson, offset=log_offset,
     geesubject=cid, geecorr=exch, within=cid='AC-1010',
     options=cl rate )

By itself, the macro only allows you to do this for one CID at a time, so you would need to run the macro for each CID. Or you could do them all in one shot by using the Margins macro with the RunBY macro as described in the Margins macro documentation and shown in the last two examples in the Results tab there.

BayzidurRahman
Obsidian | Level 7

Thanks for your support. 

BayzidurRahman
Obsidian | Level 7

Is it possible to obtain directly standardized rates for each CID with 95% CI using the covariate structure of the whole dataset by doing some modification of your code? 

StatDave
SAS Super FREQ

As mentioned in the note I referred you to in your direct standardization post, the directly standardized rate, DSR, is just a weighted crude rate, where the weight is the exposure proportion of the particular stratum in the reference population, P. Given that proportion, DSR=P*CR and stderr(DSR)=P*stderr(CR), where CR is the crude rate. This is easily computed by hand or you can use the NLEST macro to do it for you after using the Margins macro call as I showed, but adding COVOUT in OPTIONS= in the Margins macro call. For example, replace P with its numerical value in the following and use it after the Margins macro call.

%nlest(inest=_margins, incovb=_covmarg, f=b_p1*P, label=direct stdzd rate)

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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
  • 5 replies
  • 1013 views
  • 2 likes
  • 3 in conversation