LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Aug 2002 09:57:32 -0700
Reply-To:     Dale McLerran <stringplayer_2@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <stringplayer_2@YAHOO.COM>
Subject:      Re: Three-level hierarchical model
Comments: To: DDB <dirk.debacquer@RUG.AC.BE>
In-Reply-To:  <aire98$21a$1@gaudi2.rug.ac.be>
Content-Type: text/plain; charset=us-ascii

Dirk,

The DF for testing pupil effects will be essentially just a few less than the number of observations in the dataset, that is, for all practical purposes infinite. It is the class level effects that you need to be careful with. The class level effects should have DF which are the number of classes minus the number of schools in which the classes are nested minus the number of fixed effects measured at the class level. If you were to specify ddfm=satterth or ddfm=kenwardroger as an option to your model statement, you should get denominator DF which are close to the appropriate DF. But you might want to specify the DF for each effect measured at the class level.

The following code illustrates illustrates how DF can be specified for data such as you have. First, I generate data with students nested within classrooms nested within schools. I generate a variable clsize (class size) which is obviously measured at the class level. Clsize has fixed effect clsize_eff. I also generate a variable age which is measured at the student level and has fixed effect age_eff. Schools and classrooms within schools have random effects. The student random effect is the pure error term. It should be apparent that we can also consider just the two-level hierarchical model which is the classroom mean effect with classes nested within schools. When we consider the classroom mean model, we are examining a model which should inform us as to the degrees of freedom for variables measured at the class level in the three level hierarchical model. The code below demonstrates an analysis of the true two level hierarchical model as well as a two level hierarchical model obtained by computing the classroom mean value (averaging over student effects).

/* Generate data for two- and three-level hierarchical models */ /* Dataset class contains the two-level model and student */ /* has the full three-level hierarchical model data. */ data class student; intercept = 2; clsize_eff = 1.5; age_eff = 4; do school=1 to 5; ranschool = .3*rannor(1234579); do class=1 to 4; ranclass = .9*rannor(1234579); clsize = 25 + 3*rannor(1234579); y = intercept + clsize*clsize_eff + ranclass; output class; do student=1 to 20; age = 12 + rannor(1234579); err = 2*rannor(1234579); y = intercept + ranschool + ranclass + clsize*clsize_eff + age*age_eff + err; output student; end; end; end; run;

/* Fit the two-level hierarchical model. DF for clsize are */ /* appropriately computed. */ proc mixed data=class; class school; model y = clsize / s; random school; run;

/* Average over student effects to obtain classroom means. */ /* The classroom means will be used to fit a two-level model. */ proc means data=student noprint nway; id clsize; class school class; var y; output out=means mean=meany; run;

/* Fit two-level model to classroom means. This model should */ /* have properties quite similar to the two-level model fit */ /* previously, the difference being that the one above was */ /* fit to data generated only at the classroom level while */ /* here we are taking three-level data and reducing it to */ /* two-level data by averaging over student effects. This is */ /* what one might do with real data such as you have. */ proc mixed data=means; class school; model meany = clsize / s; random school; run;

/* Fit three-level hierarchical model specifying the df for */ /* effects measured at the classroom level. */ proc mixed data=student; class school class student; model y = clsize age / s ddf=14,.; random school; random class(school); run;

/* Fit the three-level model specifying DF computed using the */ /* satterthwaite option. */ proc mixed data=student; class school class student; model y = clsize age / s ddfm=satterth; random school; random class(school); run;

/* Fit the three-level model specifying DF computed using the */ /* kenwardroger option. */ proc mixed data=student; class school class student; model y = clsize age / s ddfm=kenwardroger; random school; random class(school); run;

HTH,

Dale

--- DDB <dirk.debacquer@RUG.AC.BE> wrote: > Dear SAS user, > > I am trying to fit a multilevel model (three levels: pupils, classes, > schools) on a huge dataset with covariates on the first two levels > (pupils, > classes). > I have difficulties in interpreting the degrees of freedom of the > fixed > effects in the model using PROC MIXED. I am not sure whether my SAS > code is > correct. > Does anyone know of an example to base my SAS codes upon? Or does > anyone can > share his SAS code with me?. > It would be highly appreciated. > > Thanks, > > Dirk

===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

__________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com


Back to: Top of message | Previous page | Main SAS-L page