SlideShare a Scribd company logo
1 of 21
Download to read offline
Lab 7 – A × B Factorial Designs
October 1 & 2, 2018 FANR 6750
Richard Chandler and Bob Cooper
Situation
There are 2 factors thought to influence the response variable
Intro aov Follow-up Graphics 2 / 15
Situation
There are 2 factors thought to influence the response variable
The effect of each factor might depend on the other factor
Intro aov Follow-up Graphics 2 / 15
Situation
There are 2 factors thought to influence the response variable
The effect of each factor might depend on the other factor
We have replicates for each combination of factors
Intro aov Follow-up Graphics 2 / 15
Example: effects of food and predators on voles
voleData <- read.csv("microtus_data.csv")
head(voleData, 7)
## voles food predators
## 1 10 0 Present
## 2 12 0 Present
## 3 8 0 Present
## 4 14 0 Present
## 5 18 1 Present
## 6 20 1 Present
## 7 21 1 Present
str(voleData)
## 'data.frame': 24 obs. of 3 variables:
## $ voles : int 10 12 8 14 18 20 21 24 20 18 ...
## $ food : int 0 0 0 0 1 1 1 1 2 2 ...
## $ predators: Factor w/ 2 levels "Absent","Present": 2 2 2 2 2 2 2 2 2 2 ...
Intro aov Follow-up Graphics 3 / 15
Must convert food to a factor
voleData$food <- factor(voleData$food)
str(voleData)
## 'data.frame': 24 obs. of 3 variables:
## $ voles : int 10 12 8 14 18 20 21 24 20 18 ...
## $ food : Factor w/ 3 levels "0","1","2": 1 1 1 1 2 2 2 2
## $ predators: Factor w/ 2 levels "Absent","Present": 2 2 2 2
Intro aov Follow-up Graphics 4 / 15
See how many replicates you have
table(voleData$predators, voleData$food)
##
## 0 1 2
## Absent 4 4 4
## Present 4 4 4
Intro aov Follow-up Graphics 5 / 15
Boxplot with 2 factors
boxplot(voles ~ food + predators, data=voleData, ylab="Voles", cex.lab=1.5)
0.Absent 1.Absent 2.Absent 0.Present 1.Present 2.Present
1015202530354045
Voles
Intro aov Follow-up Graphics 6 / 15
A × B interaction
aov1 <- aov(voles ~ food * predators, data=voleData)
summary(aov1)
## Df Sum Sq Mean Sq F value Pr(>F)
## food 2 1337.3 668.6 40.56 2.15e-07 ***
## predators 1 975.4 975.4 59.16 4.27e-07 ***
## food:predators 2 518.2 259.1 15.72 0.000112 ***
## Residuals 18 296.8 16.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '
Intro aov Follow-up Graphics 7 / 15
No interaction
aov2 <- aov(voles ~ food + predators, data=voleData)
summary(aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## food 2 1337.3 668.6 16.41 6.06e-05 ***
## predators 1 975.4 975.4 23.94 8.81e-05 ***
## Residuals 20 815.0 40.8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '
Intro aov Follow-up Graphics 8 / 15
Follow-up
Effect of food when predators are present
summary(aov(voles ~ food, data=voleData, subset=predators=="Present"))
## Df Sum Sq Mean Sq F value Pr(>F)
## food 2 193.50 96.75 14.82 0.00142 **
## Residuals 9 58.75 6.53
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Intro aov Follow-up Graphics 9 / 15
Follow-up
Effect of food when predators are present
summary(aov(voles ~ food, data=voleData, subset=predators=="Present"))
## Df Sum Sq Mean Sq F value Pr(>F)
## food 2 193.50 96.75 14.82 0.00142 **
## Residuals 9 58.75 6.53
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Effect of food when predators are absent
summary(aov(voles ~ food, data=voleData, subset=predators=="Absent"))
## Df Sum Sq Mean Sq F value Pr(>F)
## food 2 1662 831.0 31.42 8.71e-05 ***
## Residuals 9 238 26.4
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Intro aov Follow-up Graphics 9 / 15
Tukey’s HSD
TukeyHSD(aov1)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = voles ~ food * predators, data = voleData)
##
## $food
## diff lwr upr p adj
## 1-0 13.875 8.693714 19.056286 0.0000061
## 2-0 17.250 12.068714 22.431286 0.0000003
## 2-1 3.375 -1.806286 8.556286 0.2464315
##
## $predators
## diff lwr upr p adj
## Present-Absent -12.75 -16.23252 -9.267482 4e-07
##
## $`food:predators`
## diff lwr upr p adj
## 1:Absent-0:Absent 18.00 8.8756323 27.124368 0.0000827
## 2:Absent-0:Absent 28.50 19.3756323 37.624368 0.0000001
## 0:Present-0:Absent -2.50 -11.6243677 6.624368 0.9487798
## 1:Present-0:Absent 7.25 -1.8743677 16.374368 0.1684043
## 2:Present-0:Absent 3.50 -5.6243677 12.624368 0.8221335
## 2:Absent-1:Absent 10.50 1.3756323 19.624368 0.0189039
## 0:Present-1:Absent -20.50 -29.6243677 -11.375632 0.0000154
## 1:Present-1:Absent -10.75 -19.8743677 -1.625632 0.0157740
## 2:Present-1:Absent -14.50 -23.6243677 -5.375632 0.0010013
## 0:Present-2:Absent -31.00 -40.1243677 -21.875632 0.0000000
## 1:Present-2:Absent -21.25 -30.3743677 -12.125632 0.0000095
## 2:Present-2:Absent -25.00 -34.1243677 -15.875632 0.0000010
## 1:Present-0:Present 9.75 0.6256323 18.874368 0.0323125
## 2:Present-0:Present 6.00 -3.1243677 15.124368 0.3351103
## 2:Present-1:Present -3.75 -12.8743677 5.374368 0.7780829Intro aov Follow-up Graphics 10 / 15
Compute group means and SEs
ybar_ij.SE <- model.tables(aov1, type="means", se=TRUE)
ybar_ij.SE
## Tables of means
## Grand mean
##
## 22.625
##
## food
## food
## 0 1 2
## 12.250 26.125 29.500
##
## predators
## predators
## Absent Present
## 29.00 16.25
##
## food:predators
## predators
## food Absent Present
## 0 13.50 11.00
## 1 31.50 20.75
## 2 42.00 17.00
##
## Standard errors for differences of means
## food predators food:predators
## 2.030 1.658 2.871
## replic. 8 12 4
Intro aov Follow-up Graphics 11 / 15
Extract group means and SEs
Group means
ybar_ij. <- ybar_ij.SE$tables$"food:predators"
ybar_ij.
## predators
## food Absent Present
## 0 13.50 11.00
## 1 31.50 20.75
## 2 42.00 17.00
Intro aov Follow-up Graphics 12 / 15
Extract group means and SEs
Group means
ybar_ij. <- ybar_ij.SE$tables$"food:predators"
ybar_ij.
## predators
## food Absent Present
## 0 13.50 11.00
## 1 31.50 20.75
## 2 42.00 17.00
Standard error
SE_ij. <- as.numeric(ybar_ij.SE$se$"food:predators")
SE_ij.
## [1] 2.871072
Intro aov Follow-up Graphics 12 / 15
Plot group means and SEs
plot(1:3, ybar_ij.[,1], xaxt="n", xlim=c(0.5, 3.5), ylim=c(0, 50), type="b",
pch=16, col="blue", xlab="Food", ylab="Voles", cex=1.5, cex.lab=1.5, lwd=2)
lines(1:3, ybar_ij.[,2], pch=16, col="black", type="b", cex=1.5, lty=2, lwd=2)
axis(1, 1:3, labels=c("0", "1", "2"))
arrows(1:3, ybar_ij.[,1]-SE_ij., 1:3, ybar_ij.[,1]+SE_ij., code=3, angle=90,
length=0.05, lwd=2, col="blue")
arrows(1:3, ybar_ij.[,2]-SE_ij., 1:3, ybar_ij.[,2]+SE_ij., code=3, angle=90,
length=0.05, lwd=2)
legend(0.5, 50, c("Absent", "Present"), col=c("blue", "black"), lty=c(1,2), title="Predators", pch=16)
q
q
q
01020304050
Food
Voles
q
q
q
0 1 2
q
q
Predators
Absent
Present
Intro aov Follow-up Graphics 13 / 15
Plot group means and SEs
bp <- barplot(ybar_ij., xlab="Predators", args.legend=list(title="Food"),
cex.lab=1.5, cex.names=1.4, col=c("linen", "lightblue", "turquoise"),
ylab="Voles", beside=TRUE, legend=TRUE, ylim=c(0, 50)); box()
arrows(bp, ybar_ij., bp, ybar_ij.+SE_ij., code=2, angle=90, length=0.05, lwd=1)
Absent Present
Food
0
1
2
Predators
Voles
01020304050
Intro aov Follow-up Graphics 14 / 15
In-class exercise
Fictitious Scenario
Acid rain has lowered the pH of many lakes in the northeastern United States, and as
a result, fish populations have declined. Managers have resorted to aerial applications
of lime (powdered calcium carbonate) in hopes of increasing pH. To determine if lime
applications result in increased pH, they applied equal amounts of lime to 15 lakes,
and as a control, they applied the same amount of inert white powder to an additional
15 lakes. Researchers suspected that the effect of lime might depend upon the
buffering effects of the underlying bedrock. To assess this hypothesis, the 30 lakes
were chosen such that 10 had limestone bedrock, 10 had granite bedrock, and 10 had
shist bedrock. pH was measured before and after each application, and the difference
in pH is recorded in the file “acidityData.csv.”
Intro aov Follow-up Graphics 15 / 15
In-class exercise
Fictitious Scenario
Acid rain has lowered the pH of many lakes in the northeastern United States, and as
a result, fish populations have declined. Managers have resorted to aerial applications
of lime (powdered calcium carbonate) in hopes of increasing pH. To determine if lime
applications result in increased pH, they applied equal amounts of lime to 15 lakes,
and as a control, they applied the same amount of inert white powder to an additional
15 lakes. Researchers suspected that the effect of lime might depend upon the
buffering effects of the underlying bedrock. To assess this hypothesis, the 30 lakes
were chosen such that 10 had limestone bedrock, 10 had granite bedrock, and 10 had
shist bedrock. pH was measured before and after each application, and the difference
in pH is recorded in the file “acidityData.csv.”
Questions
1 What are the null and alternative hypotheses?
2 Test the null hypotheses using an A × B factorial ANOVA implemented with aov .
Create an ANOVA table using summary .
3 Does the effect of lime depend upon the bedrock type? If so, how? Answer this
question by plotting the estimates of the effect of lime on pH change. Include 95%
confidence intervals.
Intro aov Follow-up Graphics 15 / 15
In-class exercise
Fictitious Scenario
Acid rain has lowered the pH of many lakes in the northeastern United States, and as
a result, fish populations have declined. Managers have resorted to aerial applications
of lime (powdered calcium carbonate) in hopes of increasing pH. To determine if lime
applications result in increased pH, they applied equal amounts of lime to 15 lakes,
and as a control, they applied the same amount of inert white powder to an additional
15 lakes. Researchers suspected that the effect of lime might depend upon the
buffering effects of the underlying bedrock. To assess this hypothesis, the 30 lakes
were chosen such that 10 had limestone bedrock, 10 had granite bedrock, and 10 had
shist bedrock. pH was measured before and after each application, and the difference
in pH is recorded in the file “acidityData.csv.”
Questions
1 What are the null and alternative hypotheses?
2 Test the null hypotheses using an A × B factorial ANOVA implemented with aov .
Create an ANOVA table using summary .
3 Does the effect of lime depend upon the bedrock type? If so, how? Answer this
question by plotting the estimates of the effect of lime on pH change. Include 95%
confidence intervals.
Put your answers in a self-contained R script, and upload the script to ELC at least
one day before your next lab.
Intro aov Follow-up Graphics 15 / 15

More Related Content

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
 
Lab on contrasts, estimation, and power
Lab on contrasts, estimation, and powerLab on contrasts, estimation, and power
Lab on contrasts, estimation, and powerrichardchandler
 
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 (11)

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
 
Assumptions of ANOVA
Assumptions of ANOVAAssumptions of ANOVA
Assumptions of ANOVA
 
Lab on contrasts, estimation, and power
Lab on contrasts, estimation, and powerLab on contrasts, estimation, and power
Lab on contrasts, estimation, and power
 
One-way ANOVA
One-way ANOVAOne-way ANOVA
One-way ANOVA
 
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

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
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
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
 
Module 4: Mendelian Genetics and Punnett Square
Module 4:  Mendelian Genetics and Punnett SquareModule 4:  Mendelian Genetics and Punnett Square
Module 4: Mendelian Genetics and Punnett SquareIsiahStephanRadaza
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.k64182334
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
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
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
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
 
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
 
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
 
Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)Jshifa
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
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
 
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
 

Recently uploaded (20)

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 ...
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .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
 
Module 4: Mendelian Genetics and Punnett Square
Module 4:  Mendelian Genetics and Punnett SquareModule 4:  Mendelian Genetics and Punnett Square
Module 4: Mendelian Genetics and Punnett Square
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
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
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).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
 
Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
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
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
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
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
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
 
Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
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
 
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...
 

Factorial designs

  • 1. Lab 7 – A × B Factorial Designs October 1 & 2, 2018 FANR 6750 Richard Chandler and Bob Cooper
  • 2. Situation There are 2 factors thought to influence the response variable Intro aov Follow-up Graphics 2 / 15
  • 3. Situation There are 2 factors thought to influence the response variable The effect of each factor might depend on the other factor Intro aov Follow-up Graphics 2 / 15
  • 4. Situation There are 2 factors thought to influence the response variable The effect of each factor might depend on the other factor We have replicates for each combination of factors Intro aov Follow-up Graphics 2 / 15
  • 5. Example: effects of food and predators on voles voleData <- read.csv("microtus_data.csv") head(voleData, 7) ## voles food predators ## 1 10 0 Present ## 2 12 0 Present ## 3 8 0 Present ## 4 14 0 Present ## 5 18 1 Present ## 6 20 1 Present ## 7 21 1 Present str(voleData) ## 'data.frame': 24 obs. of 3 variables: ## $ voles : int 10 12 8 14 18 20 21 24 20 18 ... ## $ food : int 0 0 0 0 1 1 1 1 2 2 ... ## $ predators: Factor w/ 2 levels "Absent","Present": 2 2 2 2 2 2 2 2 2 2 ... Intro aov Follow-up Graphics 3 / 15
  • 6. Must convert food to a factor voleData$food <- factor(voleData$food) str(voleData) ## 'data.frame': 24 obs. of 3 variables: ## $ voles : int 10 12 8 14 18 20 21 24 20 18 ... ## $ food : Factor w/ 3 levels "0","1","2": 1 1 1 1 2 2 2 2 ## $ predators: Factor w/ 2 levels "Absent","Present": 2 2 2 2 Intro aov Follow-up Graphics 4 / 15
  • 7. See how many replicates you have table(voleData$predators, voleData$food) ## ## 0 1 2 ## Absent 4 4 4 ## Present 4 4 4 Intro aov Follow-up Graphics 5 / 15
  • 8. Boxplot with 2 factors boxplot(voles ~ food + predators, data=voleData, ylab="Voles", cex.lab=1.5) 0.Absent 1.Absent 2.Absent 0.Present 1.Present 2.Present 1015202530354045 Voles Intro aov Follow-up Graphics 6 / 15
  • 9. A × B interaction aov1 <- aov(voles ~ food * predators, data=voleData) summary(aov1) ## Df Sum Sq Mean Sq F value Pr(>F) ## food 2 1337.3 668.6 40.56 2.15e-07 *** ## predators 1 975.4 975.4 59.16 4.27e-07 *** ## food:predators 2 518.2 259.1 15.72 0.000112 *** ## Residuals 18 296.8 16.5 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' Intro aov Follow-up Graphics 7 / 15
  • 10. No interaction aov2 <- aov(voles ~ food + predators, data=voleData) summary(aov2) ## Df Sum Sq Mean Sq F value Pr(>F) ## food 2 1337.3 668.6 16.41 6.06e-05 *** ## predators 1 975.4 975.4 23.94 8.81e-05 *** ## Residuals 20 815.0 40.8 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' Intro aov Follow-up Graphics 8 / 15
  • 11. Follow-up Effect of food when predators are present summary(aov(voles ~ food, data=voleData, subset=predators=="Present")) ## Df Sum Sq Mean Sq F value Pr(>F) ## food 2 193.50 96.75 14.82 0.00142 ** ## Residuals 9 58.75 6.53 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Intro aov Follow-up Graphics 9 / 15
  • 12. Follow-up Effect of food when predators are present summary(aov(voles ~ food, data=voleData, subset=predators=="Present")) ## Df Sum Sq Mean Sq F value Pr(>F) ## food 2 193.50 96.75 14.82 0.00142 ** ## Residuals 9 58.75 6.53 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Effect of food when predators are absent summary(aov(voles ~ food, data=voleData, subset=predators=="Absent")) ## Df Sum Sq Mean Sq F value Pr(>F) ## food 2 1662 831.0 31.42 8.71e-05 *** ## Residuals 9 238 26.4 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Intro aov Follow-up Graphics 9 / 15
  • 13. Tukey’s HSD TukeyHSD(aov1) ## Tukey multiple comparisons of means ## 95% family-wise confidence level ## ## Fit: aov(formula = voles ~ food * predators, data = voleData) ## ## $food ## diff lwr upr p adj ## 1-0 13.875 8.693714 19.056286 0.0000061 ## 2-0 17.250 12.068714 22.431286 0.0000003 ## 2-1 3.375 -1.806286 8.556286 0.2464315 ## ## $predators ## diff lwr upr p adj ## Present-Absent -12.75 -16.23252 -9.267482 4e-07 ## ## $`food:predators` ## diff lwr upr p adj ## 1:Absent-0:Absent 18.00 8.8756323 27.124368 0.0000827 ## 2:Absent-0:Absent 28.50 19.3756323 37.624368 0.0000001 ## 0:Present-0:Absent -2.50 -11.6243677 6.624368 0.9487798 ## 1:Present-0:Absent 7.25 -1.8743677 16.374368 0.1684043 ## 2:Present-0:Absent 3.50 -5.6243677 12.624368 0.8221335 ## 2:Absent-1:Absent 10.50 1.3756323 19.624368 0.0189039 ## 0:Present-1:Absent -20.50 -29.6243677 -11.375632 0.0000154 ## 1:Present-1:Absent -10.75 -19.8743677 -1.625632 0.0157740 ## 2:Present-1:Absent -14.50 -23.6243677 -5.375632 0.0010013 ## 0:Present-2:Absent -31.00 -40.1243677 -21.875632 0.0000000 ## 1:Present-2:Absent -21.25 -30.3743677 -12.125632 0.0000095 ## 2:Present-2:Absent -25.00 -34.1243677 -15.875632 0.0000010 ## 1:Present-0:Present 9.75 0.6256323 18.874368 0.0323125 ## 2:Present-0:Present 6.00 -3.1243677 15.124368 0.3351103 ## 2:Present-1:Present -3.75 -12.8743677 5.374368 0.7780829Intro aov Follow-up Graphics 10 / 15
  • 14. Compute group means and SEs ybar_ij.SE <- model.tables(aov1, type="means", se=TRUE) ybar_ij.SE ## Tables of means ## Grand mean ## ## 22.625 ## ## food ## food ## 0 1 2 ## 12.250 26.125 29.500 ## ## predators ## predators ## Absent Present ## 29.00 16.25 ## ## food:predators ## predators ## food Absent Present ## 0 13.50 11.00 ## 1 31.50 20.75 ## 2 42.00 17.00 ## ## Standard errors for differences of means ## food predators food:predators ## 2.030 1.658 2.871 ## replic. 8 12 4 Intro aov Follow-up Graphics 11 / 15
  • 15. Extract group means and SEs Group means ybar_ij. <- ybar_ij.SE$tables$"food:predators" ybar_ij. ## predators ## food Absent Present ## 0 13.50 11.00 ## 1 31.50 20.75 ## 2 42.00 17.00 Intro aov Follow-up Graphics 12 / 15
  • 16. Extract group means and SEs Group means ybar_ij. <- ybar_ij.SE$tables$"food:predators" ybar_ij. ## predators ## food Absent Present ## 0 13.50 11.00 ## 1 31.50 20.75 ## 2 42.00 17.00 Standard error SE_ij. <- as.numeric(ybar_ij.SE$se$"food:predators") SE_ij. ## [1] 2.871072 Intro aov Follow-up Graphics 12 / 15
  • 17. Plot group means and SEs plot(1:3, ybar_ij.[,1], xaxt="n", xlim=c(0.5, 3.5), ylim=c(0, 50), type="b", pch=16, col="blue", xlab="Food", ylab="Voles", cex=1.5, cex.lab=1.5, lwd=2) lines(1:3, ybar_ij.[,2], pch=16, col="black", type="b", cex=1.5, lty=2, lwd=2) axis(1, 1:3, labels=c("0", "1", "2")) arrows(1:3, ybar_ij.[,1]-SE_ij., 1:3, ybar_ij.[,1]+SE_ij., code=3, angle=90, length=0.05, lwd=2, col="blue") arrows(1:3, ybar_ij.[,2]-SE_ij., 1:3, ybar_ij.[,2]+SE_ij., code=3, angle=90, length=0.05, lwd=2) legend(0.5, 50, c("Absent", "Present"), col=c("blue", "black"), lty=c(1,2), title="Predators", pch=16) q q q 01020304050 Food Voles q q q 0 1 2 q q Predators Absent Present Intro aov Follow-up Graphics 13 / 15
  • 18. Plot group means and SEs bp <- barplot(ybar_ij., xlab="Predators", args.legend=list(title="Food"), cex.lab=1.5, cex.names=1.4, col=c("linen", "lightblue", "turquoise"), ylab="Voles", beside=TRUE, legend=TRUE, ylim=c(0, 50)); box() arrows(bp, ybar_ij., bp, ybar_ij.+SE_ij., code=2, angle=90, length=0.05, lwd=1) Absent Present Food 0 1 2 Predators Voles 01020304050 Intro aov Follow-up Graphics 14 / 15
  • 19. In-class exercise Fictitious Scenario Acid rain has lowered the pH of many lakes in the northeastern United States, and as a result, fish populations have declined. Managers have resorted to aerial applications of lime (powdered calcium carbonate) in hopes of increasing pH. To determine if lime applications result in increased pH, they applied equal amounts of lime to 15 lakes, and as a control, they applied the same amount of inert white powder to an additional 15 lakes. Researchers suspected that the effect of lime might depend upon the buffering effects of the underlying bedrock. To assess this hypothesis, the 30 lakes were chosen such that 10 had limestone bedrock, 10 had granite bedrock, and 10 had shist bedrock. pH was measured before and after each application, and the difference in pH is recorded in the file “acidityData.csv.” Intro aov Follow-up Graphics 15 / 15
  • 20. In-class exercise Fictitious Scenario Acid rain has lowered the pH of many lakes in the northeastern United States, and as a result, fish populations have declined. Managers have resorted to aerial applications of lime (powdered calcium carbonate) in hopes of increasing pH. To determine if lime applications result in increased pH, they applied equal amounts of lime to 15 lakes, and as a control, they applied the same amount of inert white powder to an additional 15 lakes. Researchers suspected that the effect of lime might depend upon the buffering effects of the underlying bedrock. To assess this hypothesis, the 30 lakes were chosen such that 10 had limestone bedrock, 10 had granite bedrock, and 10 had shist bedrock. pH was measured before and after each application, and the difference in pH is recorded in the file “acidityData.csv.” Questions 1 What are the null and alternative hypotheses? 2 Test the null hypotheses using an A × B factorial ANOVA implemented with aov . Create an ANOVA table using summary . 3 Does the effect of lime depend upon the bedrock type? If so, how? Answer this question by plotting the estimates of the effect of lime on pH change. Include 95% confidence intervals. Intro aov Follow-up Graphics 15 / 15
  • 21. In-class exercise Fictitious Scenario Acid rain has lowered the pH of many lakes in the northeastern United States, and as a result, fish populations have declined. Managers have resorted to aerial applications of lime (powdered calcium carbonate) in hopes of increasing pH. To determine if lime applications result in increased pH, they applied equal amounts of lime to 15 lakes, and as a control, they applied the same amount of inert white powder to an additional 15 lakes. Researchers suspected that the effect of lime might depend upon the buffering effects of the underlying bedrock. To assess this hypothesis, the 30 lakes were chosen such that 10 had limestone bedrock, 10 had granite bedrock, and 10 had shist bedrock. pH was measured before and after each application, and the difference in pH is recorded in the file “acidityData.csv.” Questions 1 What are the null and alternative hypotheses? 2 Test the null hypotheses using an A × B factorial ANOVA implemented with aov . Create an ANOVA table using summary . 3 Does the effect of lime depend upon the bedrock type? If so, how? Answer this question by plotting the estimates of the effect of lime on pH change. Include 95% confidence intervals. Put your answers in a self-contained R script, and upload the script to ELC at least one day before your next lab. Intro aov Follow-up Graphics 15 / 15