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

Suppose I have two factors, call them Factor1 and Factor2.  Factor1 is fixed with two levels, call them A and B.  Factor2 is random with three levels and is nested within Factor1.  For each level of factor2(factor1) my data set has about 100 observations, including a covariate and the continuous response variable.  Conceptually, a simple linear model exist for each level of factor2(factor1).  The levels of factor2(factor1) appear to have unequal slope and unequal intercept parameters.  First, I need to determine whether or not the average of the slope parameters for level A is significantly different from the average of the slope parameters for level B.  If there is no significant difference between the average slope parameters, then I would also like to test for significant differences between intercepts of the two levels.  Does anyone have any ideas on how to set up this problem, preferably with PROC MIXED?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

This looks right  To speed processing, etc., you may want to change the random statement to take advantage of subject specification:

random intercept covariate/subject=factor2(factor1) solution;

Steve Denham

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

I may be misunderstanding your design because I think your random factor2 has the same levels across all levels of factor1, so is not truly nested, but you could try (syntax is for SAS/STAT12.1):

proc mixed data=yourdata;

class factor1 factor2 id;

model response = factor1 covariate factor1*covariate/solution ddfm=kr2;

random factor2/subject=id;

run;

The Type 3 F tests are essentially for slopes and intercepts:  factor1*covariate tests whether the slopes differ for the levels of factor1, while factor1 tests whether the intercepts differ.  If you have access to SAS for Mixed Models, 2nd.ed. by Littell et al., check the sections on analysis of covariance.

Steve Denham

JeremyPoling
Calcite | Level 5

Thanks so much for your helpful response.  You said that the syntax is for SAS/STAT 12.1.  Unfortunately, I'm still stuck in SAS 9.1. 

The levels of factor2 are not the same for every level of factor1, so the design is nested.

I thought about the problem some more today and came up with the following PROC MIXED step that I think does the trick.  Using this model, there is both a fixed and a random component to the slopes and intercepts.  However, I've never seen a model quite like this and I'm operating a bit outside of my comfort zone.  Does what I'm doing make sense?

proc mixed data=mydata;

     class factor1 factor2;

     model response=factor1 covariate*factor1/noint solution;

     random factor2(factor1) covariate*factor2(factor1)/solution;

     estimate "Intercepts: Level A - Level B" factor1 1 -1;

     estimate "Slopes: Level A - Level B" covariate*factor1 1 -1;

quit;

Thanks again.

SteveDenham
Jade | Level 19

This looks right  To speed processing, etc., you may want to change the random statement to take advantage of subject specification:

random intercept covariate/subject=factor2(factor1) solution;

Steve Denham

JeremyPoling
Calcite | Level 5

Thanks so much.  This has been a big help.  Your RANDOM statement did speed processing considerably.  I also added the TYPE=FA0(2) option to the RANDOM statement because I came across an example that recommended this covariance structure (or TYPE=UN) for random coefficient models.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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