Fluorite | Level 6

## How to compute incidence rate

Hello,

This is my first time writing here. I have mortality data from a cohort study. I've been trying to calculate incidence rates for mortality with no success. I used proc genmod with lsmeans to estimate the IR using Poisson, but the results are very very different from those obtained by my colleague using STATA.This is the code I've been using:

proc genmod data=muj;
class muerto diabetes(ref=first) educacion(ref=first) sexo(ref=last);
offset=logpyears;
lsmeans diabetes/ilink exp cl diff OM;
run;

The stata code used for this is the following:

poisson muerto i.diabetes i.cat_edad i.educacion, exposure(pyears) irr
margins diabetes, predict(ir)

Is there some procedure or code that gives me adjusted incidence rates?

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

## Re: How to compute incidence rate

You would need to fit exactly the same model in both SAS and Stata since any difference in the fitted model can cause a difference, large or small, in estimated values. A predictive margin for a level of your predictor is the average predicted value when all observations in your data have the predictor set to that level. So, you could easily compute the point estimate of the margin by creating a copy of your data set with your predictor set to one level and then compute all the predicted values and average them.

8 REPLIES 8
Barite | Level 11

## Re: How to compute incidence rate

Hi, it maybe helpful to post the Stata code as well?
Fluorite | Level 6

## Re: How to compute incidence rate

Thanks for the tip, just included the stata code in the question. 🙂
Super User

## Re: How to compute incidence rate

I moved this to the SAS/STAT community, so that the experts for that may be notified of your question.

Fluorite | Level 6

Thanks 😄

SAS Super FREQ

## Re: How to compute incidence rate

The SAS code looks correct and follows what is discussed in this note. But your Stata code looks like the model only has one predictor while your SAS code has three, so that will clearly cause a difference. Additionally, note that the predictive margin computed in Stata is not the same as an LS-mean.

Fluorite | Level 6

## Re: How to compute incidence rate

What would be the equivalent in SAS fro the margin computed in STATA?
(we've been varying the covariates, so it is possible that the codes are a little different, but the results we get are different anyway)
SAS Super FREQ

## Re: How to compute incidence rate

You would need to fit exactly the same model in both SAS and Stata since any difference in the fitted model can cause a difference, large or small, in estimated values. A predictive margin for a level of your predictor is the average predicted value when all observations in your data have the predictor set to that level. So, you could easily compute the point estimate of the margin by creating a copy of your data set with your predictor set to one level and then compute all the predicted values and average them.

Fluorite | Level 6

## Re: How to compute incidence rate

Just updated the code for STATA...thanks
Discussion stats
• 8 replies
• 7509 views
• 1 like
• 4 in conversation