Programming the statistical procedures from SAS

Mixed Model, Nested ANCOVA with Random Coefficients

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Mixed Model, Nested ANCOVA with Random Coefficients

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.


Accepted Solutions
Solution
‎12-12-2012 07:57 AM
Respected Advisor
Posts: 2,655

Re: Mixed Model, Nested ANCOVA with Random Coefficients

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


All Replies
Respected Advisor
Posts: 2,655

Re: Mixed Model, Nested ANCOVA with Random Coefficients

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

Occasional Contributor
Posts: 12

Re: Mixed Model, Nested ANCOVA with Random Coefficients

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.

Solution
‎12-12-2012 07:57 AM
Respected Advisor
Posts: 2,655

Re: Mixed Model, Nested ANCOVA with Random Coefficients

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

Occasional Contributor
Posts: 12

Re: Mixed Model, Nested ANCOVA with Random Coefficients

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1287 views
  • 3 likes
  • 2 in conversation