UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

R Code Fragment
Split-plot Factorial spf2-22

This code fragment covers a split-plot factorial design with one between subject factor and two within subject factors use the lmer command. There is a Stata dataset located at http://www.ats.ucla.edu/stat/stata/examples/kirk/spf2-22. In this dataset y is the response variable, a is the between subject factor, b and c are within subject factors, and s is the subject identifier.
library(foreign)

spf <- read.dta(file="~/data/spf2-22.dta")

library(lme4)

m1<-lmer(y~factor(a)*factor(b)*factor(c)+ (1 | s), spf)

anova(m1)

Analysis of Variance Table
                              Df  Sum Sq Mean Sq  F value
factor(a)                      1   1.014   1.014   1.9997
factor(b)                      1 162.000 162.000 319.5616
factor(c)                      1  24.500  24.500  48.3288
factor(a):factor(b)            1   6.125   6.125  12.0822
factor(a):factor(c)            1  10.125  10.125  19.9726
factor(b):factor(c)            1   8.000   8.000  15.7808
factor(a):factor(b):factor(c)  1   3.125   3.125   6.1644


How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California