Programming the statistical procedures from SAS

How to write estimate statements for continuous by continuous interactions in proc genmod?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

How to write estimate statements for continuous by continuous interactions in proc genmod?

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!


Accepted Solutions
Solution
‎07-06-2015 04:20 PM
Valued Guide
Valued Guide
Posts: 684

Re: How to write estimate statements for continuous by continuous interactions in proc genmod?

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


All Replies
Respected Advisor
Posts: 2,655

Re: How to write estimate statements for continuous by continuous interactions in proc genmod?

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

Solution
‎07-06-2015 04:20 PM
Valued Guide
Valued Guide
Posts: 684

Re: How to write estimate statements for continuous by continuous interactions in proc genmod?

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.

Occasional Contributor
Posts: 8

Re: How to write estimate statements for continuous by continuous interactions in proc genmod?

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 1511 views
  • 1 like
  • 3 in conversation