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

Hello!

 

I have found a significant interaction effect of moderator A on the association between X and Y. I now want to test and plot at which values of A (-1 SD, 0, +1 SD) the relationship between X and Y significant. I am examining both within and between subject associations using glimmix for drinking frequency (drinks/no drinks) and nlmixed for drinking quantity (count data), however, I only found a significant interaction effect at the within-person level.

Any help with this would be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

@Laian_N , I just thought of something a bit scary - you are fitting a large number of effects (61 + number of days in Days_c, by my count).  Finding only one interaction significant may be just an artifact.  I would sort of expect about 3 effects to be significant at the 0.05 level if I were fitting random numbers.  You may want to try GLMSELECT with a LASSO or elasticnet variable selection method to reduce the dimensionality of your X'beta matrix, and then see if there are any interactions to be investigated.  Or perhaps you can use some prior knowledge to eliminate some of the variables.

 

There are likely some data science approaches that would be more fruitful as well.

 

SteveDenham

View solution in original post

11 REPLIES 11
SteveDenham
Jade | Level 19

Is A continuous or categorical?  I assume continuous, as you speak of wanting to look at values of A based on the SD.  Can you share your current GLIMMIX code?  It would be easier to add things in to what you already have than to try to start from scratch.

 

SteveDenham

Laian_N
Calcite | Level 5

Yes, most certainly. Here is the GLIMMIX code. And yes, A is continuous and so is my predictor variable. 

 

proc glimmix data=SHB.Days_final lognote;
class IDnum Days_c;
model Freq = DDmodmet_c|SS_sd DDmodmet_dev|SS_sd DDvigmet_c|SS_sd DDvigmet_dev|SS_sd
DDmodmet_c|PU_sd DDmodmet_dev|PU_sd DDvigmet_c|PU_sd DDvigmet_dev|PU_sd
DDmodmet_c|NU_sd DDmodmet_dev|NU_sd DDvigmet_c|NU_sd DDvigmet_dev|NU_sd
DDmodmet_c|pers_sd DDmodmet_dev|pers_sd DDvigmet_c|pers_sd DDvigmet_dev|pers_sd
DDmodmet_c|prem_sd DDmodmet_dev|prem_sd DDvigmet_c|prem_sd DDvigmet_dev|prem_sd male Weekend PreviousFreq Days_c / solution dist= binomial ddfm=kr2;
random intercept / subject=IDnum;
random Days_c / subject=IDnum type=ar(1) residual;
nloptions tech= nrrdg maxiter=500;
store SHB.IMPinteractions / label='Interactions with IMP';
run;

 

Only the interaction in red was significant. I used the STORE statement to then test significant interactions for different values of A (here PU_sd) and plot them using PROC PLM. However, I was only able to plot but not run the test of significance on the different values of A (here PU_sd), since GLIMMIX does not support the SLICE option. I am wondering if there are any alternative options for SLICE that are supported by GLIMMIX, or any other ways I can do this?

 

So I was successfully able to visualize the interactions for different values of PU_sd with the code below:

proc plm restore=SHB.IMPinteractions;
effectplot slicefit(x=DDmodmet_dev sliceby=PU_sd);
run; 

 

This is the code I tried for the test of significance:

proc plm restore=SHB.IMPinteractions;

test;
slice DDmodmet_dev*PU_sd;
effectplot;

run;

SteveDenham
Jade | Level 19

Well, GLIMMIX does support the SLICE statement but for your work it won't make much sense, as it usually means testing for simple effects at a given level of a categorical variable.  I think you will need to use the AT option in an LSMEANS statement.<--EDIT: Won't work as both elements are continuous.

 

Something like this might give what you are looking for, but only if DDmodmet_de is a categorical variable:

 

proc plm restore=SHB.IMPinteractions;
lsmeans DDmodmet_dev/diff AT means;
lsmeans DDmodmet_dev/diff AT PU_sd= <a low value, say mean - 1sd)>;
lsmeans DDmodmet_dev/diff AT PU_sd= <a high value, say mean + 1sd)>;
effectplot (PLOTBY=DDmodmet_dev, X=PU_sd);
run;

It appears that the AT option doesn't support multiple values for a single continuous covariate, so there are multiple LSMEANS statements.  You might want to add more depending on the range of PU_sd.

 

EDIT: I missed the point that DDmodmet_de is continuous as well. That makes everything somewhat more difficult.  The EFFECTPLOT statement won't work as the PLOTBY variable is not categorical (plus I forgot to specify the FIT suboption). The same applies to the LSMEANS statements.

 

For the EFFECTPLOT, you might try EFFECTPLOT (contour PLOTBY=Freq X=DDmodmet_dev Y=PU_sd).

For tests, I think you will probably have to wrie a bunch of ESTIMATE statements that look something like:

 

ESTIMATE 'point (x1, y1)' intercept 1 DDmodmet_dev <insert a value for this - X1 as an example> PU_sd <insert a value for this - Y1 as an example>,
          'point (x2, y1)' intercept 1 DDmodmet_dev <insert a value for this - X2 as an example> PU_sd <insert a value for this - Y1 as an example>,
...
         'point (xN, y1)' intercept 1 DDmodmet_dev <insert a value for this - XN as an example> PU_sd <insert a value for this - Y1 as an example>,
         'point (x1, y2)' intercept 1 DDmodmet_dev <insert a value for this - X1 as an example> PU_sd <insert a value for this - Y2 as an example>,
...
         'point (xN, yM)' intercept 1 DDmodmet_dev <insert a value for this - XN as an example> PU_sd <insert a value for this - YM as an example>/ILINK;

SteveDenham

 

 

 

SteveDenham
Jade | Level 19

@Laian_N , I just thought of something a bit scary - you are fitting a large number of effects (61 + number of days in Days_c, by my count).  Finding only one interaction significant may be just an artifact.  I would sort of expect about 3 effects to be significant at the 0.05 level if I were fitting random numbers.  You may want to try GLMSELECT with a LASSO or elasticnet variable selection method to reduce the dimensionality of your X'beta matrix, and then see if there are any interactions to be investigated.  Or perhaps you can use some prior knowledge to eliminate some of the variables.

 

There are likely some data science approaches that would be more fruitful as well.

 

SteveDenham

Laian_N
Calcite | Level 5

Thanks very much for the helpful suggestions. Regarding overfitting, I did run the models with fewer variables based on information from prior studies and found similar results. 

Laian_N
Calcite | Level 5

Hi Steve,

 

Thanks for the suggested code. I tried it and it gave me this message: ERROR: Only CLASS variables allowed in this effect. Are there any other ways I can find at which values of the moderator is the interaction significant? 

SteveDenham
Jade | Level 19

I apologize.  I edited my response to recognize that, and added the only way I could think of to do the testing for two continuous covariates in this setting.

 

SteveDenham

SteveDenham
Jade | Level 19

Could you post the pertinent section of the log where this error occurs?  See the post by @sld  on this topic https://communities.sas.com/t5/Statistical-Procedures/How-to-write-estimate-statements-for-continuou... for an example of continuous by continuous interactions using ESTIMATE statements. The post by the OP in that thread looks like they were also trying to look for the effect of a moderating variable.

 

SteveDenham

 

 

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

I'd be happy to take credit, but that was @lvm 's solution 🙂

SteveDenham
Jade | Level 19

Disconnect on the eye-brain-fingers circuit...

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

I am flattered to be confused with @lvm 🙂

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 11 replies
  • 1170 views
  • 1 like
  • 3 in conversation