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

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

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.

 

 

 

 

 

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

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-innovate-2024.png

Available on demand!

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

 

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
  • 1 reply
  • 2391 views
  • 4 likes
  • 2 in conversation