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

I'm running a random effects linear regression model to determine the relationship between two continuous variables (X and Y) within subjects. I'm currently using proc glm in SAS 9.4 to accomplish this. Where in my output can I find my global regression equation variables?

 

Example code:

proc glm data = Example;
class ID; model Y = X ID X*ID / solution;
random ID;
run;

 

In the results for the solution option, all I can find are the intercept and correlation coefficient for the reference subject, not the whole group.

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Oh, yes, switch to MIXED or even (my favorite) GLIMMIX!

 

This example in the MIXED procedure may produce what you are looking for, if what you want is a random coefficients model

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect0...

 

Using that example as a template, and throwing in a plot, your code would look like

proc sgplot data=example;
reg x=X y=Y / group=ID;
run;

proc mixed data=example; class ID; model Y = X / solution; random Intercept X / type=un sub=ID solution; run;

"type=un" specifies random intercepts, random slopes, and covariance between intercepts and slopes. You may find that a simpler structure (e.g., setting covariance to zero, or only random intercepts) might provide a better fit to your data.

 

The estimates of regression parameters (intercept and slope) for the population of IDs is produced by the SOLUTION option on the MODEL statement.

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

First comment, if you want to model random effects, you should probably use PROC MIXED. Your syntax won't change for this example.

 

The ParameterEstimates table shows the estimates for the model. It does not have a spanning header in PROC GLM, but the column headers are

Parameter Estimate   Standard
Error
t Value Pr > |t|

 

For PROC MIXED, run this code and look for the table that says "Solution for Fixed Effects":

 

data class;
call streaminit(1);
set sashelp.class;
clinic = rand("Table", 0.3, 0.3, 0.4);
run;

proc mixed data = class;
class clinic; 
model weight = height | clinic / solution;
random clinic;
run;
kaune
Calcite | Level 5

Thanks for the reply. Your suggestion highlights the issue I have with my original analysis. Using your example code, I get an intercept of -135.67 and a fixed effect estimate for height of 3.77 (suggesting a regression equation of weight = 3.77*height - 135.67). However, when I reorder and re-run the same analysis using the following:

data class;
call streaminit(1);
set sashelp.class;
clinic = rand("Table", 0.3, 0.3, 0.4);
run;

data class2; set class; if clinic = 1 then clinic2 = 'one'; else if clinic = 2 then clinic2 = 'two'; else if clinic = 3 then clinic2 = 'three'; proc mixed data = class2; class clinic2; model weight = height | clinic2 / solution; random clinic2; run;

I get an intercept of -144.54 and a slope estimate of 3.91 (weight = 3.91*height - 144.54). The fixed effect estimates in the solution option (in PROC MIXED or PROC GLM) provides estimates for the reference subject only (which is the last one calculated), so simply re-ordering the data can vastly change the result. In this example, how do I determine the global effect of weight on height?

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

Oh, yes, switch to MIXED or even (my favorite) GLIMMIX!

 

This example in the MIXED procedure may produce what you are looking for, if what you want is a random coefficients model

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect0...

 

Using that example as a template, and throwing in a plot, your code would look like

proc sgplot data=example;
reg x=X y=Y / group=ID;
run;

proc mixed data=example; class ID; model Y = X / solution; random Intercept X / type=un sub=ID solution; run;

"type=un" specifies random intercepts, random slopes, and covariance between intercepts and slopes. You may find that a simpler structure (e.g., setting covariance to zero, or only random intercepts) might provide a better fit to your data.

 

The estimates of regression parameters (intercept and slope) for the population of IDs is produced by the SOLUTION option on the MODEL statement.

PaigeMiller
Diamond | Level 26

@kaune wrote:

I get an intercept of -144.54 and a slope estimate of 3.91 (weight = 3.91*height - 144.54). The fixed effect estimates in the solution option (in PROC MIXED or PROC GLM) provides estimates for the reference subject only (which is the last one calculated), so simply re-ordering the data can vastly change the result. In this example, how do I determine the global effect of weight on height?


The slope for height on weight for the various different clinics is indeed constant. The coefficients do change depending on which level is considered the reference. However, the sum of the global slope and effect due to the specific clinic is unique and doesn't change if you change the reference subject.

 

So to use Rick's example from SASUSER.CLASS data set:

 

                                       Standard
Effect           clinic    Estimate       Error      DF    t Value    Pr > |t|

Intercept                   -135.67     42.9456       0      -3.16       .
Height                       3.7701      0.6818      13       5.53      <.0001
clinic           1           873.56      638.75       0       1.37       .
clinic           2          -8.8650     77.9700       0      -0.11       .
clinic           3                0           .       .        .         .
Height*clinic    1         -13.1818      9.7306      13      -1.35      0.1986
Height*clinic    2           0.1359      1.2906      13       0.11      0.9177
Height*clinic    3                0           .       .        .         .

the slope of height for clinic1 is 3.7701 - 13.1818 = -9.4117, and this is unique and unchanging, even when you change the reference level.

 

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 4109 views
  • 1 like
  • 4 in conversation