SlideShare a Scribd company logo
1 of 38
Download to read offline
Lab 10 – Repeated Measures
October 22 & 23, 2018
FANR 6750
Richard Chandler and Bob Cooper
Overview
Design
• We randomly assign each “subject” to a treatment
• We record the response to the treatment over time
Intro Univariate Split-plot Approach Multivariate 2 / 18
Overview
Design
• We randomly assign each “subject” to a treatment
• We record the response to the treatment over time
Sources of variation
• Treatment
• Time
• Treatment-time interaction
• Random variation among subjects
• Random variation within subjects
Intro Univariate Split-plot Approach Multivariate 2 / 18
Approaches
Univariate
• This is just a split-plot analysis with adjusted p-values
• Adjustments: Greenhouse-Geisser or Huynh-Feldt methods
• In R, you must do a MANOVA to obtain these adjusted
P-values
Intro Univariate Split-plot Approach Multivariate 3 / 18
Approaches
Univariate
• This is just a split-plot analysis with adjusted p-values
• Adjustments: Greenhouse-Geisser or Huynh-Feldt methods
• In R, you must do a MANOVA to obtain these adjusted
P-values
MANOVA
• Testing based on Wilks’ lambda or Pillai’s trace
• This is usually followed by a profile analysis
Intro Univariate Split-plot Approach Multivariate 3 / 18
Approaches
Univariate
• This is just a split-plot analysis with adjusted p-values
• Adjustments: Greenhouse-Geisser or Huynh-Feldt methods
• In R, you must do a MANOVA to obtain these adjusted
P-values
MANOVA
• Testing based on Wilks’ lambda or Pillai’s trace
• This is usually followed by a profile analysis
Mixed effects model with (ARMA) correlation structure
• This can be done using lme
• We might cover this later
Intro Univariate Split-plot Approach Multivariate 3 / 18
The plant data
plantData <- read.csv("plantData.csv")
plantData$plant <- factor(plantData$plant)
plantData$week <- factor(plantData$week)
str(plantData)
## 'data.frame': 50 obs. of 4 variables:
## $ plant : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 .
## $ fertilizer: Factor w/ 2 levels "H","L": 2 2 2 2 2 2 2 2 2 2 ...
## $ week : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ..
## $ leaves : int 4 5 6 8 10 3 4 6 6 9 ...
Intro Univariate Split-plot Approach Multivariate 4 / 18
The plant data
plantData <- read.csv("plantData.csv")
plantData$plant <- factor(plantData$plant)
plantData$week <- factor(plantData$week)
str(plantData)
## 'data.frame': 50 obs. of 4 variables:
## $ plant : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 .
## $ fertilizer: Factor w/ 2 levels "H","L": 2 2 2 2 2 2 2 2 2 2 ...
## $ week : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ..
## $ leaves : int 4 5 6 8 10 3 4 6 6 9 ...
head(plantData, n=8)
## plant fertilizer week leaves
## 1 1 L 1 4
## 2 1 L 2 5
## 3 1 L 3 6
## 4 1 L 4 8
## 5 1 L 5 10
## 6 2 L 1 3
## 7 2 L 2 4
## 8 2 L 3 6
Intro Univariate Split-plot Approach Multivariate 4 / 18
Leaf Growth
1 2 3 4 5
468101214
Week
Leaves
High fertilizer
Low fertilizer
Intro Univariate Split-plot Approach Multivariate 5 / 18
Univariate split-plot approach
aov1 <- aov(leaves ~ fertilizer*week + Error(plant),
data=plantData)
Intro Univariate Split-plot Approach Multivariate 6 / 18
Univariate split-plot approach
aov1 <- aov(leaves ~ fertilizer*week + Error(plant),
data=plantData)
summary(aov1)
##
## Error: plant
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 16.82 16.82 2.604 0.145
## Residuals 8 51.68 6.46
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## week 4 267.40 66.85 158.225 <2e-16 ***
## fertilizer:week 4 5.08 1.27 3.006 0.0326 *
## Residuals 32 13.52 0.42
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Intro Univariate Split-plot Approach Multivariate 6 / 18
Univariate split-plot approach
aov1 <- aov(leaves ~ fertilizer*week + Error(plant),
data=plantData)
summary(aov1)
##
## Error: plant
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 16.82 16.82 2.604 0.145
## Residuals 8 51.68 6.46
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## week 4 267.40 66.85 158.225 <2e-16 ***
## fertilizer:week 4 5.08 1.27 3.006 0.0326 *
## Residuals 32 13.52 0.42
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
We need to adjust the p-values for the time and interaction effects
Intro Univariate Split-plot Approach Multivariate 6 / 18
Univariate split-plot approach
aov1 <- aov(leaves ~ fertilizer*week + Error(plant),
data=plantData)
summary(aov1)
##
## Error: plant
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 16.82 16.82 2.604 0.145
## Residuals 8 51.68 6.46
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## week 4 267.40 66.85 158.225 <2e-16 ***
## fertilizer:week 4 5.08 1.27 3.006 0.0326 *
## Residuals 32 13.52 0.42
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
We need to adjust the p-values for the time and interaction effects
In R, this requires reformatting the data and running a MANOVA
Intro Univariate Split-plot Approach Multivariate 6 / 18
Format data for MANOVA
plantData2 <- reshape(plantData, idvar="plant",
timevar="week", v.names="leaves",
direction="wide")
Intro Univariate Split-plot Approach Multivariate 7 / 18
Format data for MANOVA
plantData2 <- reshape(plantData, idvar="plant",
timevar="week", v.names="leaves",
direction="wide")
plantData2
## plant fertilizer leaves.1 leaves.2 leaves.3 leaves.4 leaves.5
## 1 1 L 4 5 6 8 10
## 6 2 L 3 4 6 6 9
## 11 3 L 6 7 9 10 12
## 16 4 L 5 7 8 10 12
## 21 5 L 5 6 7 8 10
## 26 6 H 4 6 9 9 11
## 31 7 H 3 5 7 10 12
## 36 8 H 6 8 11 10 14
## 41 9 H 5 7 9 10 12
## 46 10 H 5 8 9 11 11
Intro Univariate Split-plot Approach Multivariate 7 / 18
MANOVA and adjusted P-values
manova1 <- manova(cbind(leaves.1, leaves.2, leaves.3,
leaves.4, leaves.5) ~ fertilizer,
data=plantData2)
Intro Univariate Split-plot Approach Multivariate 8 / 18
MANOVA and adjusted P-values
manova1 <- manova(cbind(leaves.1, leaves.2, leaves.3,
leaves.4, leaves.5) ~ fertilizer,
data=plantData2)
anova(manova1, X=~1, test="Spherical")
## Analysis of Variance Table
##
##
## Contrasts orthogonal to
## ~1
##
## Greenhouse-Geisser epsilon: 0.5882
## Huynh-Feldt epsilon: 0.8490
##
## Df F num Df den Df Pr(>F) G-G Pr H-F Pr
## (Intercept) 1 158.2249 4 32 0.000000 0.000000 0.00000
## fertilizer 1 3.0059 4 32 0.032613 0.066622 0.04224
## Residuals 8
Intro Univariate Split-plot Approach Multivariate 8 / 18
MANOVA and adjusted P-values
manova1 <- manova(cbind(leaves.1, leaves.2, leaves.3,
leaves.4, leaves.5) ~ fertilizer,
data=plantData2)
anova(manova1, X=~1, test="Spherical")
## Analysis of Variance Table
##
##
## Contrasts orthogonal to
## ~1
##
## Greenhouse-Geisser epsilon: 0.5882
## Huynh-Feldt epsilon: 0.8490
##
## Df F num Df den Df Pr(>F) G-G Pr H-F Pr
## (Intercept) 1 158.2249 4 32 0.000000 0.000000 0.00000
## fertilizer 1 3.0059 4 32 0.032613 0.066622 0.04224
## Residuals 8
The last 3 columns are p-values corresponding to the effects of time (Intercept)
and interaction (fertilizer). No adjustment is necessary for the main effect so
you can use the p-value from aov .
Intro Univariate Split-plot Approach Multivariate 8 / 18
An aside – sphericity
Technically, adjusted p-values and MANOVA aren’t necessary if the
assumption of sphericity holds. However, we recommend doing the
adjustments (or the MANOVA) anyway because the test of sphericity has
low power.
Intro Univariate Split-plot Approach Multivariate 9 / 18
An aside – sphericity
Technically, adjusted p-values and MANOVA aren’t necessary if the
assumption of sphericity holds. However, we recommend doing the
adjustments (or the MANOVA) anyway because the test of sphericity has
low power.
Sphericity is the multivariate analogue of the homogeneity of variance
assumption of ANOVA.
Intro Univariate Split-plot Approach Multivariate 9 / 18
An aside – sphericity
Technically, adjusted p-values and MANOVA aren’t necessary if the
assumption of sphericity holds. However, we recommend doing the
adjustments (or the MANOVA) anyway because the test of sphericity has
low power.
Sphericity is the multivariate analogue of the homogeneity of variance
assumption of ANOVA.
Here is how you test the assumption:
mauchly.test(manova1, X=~1)
##
## Mauchly's test of sphericity
## Contrasts orthogonal to
## ~1
##
##
## data: SSD matrix from manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4,
## W = 0.099297, p-value = 0.1062
Intro Univariate Split-plot Approach Multivariate 9 / 18
An aside – sphericity
Technically, adjusted p-values and MANOVA aren’t necessary if the
assumption of sphericity holds. However, we recommend doing the
adjustments (or the MANOVA) anyway because the test of sphericity has
low power.
Sphericity is the multivariate analogue of the homogeneity of variance
assumption of ANOVA.
Here is how you test the assumption:
mauchly.test(manova1, X=~1)
##
## Mauchly's test of sphericity
## Contrasts orthogonal to
## ~1
##
##
## data: SSD matrix from manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4,
## W = 0.099297, p-value = 0.1062
We fail to reject the null hypothesis, so sphericity can be assumed.
Intro Univariate Split-plot Approach Multivariate 9 / 18
Compare aov and manova results
summary(aov1)
##
## Error: plant
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 16.82 16.82 2.604 0.145
## Residuals 8 51.68 6.46
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## week 4 267.40 66.85 158.225 <2e-16 ***
## fertilizer:week 4 5.08 1.27 3.006 0.0326 *
## Residuals 32 13.52 0.42
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(manova1, X=~1, test="Spherical")
## Analysis of Variance Table
##
##
## Contrasts orthogonal to
## ~1
##
## Greenhouse-Geisser epsilon: 0.5882
## Huynh-Feldt epsilon: 0.8490
##
## Df F num Df den Df Pr(>F) G-G Pr H-F Pr
## (Intercept) 1 158.2249 4 32 0.000000 0.000000 0.00000
## fertilizer 1 3.0059 4 32 0.032613 0.066622 0.04224
## Residuals 8
Intro Univariate Split-plot Approach Multivariate 10 / 18
Multivariate tests – Wilks’ lambda
An alternative to the adjusted p-value approach is to do a multivariate
analysis relaxing the assumptions about the structure of the
variance-covariance matrix. We’re already most of the way there.
Intro Univariate Split-plot Approach Multivariate 11 / 18
Multivariate tests – Wilks’ lambda
An alternative to the adjusted p-value approach is to do a multivariate
analysis relaxing the assumptions about the structure of the
variance-covariance matrix. We’re already most of the way there.
anova(manova1, X=~1, test="Wilks")
## Analysis of Variance Table
##
##
## Contrasts orthogonal to
## ~1
##
## Df Wilks approx F num Df den Df Pr(>F)
## (Intercept) 1 0.008487 146.042 4 5 2.308e-05 ***
## fertilizer 1 0.144772 7.384 4 5 0.02503 *
## Residuals 8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Intro Univariate Split-plot Approach Multivariate 11 / 18
Multivariate tests – Wilks’ lambda
An alternative to the adjusted p-value approach is to do a multivariate
analysis relaxing the assumptions about the structure of the
variance-covariance matrix. We’re already most of the way there.
anova(manova1, X=~1, test="Wilks")
## Analysis of Variance Table
##
##
## Contrasts orthogonal to
## ~1
##
## Df Wilks approx F num Df den Df Pr(>F)
## (Intercept) 1 0.008487 146.042 4 5 2.308e-05 ***
## fertilizer 1 0.144772 7.384 4 5 0.02503 *
## Residuals 8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
As before, we conclude that the effect of fertilizer changes over time
Intro Univariate Split-plot Approach Multivariate 11 / 18
Multivariate tests – Pillai’s trace
Pillai’s trace is an alternative to Wilks’ lambda. In this case, it returns
the same p-values as Wilks’ test.
anova(manova1, X=~1, test="Pillai")
## Analysis of Variance Table
##
##
## Contrasts orthogonal to
## ~1
##
## Df Pillai approx F num Df den Df Pr(>F)
## (Intercept) 1 0.99151 146.042 4 5 2.308e-05 ***
## fertilizer 1 0.85523 7.384 4 5 0.02503 *
## Residuals 8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Intro Univariate Split-plot Approach Multivariate 12 / 18
Profile analysis
Profile analysis requires calculating the differences (ie, the number
of leaves grown each week).
manova2 <- manova(
cbind(leaves.2-leaves.1, leaves.3-leaves.2,
leaves.4-leaves.3, leaves.5-leaves.4) ~
fertilizer, data=plantData2)
Intro Univariate Split-plot Approach Multivariate 13 / 18
Profile Analysis
During which intervals do the growth rates differ?
Intro Univariate Split-plot Approach Multivariate 14 / 18
Profile Analysis
During which intervals do the growth rates differ?
summary.aov(manova2)
## Response 1 :
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 2.5 2.5 12.5 0.00767 **
## Residuals 8 1.6 0.2
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response 2 :
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 1.6 1.6 3.2 0.1114
## Residuals 8 4.0 0.5
##
## Response 3 :
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 0.1 0.1 0.0625 0.8089
## Residuals 8 12.8 1.6
##
## Response 4 :
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 1 0.1 0.1 0.0909 0.7707
## Residuals 8 8.8 1.1
Intro Univariate Split-plot Approach Multivariate 14 / 18
Plot the growth rates
Calculate mean growth rate for each time interval
Intro Univariate Split-plot Approach Multivariate 15 / 18
Plot the growth rates
Calculate mean growth rate for each time interval
leavesMat <- plantData2[,3:7]
growthMat <- leavesMat[,2:5] - leavesMat[,1:4]
colnames(growthMat) <- paste("interval", 1:4, sep=".")
(lowFertilizer <- colMeans(growthMat[1:5,]))
## interval.1 interval.2 interval.3 interval.4
## 1.2 1.4 1.2 2.2
(highFertilizer <- colMeans(growthMat[6:10,]))
## interval.1 interval.2 interval.3 interval.4
## 2.2 2.2 1.0 2.0
Intro Univariate Split-plot Approach Multivariate 15 / 18
Plot the growth rates
Calculate mean growth rate for each time interval
leavesMat <- plantData2[,3:7]
growthMat <- leavesMat[,2:5] - leavesMat[,1:4]
colnames(growthMat) <- paste("interval", 1:4, sep=".")
(lowFertilizer <- colMeans(growthMat[1:5,]))
## interval.1 interval.2 interval.3 interval.4
## 1.2 1.4 1.2 2.2
(highFertilizer <- colMeans(growthMat[6:10,]))
## interval.1 interval.2 interval.3 interval.4
## 2.2 2.2 1.0 2.0
Calculate the standard errors for these growth rates
SE <- sqrt(diag(stats:::vcov.mlm(manova2)))
SE <- SE[names(SE)==":(Intercept)"] # Only use "intercept" SEs
unname(SE) ## Ignore the names
## [1] 0.2000000 0.3162278 0.5656854 0.4690416
Intro Univariate Split-plot Approach Multivariate 15 / 18
Plot the growth rates
plot(1:4-0.05, lowFertilizer, type="b", xlim=c(0.9, 4.1),
ylim=c(-1, 4), xaxp=c(1,4,3), cex.lab=1.5,
xlab="Time interval", ylab="Growth rate (leaves/week)")
abline(h=0, lty=3)
arrows(1:4-.05, lowFertilizer-SE, 1:4-.05, lowFertilizer+SE,
angle=90, code=3, length=0.05)
lines(1:4+0.05, highFertilizer, type="b", pch=17, col=4)
arrows(1:4+0.05, highFertilizer-SE, 1:4+0.05,
highFertilizer+SE, angle=90, code=3, length=0.05)
legend(1, 4, c("Low fertilizer", "High fertilizer"),
col=c("black", "blue"), pch=c(1,17))
Intro Univariate Split-plot Approach Multivariate 16 / 18
Plot the growth rates
q
q
q
q
1 2 3 4
−101234
Time interval
Growthrate(leaves/week)
q Low fertilizer
High fertilizer
Intro Univariate Split-plot Approach Multivariate 17 / 18
Assignment
A researcher wants to assess the effects of crowding on the growth of the dark
toadfish (Neophrynichthys latus). 15 fish tanks are stocked with three densities
of conspecifics. Five tanks have low density (1 fish), 5 tanks have medium
density (5 fish), and 5 tanks have high density (10 fish). In each tank, the
weight of one “focal fish” is recorded on 6 consecutive weeks. The data are in
the file fishData.csv.
Intro Univariate Split-plot Approach Multivariate 18 / 18
Assignment
A researcher wants to assess the effects of crowding on the growth of the dark
toadfish (Neophrynichthys latus). 15 fish tanks are stocked with three densities
of conspecifics. Five tanks have low density (1 fish), 5 tanks have medium
density (5 fish), and 5 tanks have high density (10 fish). In each tank, the
weight of one “focal fish” is recorded on 6 consecutive weeks. The data are in
the file fishData.csv.
(1) Conduct the univariate repeated measures ANOVA using aov . Calculate
the adjusted p-values using the Huynh-Feldt method. Does the effect of
density change over time?
(2) Conduct a multivariate repeated measures ANOVA and use Wilks’ lambda
to test if the effect of density changes over time. What is your conclusion?
(3) Conduct a profile analysis. In which time intervals is the effect of density
on growth rate significant?
Intro Univariate Split-plot Approach Multivariate 18 / 18
Assignment
A researcher wants to assess the effects of crowding on the growth of the dark
toadfish (Neophrynichthys latus). 15 fish tanks are stocked with three densities
of conspecifics. Five tanks have low density (1 fish), 5 tanks have medium
density (5 fish), and 5 tanks have high density (10 fish). In each tank, the
weight of one “focal fish” is recorded on 6 consecutive weeks. The data are in
the file fishData.csv.
(1) Conduct the univariate repeated measures ANOVA using aov . Calculate
the adjusted p-values using the Huynh-Feldt method. Does the effect of
density change over time?
(2) Conduct a multivariate repeated measures ANOVA and use Wilks’ lambda
to test if the effect of density changes over time. What is your conclusion?
(3) Conduct a profile analysis. In which time intervals is the effect of density
on growth rate significant?
Upload your self-contained R-script to ELC at least one day before your next lab
Intro Univariate Split-plot Approach Multivariate 18 / 18

More Related Content

Similar to Repeated measures analysis in R

A note on estimation of population mean in sample survey using auxiliary info...
A note on estimation of population mean in sample survey using auxiliary info...A note on estimation of population mean in sample survey using auxiliary info...
A note on estimation of population mean in sample survey using auxiliary info...Alexander Decker
 
Biom-32-GxE I.ppt
Biom-32-GxE I.pptBiom-32-GxE I.ppt
Biom-32-GxE I.pptbirhankassa
 
10.Analysis of Variance.ppt
10.Analysis of Variance.ppt10.Analysis of Variance.ppt
10.Analysis of Variance.pptAbdulhaqAli
 
Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...
Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...
Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...Satish Khadia
 
Variance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeriVariance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeriParavayya Pujeri
 
U1.4-RVDistributions.ppt
U1.4-RVDistributions.pptU1.4-RVDistributions.ppt
U1.4-RVDistributions.pptSameeraasif2
 
UMBC Research Day Presentation
UMBC Research Day PresentationUMBC Research Day Presentation
UMBC Research Day PresentationSDavis7
 
A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...
A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...
A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...Savas Papadopoulos, Ph.D
 
Memorization of Various Calculator shortcuts
Memorization of Various Calculator shortcutsMemorization of Various Calculator shortcuts
Memorization of Various Calculator shortcutsPrincessNorberte
 
Chapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docx
Chapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docxChapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docx
Chapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docxtiffanyd4
 

Similar to Repeated measures analysis in R (20)

linear models.pptx
linear models.pptxlinear models.pptx
linear models.pptx
 
Assumptions of ANOVA
Assumptions of ANOVAAssumptions of ANOVA
Assumptions of ANOVA
 
A note on estimation of population mean in sample survey using auxiliary info...
A note on estimation of population mean in sample survey using auxiliary info...A note on estimation of population mean in sample survey using auxiliary info...
A note on estimation of population mean in sample survey using auxiliary info...
 
Biom-32-GxE I.ppt
Biom-32-GxE I.pptBiom-32-GxE I.ppt
Biom-32-GxE I.ppt
 
10.Analysis of Variance.ppt
10.Analysis of Variance.ppt10.Analysis of Variance.ppt
10.Analysis of Variance.ppt
 
Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...
Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...
Analysis of Variance (ANOVA), MANOVA: Expected variance components, Random an...
 
One-way ANOVA
One-way ANOVAOne-way ANOVA
One-way ANOVA
 
Variance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeriVariance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeri
 
U1.4-RVDistributions.ppt
U1.4-RVDistributions.pptU1.4-RVDistributions.ppt
U1.4-RVDistributions.ppt
 
UMBC Research Day Presentation
UMBC Research Day PresentationUMBC Research Day Presentation
UMBC Research Day Presentation
 
SAS Notes
SAS NotesSAS Notes
SAS Notes
 
Analysis of variance anova
Analysis of variance anovaAnalysis of variance anova
Analysis of variance anova
 
Anova; analysis of variance
Anova; analysis of varianceAnova; analysis of variance
Anova; analysis of variance
 
6SigmaReferenceMaterials
6SigmaReferenceMaterials6SigmaReferenceMaterials
6SigmaReferenceMaterials
 
4 meda
4 meda4 meda
4 meda
 
A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...
A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...
A PRACTICAL POWERFUL ROBUST AND INTERPRETABLE FAMILY OF CORRELATION COEFFICIE...
 
4 MEDA.pdf
4 MEDA.pdf4 MEDA.pdf
4 MEDA.pdf
 
Memorization of Various Calculator shortcuts
Memorization of Various Calculator shortcutsMemorization of Various Calculator shortcuts
Memorization of Various Calculator shortcuts
 
PheWAS-package.pdf
PheWAS-package.pdfPheWAS-package.pdf
PheWAS-package.pdf
 
Chapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docx
Chapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docxChapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docx
Chapter 9 Two-Sample Inference 265 Chapter 9 Two-Sam.docx
 

More from richardchandler

Introduction to Generalized Linear Models
Introduction to Generalized Linear ModelsIntroduction to Generalized Linear Models
Introduction to Generalized Linear Modelsrichardchandler
 
Introduction to statistical modeling in R
Introduction to statistical modeling in RIntroduction to statistical modeling in R
Introduction to statistical modeling in Rrichardchandler
 
t-tests in R - Lab slides for UGA course FANR 6750
t-tests in R - Lab slides for UGA course FANR 6750t-tests in R - Lab slides for UGA course FANR 6750
t-tests in R - Lab slides for UGA course FANR 6750richardchandler
 
Introduction to R - Lab slides for UGA course FANR 6750
Introduction to R - Lab slides for UGA course FANR 6750Introduction to R - Lab slides for UGA course FANR 6750
Introduction to R - Lab slides for UGA course FANR 6750richardchandler
 
Hierarchichal species distributions model and Maxent
Hierarchichal species distributions model and MaxentHierarchichal species distributions model and Maxent
Hierarchichal species distributions model and Maxentrichardchandler
 
The role of spatial models in applied ecological research
The role of spatial models in applied ecological researchThe role of spatial models in applied ecological research
The role of spatial models in applied ecological researchrichardchandler
 

More from richardchandler (8)

Introduction to Generalized Linear Models
Introduction to Generalized Linear ModelsIntroduction to Generalized Linear Models
Introduction to Generalized Linear Models
 
Introduction to statistical modeling in R
Introduction to statistical modeling in RIntroduction to statistical modeling in R
Introduction to statistical modeling in R
 
t-tests in R - Lab slides for UGA course FANR 6750
t-tests in R - Lab slides for UGA course FANR 6750t-tests in R - Lab slides for UGA course FANR 6750
t-tests in R - Lab slides for UGA course FANR 6750
 
Introduction to R - Lab slides for UGA course FANR 6750
Introduction to R - Lab slides for UGA course FANR 6750Introduction to R - Lab slides for UGA course FANR 6750
Introduction to R - Lab slides for UGA course FANR 6750
 
Hierarchichal species distributions model and Maxent
Hierarchichal species distributions model and MaxentHierarchichal species distributions model and Maxent
Hierarchichal species distributions model and Maxent
 
Slides from ESA 2015
Slides from ESA 2015Slides from ESA 2015
Slides from ESA 2015
 
The role of spatial models in applied ecological research
The role of spatial models in applied ecological researchThe role of spatial models in applied ecological research
The role of spatial models in applied ecological research
 
2014 ISEC slides
2014 ISEC slides2014 ISEC slides
2014 ISEC slides
 

Recently uploaded

GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physicsvishikhakeshava1
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCEPRINCE C P
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Luciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxLuciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxAleenaTreesaSaji
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxyaramohamed343013
 

Recently uploaded (20)

GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physics
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Munirka Delhi 💯Call Us 🔝8264348440🔝
 
Luciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxLuciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptx
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docx
 

Repeated measures analysis in R

  • 1. Lab 10 – Repeated Measures October 22 & 23, 2018 FANR 6750 Richard Chandler and Bob Cooper
  • 2. Overview Design • We randomly assign each “subject” to a treatment • We record the response to the treatment over time Intro Univariate Split-plot Approach Multivariate 2 / 18
  • 3. Overview Design • We randomly assign each “subject” to a treatment • We record the response to the treatment over time Sources of variation • Treatment • Time • Treatment-time interaction • Random variation among subjects • Random variation within subjects Intro Univariate Split-plot Approach Multivariate 2 / 18
  • 4. Approaches Univariate • This is just a split-plot analysis with adjusted p-values • Adjustments: Greenhouse-Geisser or Huynh-Feldt methods • In R, you must do a MANOVA to obtain these adjusted P-values Intro Univariate Split-plot Approach Multivariate 3 / 18
  • 5. Approaches Univariate • This is just a split-plot analysis with adjusted p-values • Adjustments: Greenhouse-Geisser or Huynh-Feldt methods • In R, you must do a MANOVA to obtain these adjusted P-values MANOVA • Testing based on Wilks’ lambda or Pillai’s trace • This is usually followed by a profile analysis Intro Univariate Split-plot Approach Multivariate 3 / 18
  • 6. Approaches Univariate • This is just a split-plot analysis with adjusted p-values • Adjustments: Greenhouse-Geisser or Huynh-Feldt methods • In R, you must do a MANOVA to obtain these adjusted P-values MANOVA • Testing based on Wilks’ lambda or Pillai’s trace • This is usually followed by a profile analysis Mixed effects model with (ARMA) correlation structure • This can be done using lme • We might cover this later Intro Univariate Split-plot Approach Multivariate 3 / 18
  • 7. The plant data plantData <- read.csv("plantData.csv") plantData$plant <- factor(plantData$plant) plantData$week <- factor(plantData$week) str(plantData) ## 'data.frame': 50 obs. of 4 variables: ## $ plant : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 . ## $ fertilizer: Factor w/ 2 levels "H","L": 2 2 2 2 2 2 2 2 2 2 ... ## $ week : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 .. ## $ leaves : int 4 5 6 8 10 3 4 6 6 9 ... Intro Univariate Split-plot Approach Multivariate 4 / 18
  • 8. The plant data plantData <- read.csv("plantData.csv") plantData$plant <- factor(plantData$plant) plantData$week <- factor(plantData$week) str(plantData) ## 'data.frame': 50 obs. of 4 variables: ## $ plant : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 . ## $ fertilizer: Factor w/ 2 levels "H","L": 2 2 2 2 2 2 2 2 2 2 ... ## $ week : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 .. ## $ leaves : int 4 5 6 8 10 3 4 6 6 9 ... head(plantData, n=8) ## plant fertilizer week leaves ## 1 1 L 1 4 ## 2 1 L 2 5 ## 3 1 L 3 6 ## 4 1 L 4 8 ## 5 1 L 5 10 ## 6 2 L 1 3 ## 7 2 L 2 4 ## 8 2 L 3 6 Intro Univariate Split-plot Approach Multivariate 4 / 18
  • 9. Leaf Growth 1 2 3 4 5 468101214 Week Leaves High fertilizer Low fertilizer Intro Univariate Split-plot Approach Multivariate 5 / 18
  • 10. Univariate split-plot approach aov1 <- aov(leaves ~ fertilizer*week + Error(plant), data=plantData) Intro Univariate Split-plot Approach Multivariate 6 / 18
  • 11. Univariate split-plot approach aov1 <- aov(leaves ~ fertilizer*week + Error(plant), data=plantData) summary(aov1) ## ## Error: plant ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 16.82 16.82 2.604 0.145 ## Residuals 8 51.68 6.46 ## ## Error: Within ## Df Sum Sq Mean Sq F value Pr(>F) ## week 4 267.40 66.85 158.225 <2e-16 *** ## fertilizer:week 4 5.08 1.27 3.006 0.0326 * ## Residuals 32 13.52 0.42 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Intro Univariate Split-plot Approach Multivariate 6 / 18
  • 12. Univariate split-plot approach aov1 <- aov(leaves ~ fertilizer*week + Error(plant), data=plantData) summary(aov1) ## ## Error: plant ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 16.82 16.82 2.604 0.145 ## Residuals 8 51.68 6.46 ## ## Error: Within ## Df Sum Sq Mean Sq F value Pr(>F) ## week 4 267.40 66.85 158.225 <2e-16 *** ## fertilizer:week 4 5.08 1.27 3.006 0.0326 * ## Residuals 32 13.52 0.42 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 We need to adjust the p-values for the time and interaction effects Intro Univariate Split-plot Approach Multivariate 6 / 18
  • 13. Univariate split-plot approach aov1 <- aov(leaves ~ fertilizer*week + Error(plant), data=plantData) summary(aov1) ## ## Error: plant ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 16.82 16.82 2.604 0.145 ## Residuals 8 51.68 6.46 ## ## Error: Within ## Df Sum Sq Mean Sq F value Pr(>F) ## week 4 267.40 66.85 158.225 <2e-16 *** ## fertilizer:week 4 5.08 1.27 3.006 0.0326 * ## Residuals 32 13.52 0.42 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 We need to adjust the p-values for the time and interaction effects In R, this requires reformatting the data and running a MANOVA Intro Univariate Split-plot Approach Multivariate 6 / 18
  • 14. Format data for MANOVA plantData2 <- reshape(plantData, idvar="plant", timevar="week", v.names="leaves", direction="wide") Intro Univariate Split-plot Approach Multivariate 7 / 18
  • 15. Format data for MANOVA plantData2 <- reshape(plantData, idvar="plant", timevar="week", v.names="leaves", direction="wide") plantData2 ## plant fertilizer leaves.1 leaves.2 leaves.3 leaves.4 leaves.5 ## 1 1 L 4 5 6 8 10 ## 6 2 L 3 4 6 6 9 ## 11 3 L 6 7 9 10 12 ## 16 4 L 5 7 8 10 12 ## 21 5 L 5 6 7 8 10 ## 26 6 H 4 6 9 9 11 ## 31 7 H 3 5 7 10 12 ## 36 8 H 6 8 11 10 14 ## 41 9 H 5 7 9 10 12 ## 46 10 H 5 8 9 11 11 Intro Univariate Split-plot Approach Multivariate 7 / 18
  • 16. MANOVA and adjusted P-values manova1 <- manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4, leaves.5) ~ fertilizer, data=plantData2) Intro Univariate Split-plot Approach Multivariate 8 / 18
  • 17. MANOVA and adjusted P-values manova1 <- manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4, leaves.5) ~ fertilizer, data=plantData2) anova(manova1, X=~1, test="Spherical") ## Analysis of Variance Table ## ## ## Contrasts orthogonal to ## ~1 ## ## Greenhouse-Geisser epsilon: 0.5882 ## Huynh-Feldt epsilon: 0.8490 ## ## Df F num Df den Df Pr(>F) G-G Pr H-F Pr ## (Intercept) 1 158.2249 4 32 0.000000 0.000000 0.00000 ## fertilizer 1 3.0059 4 32 0.032613 0.066622 0.04224 ## Residuals 8 Intro Univariate Split-plot Approach Multivariate 8 / 18
  • 18. MANOVA and adjusted P-values manova1 <- manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4, leaves.5) ~ fertilizer, data=plantData2) anova(manova1, X=~1, test="Spherical") ## Analysis of Variance Table ## ## ## Contrasts orthogonal to ## ~1 ## ## Greenhouse-Geisser epsilon: 0.5882 ## Huynh-Feldt epsilon: 0.8490 ## ## Df F num Df den Df Pr(>F) G-G Pr H-F Pr ## (Intercept) 1 158.2249 4 32 0.000000 0.000000 0.00000 ## fertilizer 1 3.0059 4 32 0.032613 0.066622 0.04224 ## Residuals 8 The last 3 columns are p-values corresponding to the effects of time (Intercept) and interaction (fertilizer). No adjustment is necessary for the main effect so you can use the p-value from aov . Intro Univariate Split-plot Approach Multivariate 8 / 18
  • 19. An aside – sphericity Technically, adjusted p-values and MANOVA aren’t necessary if the assumption of sphericity holds. However, we recommend doing the adjustments (or the MANOVA) anyway because the test of sphericity has low power. Intro Univariate Split-plot Approach Multivariate 9 / 18
  • 20. An aside – sphericity Technically, adjusted p-values and MANOVA aren’t necessary if the assumption of sphericity holds. However, we recommend doing the adjustments (or the MANOVA) anyway because the test of sphericity has low power. Sphericity is the multivariate analogue of the homogeneity of variance assumption of ANOVA. Intro Univariate Split-plot Approach Multivariate 9 / 18
  • 21. An aside – sphericity Technically, adjusted p-values and MANOVA aren’t necessary if the assumption of sphericity holds. However, we recommend doing the adjustments (or the MANOVA) anyway because the test of sphericity has low power. Sphericity is the multivariate analogue of the homogeneity of variance assumption of ANOVA. Here is how you test the assumption: mauchly.test(manova1, X=~1) ## ## Mauchly's test of sphericity ## Contrasts orthogonal to ## ~1 ## ## ## data: SSD matrix from manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4, ## W = 0.099297, p-value = 0.1062 Intro Univariate Split-plot Approach Multivariate 9 / 18
  • 22. An aside – sphericity Technically, adjusted p-values and MANOVA aren’t necessary if the assumption of sphericity holds. However, we recommend doing the adjustments (or the MANOVA) anyway because the test of sphericity has low power. Sphericity is the multivariate analogue of the homogeneity of variance assumption of ANOVA. Here is how you test the assumption: mauchly.test(manova1, X=~1) ## ## Mauchly's test of sphericity ## Contrasts orthogonal to ## ~1 ## ## ## data: SSD matrix from manova(cbind(leaves.1, leaves.2, leaves.3, leaves.4, ## W = 0.099297, p-value = 0.1062 We fail to reject the null hypothesis, so sphericity can be assumed. Intro Univariate Split-plot Approach Multivariate 9 / 18
  • 23. Compare aov and manova results summary(aov1) ## ## Error: plant ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 16.82 16.82 2.604 0.145 ## Residuals 8 51.68 6.46 ## ## Error: Within ## Df Sum Sq Mean Sq F value Pr(>F) ## week 4 267.40 66.85 158.225 <2e-16 *** ## fertilizer:week 4 5.08 1.27 3.006 0.0326 * ## Residuals 32 13.52 0.42 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 anova(manova1, X=~1, test="Spherical") ## Analysis of Variance Table ## ## ## Contrasts orthogonal to ## ~1 ## ## Greenhouse-Geisser epsilon: 0.5882 ## Huynh-Feldt epsilon: 0.8490 ## ## Df F num Df den Df Pr(>F) G-G Pr H-F Pr ## (Intercept) 1 158.2249 4 32 0.000000 0.000000 0.00000 ## fertilizer 1 3.0059 4 32 0.032613 0.066622 0.04224 ## Residuals 8 Intro Univariate Split-plot Approach Multivariate 10 / 18
  • 24. Multivariate tests – Wilks’ lambda An alternative to the adjusted p-value approach is to do a multivariate analysis relaxing the assumptions about the structure of the variance-covariance matrix. We’re already most of the way there. Intro Univariate Split-plot Approach Multivariate 11 / 18
  • 25. Multivariate tests – Wilks’ lambda An alternative to the adjusted p-value approach is to do a multivariate analysis relaxing the assumptions about the structure of the variance-covariance matrix. We’re already most of the way there. anova(manova1, X=~1, test="Wilks") ## Analysis of Variance Table ## ## ## Contrasts orthogonal to ## ~1 ## ## Df Wilks approx F num Df den Df Pr(>F) ## (Intercept) 1 0.008487 146.042 4 5 2.308e-05 *** ## fertilizer 1 0.144772 7.384 4 5 0.02503 * ## Residuals 8 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Intro Univariate Split-plot Approach Multivariate 11 / 18
  • 26. Multivariate tests – Wilks’ lambda An alternative to the adjusted p-value approach is to do a multivariate analysis relaxing the assumptions about the structure of the variance-covariance matrix. We’re already most of the way there. anova(manova1, X=~1, test="Wilks") ## Analysis of Variance Table ## ## ## Contrasts orthogonal to ## ~1 ## ## Df Wilks approx F num Df den Df Pr(>F) ## (Intercept) 1 0.008487 146.042 4 5 2.308e-05 *** ## fertilizer 1 0.144772 7.384 4 5 0.02503 * ## Residuals 8 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 As before, we conclude that the effect of fertilizer changes over time Intro Univariate Split-plot Approach Multivariate 11 / 18
  • 27. Multivariate tests – Pillai’s trace Pillai’s trace is an alternative to Wilks’ lambda. In this case, it returns the same p-values as Wilks’ test. anova(manova1, X=~1, test="Pillai") ## Analysis of Variance Table ## ## ## Contrasts orthogonal to ## ~1 ## ## Df Pillai approx F num Df den Df Pr(>F) ## (Intercept) 1 0.99151 146.042 4 5 2.308e-05 *** ## fertilizer 1 0.85523 7.384 4 5 0.02503 * ## Residuals 8 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Intro Univariate Split-plot Approach Multivariate 12 / 18
  • 28. Profile analysis Profile analysis requires calculating the differences (ie, the number of leaves grown each week). manova2 <- manova( cbind(leaves.2-leaves.1, leaves.3-leaves.2, leaves.4-leaves.3, leaves.5-leaves.4) ~ fertilizer, data=plantData2) Intro Univariate Split-plot Approach Multivariate 13 / 18
  • 29. Profile Analysis During which intervals do the growth rates differ? Intro Univariate Split-plot Approach Multivariate 14 / 18
  • 30. Profile Analysis During which intervals do the growth rates differ? summary.aov(manova2) ## Response 1 : ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 2.5 2.5 12.5 0.00767 ** ## Residuals 8 1.6 0.2 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Response 2 : ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 1.6 1.6 3.2 0.1114 ## Residuals 8 4.0 0.5 ## ## Response 3 : ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 0.1 0.1 0.0625 0.8089 ## Residuals 8 12.8 1.6 ## ## Response 4 : ## Df Sum Sq Mean Sq F value Pr(>F) ## fertilizer 1 0.1 0.1 0.0909 0.7707 ## Residuals 8 8.8 1.1 Intro Univariate Split-plot Approach Multivariate 14 / 18
  • 31. Plot the growth rates Calculate mean growth rate for each time interval Intro Univariate Split-plot Approach Multivariate 15 / 18
  • 32. Plot the growth rates Calculate mean growth rate for each time interval leavesMat <- plantData2[,3:7] growthMat <- leavesMat[,2:5] - leavesMat[,1:4] colnames(growthMat) <- paste("interval", 1:4, sep=".") (lowFertilizer <- colMeans(growthMat[1:5,])) ## interval.1 interval.2 interval.3 interval.4 ## 1.2 1.4 1.2 2.2 (highFertilizer <- colMeans(growthMat[6:10,])) ## interval.1 interval.2 interval.3 interval.4 ## 2.2 2.2 1.0 2.0 Intro Univariate Split-plot Approach Multivariate 15 / 18
  • 33. Plot the growth rates Calculate mean growth rate for each time interval leavesMat <- plantData2[,3:7] growthMat <- leavesMat[,2:5] - leavesMat[,1:4] colnames(growthMat) <- paste("interval", 1:4, sep=".") (lowFertilizer <- colMeans(growthMat[1:5,])) ## interval.1 interval.2 interval.3 interval.4 ## 1.2 1.4 1.2 2.2 (highFertilizer <- colMeans(growthMat[6:10,])) ## interval.1 interval.2 interval.3 interval.4 ## 2.2 2.2 1.0 2.0 Calculate the standard errors for these growth rates SE <- sqrt(diag(stats:::vcov.mlm(manova2))) SE <- SE[names(SE)==":(Intercept)"] # Only use "intercept" SEs unname(SE) ## Ignore the names ## [1] 0.2000000 0.3162278 0.5656854 0.4690416 Intro Univariate Split-plot Approach Multivariate 15 / 18
  • 34. Plot the growth rates plot(1:4-0.05, lowFertilizer, type="b", xlim=c(0.9, 4.1), ylim=c(-1, 4), xaxp=c(1,4,3), cex.lab=1.5, xlab="Time interval", ylab="Growth rate (leaves/week)") abline(h=0, lty=3) arrows(1:4-.05, lowFertilizer-SE, 1:4-.05, lowFertilizer+SE, angle=90, code=3, length=0.05) lines(1:4+0.05, highFertilizer, type="b", pch=17, col=4) arrows(1:4+0.05, highFertilizer-SE, 1:4+0.05, highFertilizer+SE, angle=90, code=3, length=0.05) legend(1, 4, c("Low fertilizer", "High fertilizer"), col=c("black", "blue"), pch=c(1,17)) Intro Univariate Split-plot Approach Multivariate 16 / 18
  • 35. Plot the growth rates q q q q 1 2 3 4 −101234 Time interval Growthrate(leaves/week) q Low fertilizer High fertilizer Intro Univariate Split-plot Approach Multivariate 17 / 18
  • 36. Assignment A researcher wants to assess the effects of crowding on the growth of the dark toadfish (Neophrynichthys latus). 15 fish tanks are stocked with three densities of conspecifics. Five tanks have low density (1 fish), 5 tanks have medium density (5 fish), and 5 tanks have high density (10 fish). In each tank, the weight of one “focal fish” is recorded on 6 consecutive weeks. The data are in the file fishData.csv. Intro Univariate Split-plot Approach Multivariate 18 / 18
  • 37. Assignment A researcher wants to assess the effects of crowding on the growth of the dark toadfish (Neophrynichthys latus). 15 fish tanks are stocked with three densities of conspecifics. Five tanks have low density (1 fish), 5 tanks have medium density (5 fish), and 5 tanks have high density (10 fish). In each tank, the weight of one “focal fish” is recorded on 6 consecutive weeks. The data are in the file fishData.csv. (1) Conduct the univariate repeated measures ANOVA using aov . Calculate the adjusted p-values using the Huynh-Feldt method. Does the effect of density change over time? (2) Conduct a multivariate repeated measures ANOVA and use Wilks’ lambda to test if the effect of density changes over time. What is your conclusion? (3) Conduct a profile analysis. In which time intervals is the effect of density on growth rate significant? Intro Univariate Split-plot Approach Multivariate 18 / 18
  • 38. Assignment A researcher wants to assess the effects of crowding on the growth of the dark toadfish (Neophrynichthys latus). 15 fish tanks are stocked with three densities of conspecifics. Five tanks have low density (1 fish), 5 tanks have medium density (5 fish), and 5 tanks have high density (10 fish). In each tank, the weight of one “focal fish” is recorded on 6 consecutive weeks. The data are in the file fishData.csv. (1) Conduct the univariate repeated measures ANOVA using aov . Calculate the adjusted p-values using the Huynh-Feldt method. Does the effect of density change over time? (2) Conduct a multivariate repeated measures ANOVA and use Wilks’ lambda to test if the effect of density changes over time. What is your conclusion? (3) Conduct a profile analysis. In which time intervals is the effect of density on growth rate significant? Upload your self-contained R-script to ELC at least one day before your next lab Intro Univariate Split-plot Approach Multivariate 18 / 18