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

Hi,

I am studying the association between a continuous exposure variable and a dichotomous outcome variable using poisson regression with robust error variance.  (I chose to use poisson regression here as opposed to logistic regression because the outcome prevalence in my sample is quite high - greater than 20%.)  In conducting my analyses, I found a significant interaction between the continuous exposure and a continuous modifier variable.  I would like to calculate the risk ratio when both the exposure and the modifier are increased by 10 units.  I have found examples of how to do this with estimate statements when working with interactions among categorical variables, but I have been unable to find similar examples for continuous by continuous interactions.  What is the appropriate SAS syntax for this scenario?  The code I am using is below:

    proc genmod data=test1;

    class sex race subject/ ref=first param=ref;

    model outcome = exposure*modifier exposure modifier age sex race / dist=poisson link=log type3 wald;

    repeated subject=subject / type=unstr;

    estimate ???;

    run;

Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

For continuous predictors, one puts the values of the predictors in the estimate statement. That is, when one lists x1, for example, the procedure substitutes the estimated parameter for x1; so, you give the x1 value. Here is an example program for what I think you want (using x1 and x2 for continuous predictors and cat for a categorical predictor (class variable). The model is for

     ln(mu) = intercept + b1*x1 + b2*x2 + b3*x1*x2

More comments after the code.

proc genmod data=a;

class cat;

model y = x1 x2 x1*x2 cat / type3 dist=poisson ;

estimate '0 0'   int 1  x1 0  x2 0  x1*x2 0;

estimate '10 10' int 1  x1 10 x2 10 x1*x2 100;

estimate '10-0, 10-0'   x1 10 x2 10 x1*x2 100 ;

/* Substract one from the other to get change in Y with a change in 10 (for x1 and x2) */

estimate '6 10'  int 1  x1 6  x2 10 x1*x2 60 ;

estimate '16 20' int 1  x1 16 x2 20 x1*x2 320 ;

estimate '16-6, 20-10'  x1 10 x2 10 x1*x2 260 ;

/* Because of interaction, difference depends on actual levels of x1,x2 */

run;

I give examples of getting the expected values for (x1,x2) = (0,0), and (10,10); that is an increase in 10 for both predictors. One puts in the x values, and the procedure does the multiplication. Note that for the x1*x2 term, one puts in 100 (10*10) for the second one. Subtracting the first two estimate statements gives the third one, the one I think you want (difference for a change in 10 for x1 and x2). You just subtract each of the relevant terms. You don't need the first two. I put them in to show you where the third one came from. I then did this for (x1,x2) = (6,10) and (16,20). Last estimate is the one you would want. You just subtract the relevant terms (320-60, and so on). With categorical variables in the model, one is getting expected values averaged over all the levels of the these factors.

View solution in original post

3 REPLIES 3
SteveDenham
Jade | Level 19

You might have to sneak up on this a bit.  I always have trouble with the L matrix entries needed to do this, so I would try to get a start on it by using the LSMEANS statement with the /e option.  To make this work somewhat better, rearrange the MODEL statement so that the class variables come first.

Try

lsmeans sex/e;

That should give a matrix that includes values for the continuous variables, including the interaction, with these values set at the mean.  However, these may be the coefficients so test it with:

estimate <all class variable stuff> <continuous values>;

and see if it gives back the LSmeans.  Once you have this down, it then becomes a matter of calculating the estimate at two points and creating an L matrix as the difference between the two.  I don't know if it sounds harder to do than it actually is, but has given several examples in the past month on how to do this (yes for categorical variables, but the principle applies to continuous as well).

Steve Denham

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

For continuous predictors, one puts the values of the predictors in the estimate statement. That is, when one lists x1, for example, the procedure substitutes the estimated parameter for x1; so, you give the x1 value. Here is an example program for what I think you want (using x1 and x2 for continuous predictors and cat for a categorical predictor (class variable). The model is for

     ln(mu) = intercept + b1*x1 + b2*x2 + b3*x1*x2

More comments after the code.

proc genmod data=a;

class cat;

model y = x1 x2 x1*x2 cat / type3 dist=poisson ;

estimate '0 0'   int 1  x1 0  x2 0  x1*x2 0;

estimate '10 10' int 1  x1 10 x2 10 x1*x2 100;

estimate '10-0, 10-0'   x1 10 x2 10 x1*x2 100 ;

/* Substract one from the other to get change in Y with a change in 10 (for x1 and x2) */

estimate '6 10'  int 1  x1 6  x2 10 x1*x2 60 ;

estimate '16 20' int 1  x1 16 x2 20 x1*x2 320 ;

estimate '16-6, 20-10'  x1 10 x2 10 x1*x2 260 ;

/* Because of interaction, difference depends on actual levels of x1,x2 */

run;

I give examples of getting the expected values for (x1,x2) = (0,0), and (10,10); that is an increase in 10 for both predictors. One puts in the x values, and the procedure does the multiplication. Note that for the x1*x2 term, one puts in 100 (10*10) for the second one. Subtracting the first two estimate statements gives the third one, the one I think you want (difference for a change in 10 for x1 and x2). You just subtract each of the relevant terms. You don't need the first two. I put them in to show you where the third one came from. I then did this for (x1,x2) = (6,10) and (16,20). Last estimate is the one you would want. You just subtract the relevant terms (320-60, and so on). With categorical variables in the model, one is getting expected values averaged over all the levels of the these factors.

jmdecu
Fluorite | Level 6

This is exactly what I was looking for.  Thanks so much!

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
  • 3 replies
  • 13740 views
  • 3 likes
  • 3 in conversation