Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lgutm18
Fluorite | Level 6

Hello,

 

I need some help obtaining the random slope estimates per individual, so that I can use those parameters per individual as an outcome in another part of the analysis.

 

Below is the code that I am currently using:

 

ods output solutionf=slopes;
proc mixed data=trial;
class idno time;
model GLOBALCOG = time WMFA WMH ICV brainvol AGE RACE GENDER/s chisq OUTPM=WORK.PM RESIDUAL;
random intercept time;
repeated time/type=un subject=idno r rcorr;
run;

 

The part "solutionf=slopes" provide one parameter of the random slope but not per individual. 

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

If this random slope is one slope for one subject. Try this:

data trial;
call streaminit(123);
do idno=1 to 10;
 do time=1 to 4;
  globalcog=rand('normal');
  brain=rand('normal');
  output;
 end;
end;
run;

ods  output SolutionR= SolutionR;
proc mixed data=trial;
class idno time ;
model GLOBALCOG = time brain/s chisq  RESIDUAL;
/*random intercept /subject=idno solution ;*/
random  brain/subject=idno solution ;

/*repeated time/type=un subject=idno r rcorr;*/
run;

Ksharp_0-1744940008111.png

 

View solution in original post

7 REPLIES 7
lgutm18
Fluorite | Level 6

Yes! Thanks for sharing. However, what it's still not clear is how to extract the random slope parameters per individual as a column that you could add to the dataset to use for analysis. I'd greatly appreciate suggestions!

Ksharp
Super User

I think your code should look like this:

data trial;
call streaminit(123);
do idno=1 to 10;
 do time=1 to 4;
  globalcog=rand('normal');
  brain=rand('normal');
  output;
 end;
end;
run;

ods  output SolutionR= SolutionR;
proc mixed data=trial;
class idno time;
model GLOBALCOG = time brain/s chisq  RESIDUAL;
random intercept /subject=idno solution ;
repeated time/type=un subject=idno r rcorr;
run;

Ksharp_0-1744938570030.png

 

Ksharp
Super User

If this random slope is one slope for one subject. Try this:

data trial;
call streaminit(123);
do idno=1 to 10;
 do time=1 to 4;
  globalcog=rand('normal');
  brain=rand('normal');
  output;
 end;
end;
run;

ods  output SolutionR= SolutionR;
proc mixed data=trial;
class idno time ;
model GLOBALCOG = time brain/s chisq  RESIDUAL;
/*random intercept /subject=idno solution ;*/
random  brain/subject=idno solution ;

/*repeated time/type=un subject=idno r rcorr;*/
run;

Ksharp_0-1744940008111.png

 

lgutm18
Fluorite | Level 6
This works great! Thank you very much!
jiltao
SAS Super FREQ

First, your PROC MIXED code does not seem to be appropriate. It looks to me that you wanted to fit a random coefficients model? If so, TIME should not be a CLASS variable, and you should have the SUBJECT= option in the RANDOM statement. Then with this modified RANDOM statement, your REPEATED statement with TYPE=UN structure is likely over-fitting your data and might need to be removed.

 

proc mixed data=trial;
class idno ;
model GLOBALCOG = time WMFA WMH ICV brainvol AGE RACE GENDER/s chisq OUTPM=WORK.PM RESIDUAL;
random intercept time / subject=idno;
run;

 

Then you might use approaches illustrated in the following usage note to obtain subject-specific intercept and slope estimates.

 

37109 - Obtaining subject-specific parameter estimates and tests for a random coefficients model or ...

 

Hope this helps,

Jill

lgutm18
Fluorite | Level 6
I appreciate your comment and the resource. I have fixed my code.
Thanks!!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 7 replies
  • 687 views
  • 3 likes
  • 4 in conversation