Quartz | Level 8

## Calculate the slope for each subject using the mixed effect model and regression model

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
SAS Super FREQ

## Re: Calculate the slope for each subject using the mixed effect model and regression model

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.

SAS Super FREQ

## Re: Calculate the slope for each subject using the mixed effect model and regression model

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.

Discussion stats