turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Slope and intercept in repeated measures linear re...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2017 08:53 AM

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.

Accepted Solutions

Solution

03-28-2017
02:35 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2017 02:14 PM

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

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2017 09:49 AM

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;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2017 11:24 AM - edited 03-28-2017 11:45 AM

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?

Solution

03-28-2017
02:35 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2017 02:14 PM

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

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2017 02:24 PM - edited 03-28-2017 02:27 PM

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.