DOC PREVIEW
UW-Madison STAT 572 - Random Effects in R

This preview shows page 1 out of 4 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The Big Picture Random Effects and Balance The Big Picture The completely randomized design with a random effect assumes the following model yij ai eij Random Effects in R where ai iidN 0 a2 and eij iidN 0 e2 with ai independent of eij If the data is perfectly balanced with equal numbers of individuals in each group ni n for all i it is possible to make modifications to a fixed effects ANOVA analysis by computing a different expected mean square EMS for inference When the data is not balanced this approach fails sometimes approximations work sometimes not An alternative regression approach is appropriate even when the design is imbalanced but the scope of inference is then different I will first show the regression approach described in Chapter 10 of your book Bret Larget Departments of Botany and of Statistics University of Wisconsin Madison March 15 2007 Statistics 572 Spring 2007 Random Effects in R The Big Picture j 1 ni i 1 k March 17 2007 1 13 Statistics 572 Spring 2007 Random Effects and Balance Random Effects in R The Big Picture Correlation March 17 2007 2 13 Random Effects and Balance Variance One consequence of the random effects model is that observations can be correlated Recall from Statistics 571 the following facts about variances of independent random variables X and Y and constant c In the model we study here observations in different groups are independent just as in the fixed effect model because they do not share any random variables 1 2 For example the first observations from groups one y11 depends a1 and e11 while y21 depends on a2 and e21 In contrast observations in the same group are correlated V X Y V X Y V X V Y if independent V cX c 2 V X With this reminder we can recognize that a measures the size of a typical difference between a random effect and the grand mean A effects is ptypical difference p between two regression V ai aj V ai V aj 2 a y11 and y12 each depend on a1 Statistics 572 Spring 2007 Random Effects in R March 17 2007 3 13 Statistics 572 Spring 2007 Random Effects in R March 17 2007 4 13 Computation lmer Computation Linear Mixed Effects Models using lmer Data Description The most recently developed R package for fitting linear models with random effects is in the library lme4 The function to use instead of lm is named lmer Mac users will need a recent operating system OS X 10 4 4 or later and R 2 4 1 or later to use this library Users of older Macs can use the older package nlme and the function lme lme cannot fit as rich a class of random effects models as lmer for example random effects cannot be nested and you cannot use generalized linear models but it will suffice for much of what we do in the course A model formula with a random effect in lmer differs from lm by including a term of the form a b where a is a model matrix often the intercept 1 for the scope of the random effect and b is the group to which the random effect applies Statistics 572 Spring 2007 Random Effects in R Computation lmer March 17 2007 We will consider the data set ant111b from the textbook This data set is a subset of a much larger data set on corn yields on different islands in the Carribean In the subset of data two possibly interesting response variables are harvest weight harvwt and the number of ears ears Both harvwt and ears are measured by plot but the units are unspecified There are four plots within each site The variable plot is only meaningful nested within a site We will consider the site as a random effect as there are many possible sites on each island In the subset of the data we have there is only a single treatment and all sites are on the same island 5 13 Statistics 572 Spring 2007 lmer Random Effects in R Computation Data March 17 2007 6 13 lmer Plot of Data library DAAG str ant111b 7 data frame 32 obs of 9 variables site Factor w 8 levels DBAN LFAN 1 2 3 4 5 6 7 8 1 2 parcel Factor w 4 levels I II III 1 1 1 1 1 1 1 1 2 2 code num 58 58 58 58 58 58 58 58 58 58 Notice that there is considerable island num 1 1 1 1 1 1 1 1 1 1 variation among sites id num 3 40 186 256 220 Variation within sites from plot plot num 3 4 5 5 4 5 3 5 5 7 7 15 5 15 to plot appears smaller trt num 111 111 111 111 111 111 111 111 111 111 ears num 43 5 40 5 20 42 5 31 5 32 5 43 5 50 46 46 5 harvwt num 5 16 2 93 1 73 6 79 3 25 Statistics 572 Spring 2007 Random Effects in R March 17 2007 7 13 attach ant111b library lattice fig1 xyplot harvwt site pch 16 col blue print fig1 Statistics 572 Spring 2007 6 5 harvwt 4 3 2 DBAN Random Effects in R LFAN NSAN ORAN OVAN TEAN WEAN WLAN site March 17 2007 8 13 Computation lmer Computation Fitting a Random Effects Model lmer Residual Plot Fixed effects Estimate Std Error t value Intercept 4 2917 0 5604 7 659 Random Effects in R Computation March 17 2007 9 13 1 0 0 5 0 0 3 4 5 6 fitted corn1 lmer Statistics 572 Spring 2007 lmer Random Effects in R Computation Fitted Values 0 5 There are no bad patterns in the residual plot The estimated variance components are a2 2 36773 and e2 0 57754 sig2site as vector VarCorr corn1 lmer site sigma attributes summary corn1 lmer sigma Statistics 572 Spring 2007 plot fitted corn1 lmer residuals corn1 lmer abline h 0 residuals corn1 lmer There are two sources of random variation one for site and one for parcel within site 1 0 Linear mixed effects model fit by REML Formula harvwt 1 1 site AIC BIC logLik MLdeviance REMLdeviance 98 42 101 3 47 21 95 08 94 42 Random effects Groups Name Variance Std Dev site Intercept 2 36773 1 53874 Residual 0 57754 0 75996 number of obs 32 groups site 8 1 5 The term 1 site means that there is a random effect for each site and this effect is nested within the intercept the whole model 1 5 The first 1 is the fixed effect library lme4 corn1 lmer lmer harvwt 1 1 site summary corn1 lmer March 17 2007 10 13 lmer Estimation We can use the two different variance components to estimate the error in different kinds of predictions means sapply split harvwt site mean siteFit sapply split fitted corn1 lmer site mean data frame mean means fitted siteFit DBAN LFAN NSAN ORAN OVAN TEAN WEAN WLAN mean 4 88500 4 20750 2 …


View Full Document

UW-Madison STAT 572 - Random Effects in R

Download Random Effects in R
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Random Effects in R and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Random Effects in R and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?