BookmarkSubscribeRSS Feed
madisonsmith
Calcite | Level 5

Hello all, I have run a series of PROC MIXED models with a mix of categorical, continuous, and spline predictors plus multiple interaction terms on a sample of N=205 who each contributed 7 repeated measures (example syntax below). In fixed effects, one of the interaction terms is significant, which I plotted using the outpred and PROC SGPLOT options (first example graph below). 

 

Now, one of my coauthors is wanting me to test simple slopes of the interaction. I tried using the store option and PROC PLM procedures, but I get slightly different results of the simple slopes in the 2nd example graph below (i.e., two are negative and only one is slightly positive) compared to the visual interpretation from the PROC SGPLOT (i.e., two clearly positive, one strongly negative). 

The only examples I am finding online have to do with a single interaction term, so I'm not sure how this is handled in a multivariate context and whether that could be to blame for the slight difference in interpretation. If so, which one might be "correct" and how do I modify my syntax?

 

PROC MIXED data=work.import covtest noclprint method = ML;
class fab400_id partner(ref="Yes") TransitionSingle(ref="Continuance of Singlehood OR In a Relationship")
TransitionRelat(ref="Continuance of Relationship OR Being Single") GID_Male(ref="Cisgender") dem06_L2(ref="Cisgender");
model pss_sum = Age_T1 GID_male dem06_L2 visit partner Length2 TransitionSingle TransitionRelat Time mspss_total_personmean fobss_total_personmean
partner*fobss_total_personmean Length2*fobss_total_personmean TransitionSingle*fobss_total_personmean TransitionRelat*fobss_total_personmean
Time*fobss_total_personmean /solution outpred=mixedout;
random intercept visit / sub=fab400_id type=vc;
Repeated / Subject=fab400_id;
store pred1;
run;

proc plm restore=pred1;
estimate 'Length slope, FOBS=mean-sd' Length2 1 Length2*fobss_total_personmean 1.41,
'Length slope, FOBS=mean' Length2 1 Length2*fobss_total_personmean 2.65,
'Length slope, FOBS=mean+sd' Length2 1 Length2*fobss_total_personmean 3.89 / e;
effectplot fit (x=Length2) / at(fobss_total_personmean=1.41 2.65 3.89);
run;

Data mixedout_nomiss;
set mixedout(where=(FOBS ne .));
run;

proc sgplot data=mixedout_nomiss nowall noborder;
styleattrs backcolor=white;
reg x=Length2 y=pred / nomarkers group=FOBS;
yaxis label="Stress";
xaxis integer label="Current Singlehood Length" ;
legenditem type=line name="-1" / label="Low FOBS" LINEATTRS=(pattern=solid color=darkblue thickness=2);
legenditem type=line name="0" / label="Average FOBS" LINEATTRS=(pattern=mediumdash color=firebrick thickness=2);
legenditem type=line name="1" / label="High FOBS" LINEATTRS=(pattern=longdashshortdash color=cadetblue thickness=2);
keylegend "-1" "0" "1" / noborder location=outside position=right
title="Fear of Being Single";
run;

 

madisonsmith_1-1680474963199.png

 

madisonsmith_0-1680474905925.png

Thank you all in advance!

9 REPLIES 9
jiltao
SAS Super FREQ

Regarding your PROC SGPLOT:

FOBS does not seem to be in the model, so it might not be a plot to depict the interaction term in the model. It does show how the predicted values change over LENGTH2 for different groups of FOBS. And the predicted values are computed accounting for all other effects in the model.

Regarding your fit plot from PROC PLM:

It shows how the predicted values change over Length2 at a fixed value of other covariates/effects in the model.

 

Two output plots look different because the predicted values being plotted are computed differently.

 

Do you just wanted to plot an interaction term? Then if the two variables involved in the interaction are class variables, you might use INTERACTION in the EFFECTPLOT statement in PROC PLM; if both are continuous variables, then you might use CONTOUR in the EFFECTPLOT statement in PROC PLM; if one is a CLASS variable one is a continuous variable, then you might use SLICEFIT in the EFFECTPLOT statement. Please see the documentation below for more details:

https://go.documentation.sas.com/doc/en/pgmsascdc/v_037/statug/statug_plm_syntax03.htm

 

Hope this helps,

Jill

 

 

madisonsmith
Calcite | Level 5

Thank you @jiltao, this is incredibly helpful! So the PROC PLM statement does not account for other effects in the model when plotting?

 

For my SGPLOT statement, I created FOBS groups in my data based on the 1 SD spread of how I was going to probe the interaction (represented in PROC PLM as the continuous values). It's the same variable as what was in my model, just categorized for the purposes of visually probing the interaction.

 

I think my main issue now is that my coauthor now wants me to test the significance of each individual slope that I probe based on the 1 SD spread of the moderator. But the only documentation that I find on how to do that uses PROC PLM, which isn't necessarily accurate because it doesn't account for all other effects in the model (which the significant result for the overall interaction term clearly does). 

 

I'm not sure if this makes sense, but would really appreciate any insight you have to give.

jiltao
SAS Super FREQ

It is not correct to say that PROC PLM does not account for other effects in the model. 

PROC PLM is for post-fitting analysis. The parameter estimates are from the model you specify. So the predicted values are computed based on the parameter estimates that account for all effects in the model. The plot "fixes" the values for other covariates, as shown in the plot (it tells you which values the other covariates are set), versus your PROC SGPLOT code in which the values of other covariates are whatever in your data set, they are not fixed.

I would probably use PROC PLM to depict the interaction effects in your model.

 

Thanks,

Jill

madisonsmith
Calcite | Level 5

I see, thank you very much again @jiltao.

 

So it seems like PROC PLM fixes observed values for model predictors across all individuals, whereas PROC SGPLOT takes each person's predicted value of the outcome at whatever observed value each person has for each predictor in the model. Is that a correct understanding?

 

If I wanted to do a sensitivity analysis of the significance of the simple slopes, do you know of a way to do this in PROC SGPLOT?

jiltao
SAS Super FREQ

Yes, that is correct.

I am not sure what sensitivity analysis you plan to perform. But to depict an interaction effect from a model, I would probably get predicted vales of y at fixed vales of other covariates then use PROC SGPLOT to plot the interaction / slopes.

Thanks,

Jill 

 

madisonsmith
Calcite | Level 5
How do I get predicted values of Y at fixed values of covariates in the model?
jiltao
SAS Super FREQ

This usage note provides various ways of scoring a new data set --

http://support.sas.com/kb/33307

 

Here is an example of Approach 3. Augmenting the training data set for your case:

1. create a scoring data set, for example, NEW, that contains the fixed values for other covariates and the plotting values for the ones you are interested in plotting. Make sure the dependent variable has missing values in this data set;

2. combine the original data set with this scoring data set (NEW) with a SET statement in a SAS data step.

3. Use PROC MIXED to fit your model on this combined data set. Make sure you use the OUTP= option in the MODEL statement.

The observations from step 2 have missing values for the dependent variable, therefore will not be used in the model fitting. However, they will get predicted values. You will then use PROC SGPLOT to plot these observations.

 

Alternatively, you might use the data set NEW as the scoring data in PROC PLM to get the predicted values, then use PROC SGPLOT to plot it. This is basically approach 1 in the usage note linked above.

Hope this helps,

Jill

 

madisonsmith
Calcite | Level 5

Hello,

 

Thank you so much for this reply. I tried the first method you suggested and it seems to be working well, but I get no predicted values for the new lines in my dataset which are meant to be the primary test of what I'm looking for. What might I be doing wrong?

data new;
input Age_T1 GID_male dem06_L2 visit partner Length2 
TransitionSingle TransitionRelat Time 
mspss_total_personmean fobss_total_personmean pss_sum;
        cards;
                19.4 1 0 3.942 0 .8282 0 0 41.21 5.154 1.41 -99
		19.4 1 0 3.942 0 .8282 0 0 41.21 5.154 2.65 -99
		19.4 1 0 3.942 0 .8282 0 0 41.21 5.154 3.89 -99
		19.4 1 0 3.942 0 .8282 0 1 41.21 5.154 1.41 -99
		19.4 1 0 3.942 0 .8282 0 1 41.21 5.154 2.65 -99
		19.4 1 0 3.942 0 .8282 0 1 41.21 5.154 3.89 -99
        ;

		data both;
        set import new (in=InNew);
        w=not(InNew);
        run;

proc print noobs; 
var Age_T1 GID_male dem06_L2 visit partner Length2 
TransitionSingle TransitionRelat Time 
mspss_total_personmean fobss_total_personmean pss_sum;
run;

*Model 3 - all single variables and L2 variables + FOBS interactions*;

PROC MIXED data=both covtest noclprint method = ML; 
*weight w;
class fab400_id partner(ref="Yes") TransitionSingle(ref="Continuance of Singlehood OR In a Relationship") 
TransitionRelat(ref="Continuance of Relationship OR Being Single") GID_Male(ref="Cisgender") dem06_L2(ref="Cisgender"); 
model pss_sum = Age_T1 GID_male dem06_L2 visit partner Length2 TransitionSingle TransitionRelat Time mspss_total_personmean fobss_total_personmean 
partner*fobss_total_personmean Length2*fobss_total_personmean TransitionSingle*fobss_total_personmean TransitionRelat*fobss_total_personmean
Time*fobss_total_personmean / solution outp=pred(where=(w=0)); 
random intercept visit / sub=fab400_id type=vc;
*Repeated visit / Subject=fab400_id;
*store pred1;
run;

madisonsmith_0-1681073716528.png

 

Thank you again.

madisonsmith
Calcite | Level 5

Disregard my previous message; I figured it out! But now I am wondering if there is a way of testing the significance of the plotted slopes against 0? I know there is a way in PROC PLM but I want specifically to test the slopes that are plotted.

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
  • 9 replies
  • 1377 views
  • 2 likes
  • 2 in conversation