Turn on suggestions

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

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Calculate the slope for each subject using the mixed effect model and ...

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 10-29-2019 03:38 PM
(2510 views)

I want to get the slope (annually change) for each subject. To my knowledge, the mixed effect model could get the slope for each subject and I posted the code as following:

```
%macro individual_coeff(dataset,indice);
proc mixed data=&dataset plot(maxpoints=7000);
class ID;
model col1=timepoint/solution;
random int timepoint/subject=ID type=un solution;
ods output solutionf=sf(keep=effect estimate rename=(estimate=overall));
ods output solutionr=sr(keep=effect ID estimate rename=(estimate=ssdev));
run;
proc sort data=sf;
by effect;
run;
proc sort data=sr;
by effect;
run;
data final_&indice;
merge sf sr;
by effect;
sscoeff_&indice= overall + ssdev;
run;
%mend;
%individual_coeff(atl_two_bmi_3,bmi);
```

Also, we could get it by calculating the slope for each subject by the regression model.

```
proc reg data=a;
model col1=timepoint;
by ID;
run;
```

However, those two methods output different results. I want to know why. And which method is much more reasonable if some subjects only had two or three repeated measurements?

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It looks like you have copied the example code from the SAS Usage Note 37109: Obtaining subject-specific parameter estimates.

The MIXED model is generally regarded as the better way to analyze longitudinal data. It is especially useful when the measurements are not taken at the same time points or some subjects have missing values (fewer observations).

The differences are because the models are different. The MIXED model is often described as 'borrowing strength' from the population-average effects. There is ONE analysis that takes into account all k subjects. It estimates and accounts for the correlation between observations for the same subject.

When you use the BY statement in PROC REG, you are merely performing k individual regression analyses for the k subjects. Each REG analysis looks only at the data for one subject. When the data are correlated in time (as for longitudinal data), the data do not satisfy the independence assumption of the OLS regression model.

1 REPLY 1

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It looks like you have copied the example code from the SAS Usage Note 37109: Obtaining subject-specific parameter estimates.

The MIXED model is generally regarded as the better way to analyze longitudinal data. It is especially useful when the measurements are not taken at the same time points or some subjects have missing values (fewer observations).

The differences are because the models are different. The MIXED model is often described as 'borrowing strength' from the population-average effects. There is ONE analysis that takes into account all k subjects. It estimates and accounts for the correlation between observations for the same subject.

When you use the BY statement in PROC REG, you are merely performing k individual regression analyses for the k subjects. Each REG analysis looks only at the data for one subject. When the data are correlated in time (as for longitudinal data), the data do not satisfy the independence assumption of the OLS regression model.

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

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.