BookmarkSubscribeRSS Feed
wab13
Fluorite | Level 6

I'm running a random intercept model with a continuous outcome and continuous-continuous interaction term. It is panel data with 3 time points:

 

PROC MIXED covtest noclprint data = wab.data1 method=ml ;
class ID cov2(ref='1') time(ref="0") cov1;
model GSI = time es TIS es*TIS soc
cov1 cov2 cov3 cov4 cov5 /s ddfm = SATTERTHWAITE CL OUTPREDM=Pred;
random intercept /sub=ID type=un g;
store Model;
run;

 

 

And plotting the significant interaction with PROC GLM at M-1SD and M+1SD values of one of the variables in the interaction term:

 

PROC PLM source=Model ;
effectplot slicefit(x=ES sliceby=TIS=4.24 6.22);
run;

 

plot I want, but not looking goodplot I want, but not looking good

Is there a way to customize the looks of the plot (change axis labels, colors, etc.)?

I've seen other posts recommending using the OUTPREDM option and use PROC SGPLOT instead of PROC GLM, but the outcome is not what I want. 

proc sgplot data=Pred;             
   series x=ES y=Pred / group=TIS;  
run;

So is there an easy way to create a stored data with PROC MIXED coefficients for PROC SGPLOT?

not what I want, but at least I can customize the looksnot what I want, but at least I can customize the looks

7 REPLIES 7
sbxkoenk
SAS Super FREQ

Hello @wab13 ,

Welcome to the communities!

I understand why you have posted your question to the Visual Analytics board, but Visual Analytics is a browser-based Business Intelligence product from SAS that you probably don't have (as you are mistakenly using this channel for a SGPLOT question).

Anyway, Visual Analytics (commonly abbreviated as VA) is not suitable for answering your question.

Your SGPLOT-question belongs to the 'Graphics Programming' board under the Programming drop-down list.

Unfortunately I don't have the super-powers to move it (from one board to the other), but it will probably be done by someone else (like a community manager).

I have no time today to write you an example program but if the question is not answered by tomorrow (which would surprise me), I will post an answer tomorrow (or on Monday).

Cheers,

Koen

Rick_SAS
SAS Super FREQ

You say "the outcome is not what I want," but what do you want?

 

Some ways to visualize mixed models are presented in the article "Visualize a mixed model that has repeated measures or random coefficients."  Maybe that will get you started.

wab13
Fluorite | Level 6

Yes, this blog post was extremely helpful to get me where I'm at now (that's where I got the code I pasted above).

Given the multiple lines, it seems to me that the second figure displays the relationship between x (es) and y (gsi) across the different clusters (individuals) -- random effects. 

But I'm not interested in displaying random effects, just average effects of X on Y by levels of moderator. I'm looking for something very similar to the first figure I posted (i.e. predictions of y [GSI] by x [ES] grouped by arbitrary levels of the moderator [TIS] -- like mean-1SD and mean+1SD), but would like to edit axis labels, legends, line colors. I read in other posts to the community that it is a bit harder to do that in PROC PLM than in PROC SGPLOT, but I haven't been able to send output of my models to PROC SGPLOT.

 

I've been struggling to get at that with the code and examples in the blog post you pasted. I even thought about creating line graphs in Excel based on coefficients in the output, but was unsure if in mixed-effects models the coefficient of X would be (b+d) as in OLS regression (Y = a + bX + cM + dX*M) given the random intercept in my model

Plus I am really interested in learning to do this in SAS given that I have to do similar graphs often in my research.

sbxkoenk
SAS Super FREQ

Again, I cannot help you today (no time), but I will check the status of this track early next week and will post something if (still needed).

If you want to learn about visuals with SAS (SG-procedures) then certainly follow this blog:

https://blogs.sas.com/content/graphicallyspeaking/

Also, search all blogs for the string 'visual'. It will also bring up many entries on Visual Analytics.

https://blogs.sas.com/content/?s=visual

Cheers,

Koen

 

Rick_SAS
SAS Super FREQ

In the article, near the end, it says

It is worth noting that the MODEL statement in PROC MIXED also supports an OUTPREDM= option. (The 'M' stands for 'marginal' model.) The OUTPREDM= option writes a data set that contains the predictions that do not "incorporate the EBLUP values", where EBLUP is an abbreviation for the "empirical best linear unbiased prediction." These are the same predicted values that you obtain from the STORE statement and PROC PLM. However, the OUTPREDM= data set gives you complete control over how you use the predicted values. For example, you can use the OUTPREDM= data set to add the original observations to the graph of the predicted values for boys and girls.

 

So in your PROC MIXED code, use the OUTPREDM= option instead of the OUTPRED= option.

wab13
Fluorite | Level 6

Ugh! Sorry for being dense, but I tried this above and got the graph with multiple lines that I pasted above.

Doing it again now, the only difference were that the lines had different colors, which I think are to show all possible levels of TIS.

 Capture3.PNG

proc mixed covtest noclprint data = wab.data1 method=ml ;
class ID cov2(ref='1') cov1(ref="0") cov3;
model GSI = es TIS es*TIS time cov1 cov2 cov3 cov4 cov5 
	  /s ddfm = SATTERTHWAITE CL outpredm=MargPreds;
random intercept /sub=ID type=un g;
run;

proc sgplot data=MargPreds;             
   series x=ES y=Pred / group=TIS; 
run;

 

Rick_SAS
SAS Super FREQ

Think about what you are doing. You have multiple covariates in your model. If you evaluate the model on the original observations, you are seeing the predicted values for the fixed effects, evaluated at each observation. That is why you see all these jagged line: They correspond to the predicted values at a diverse set of explanatory variables.  This is explained in the article "Visualize multivariate regression models by slicing continuous variables," especially the second example in that article.

 

That is why the EFFECTPLOT SLICEFIT statement is so powerful. It provides a syntax to set the value of the covariates (to means or to specific values) while varying just one of the continuous covariates. This results in a "slice" through the regression surface.

 

You can manually create a sliced plot by scoring the model, but I encourage you to use the EFFECTPLOT statement, if possible, since it is easier. For more examples of using the EFFECTPLOT statement, see "Use the EFFECTPLOT statement to visualize regression models in SAS."

 

If you can't figure it out from those examples, you will have to plot some sample data and PROC MIXED code that its the data.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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