SlideShare a Scribd company logo
1 of 25
Download to read offline
Lab 6 – Randomized Complete Block Design
September 24 & 25, 2018
FANR 6750
Richard Chandler and Bob Cooper
Recap
Like one-way ANOVA but experimental units are organized
into blocks to account for extraneous sources of variation
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
Recap
Like one-way ANOVA but experimental units are organized
into blocks to account for extraneous sources of variation
Blocks could be regions, time periods, individual subjects,
etc. . .
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
Recap
Like one-way ANOVA but experimental units are organized
into blocks to account for extraneous sources of variation
Blocks could be regions, time periods, individual subjects,
etc. . .
Blocking must occur during the design phase of the study
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
Recap
Like one-way ANOVA but experimental units are organized
into blocks to account for extraneous sources of variation
Blocks could be regions, time periods, individual subjects,
etc. . .
Blocking must occur during the design phase of the study
Additive model:
yij = µ + αi + βj + εij
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
Gypsy Moth Data
gypsyData <- read.csv("gypsyData.csv")
gypsyData$region <- factor(gypsyData$region)
gypsyData
## caterpillars pesticide region
## 1 16 Bt 1
## 2 3 Bt 2
## 3 10 Bt 3
## 4 18 Bt 4
## 5 25 Control 1
## 6 10 Control 2
## 7 15 Control 3
## 8 32 Control 4
## 9 14 Dimilin 1
## 10 2 Dimilin 2
## 11 16 Dimilin 3
## 12 12 Dimilin 4
Note: Numeric grouping variables must be coded as factors.
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 3 / 14
Compute the means
Grand mean (¯y.)
caterpillars <- gypsyData$caterpillars
(grand.mean <- mean(caterpillars))
## [1] 14.41667
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 4 / 14
Compute the means
Grand mean (¯y.)
caterpillars <- gypsyData$caterpillars
(grand.mean <- mean(caterpillars))
## [1] 14.41667
Treatment means (¯yi)
pesticide <- gypsyData$pesticide
(treatment.means <- tapply(caterpillars, pesticide, mean))
## Bt Control Dimilin
## 11.75 20.50 11.00
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 4 / 14
Compute the means
Grand mean (¯y.)
caterpillars <- gypsyData$caterpillars
(grand.mean <- mean(caterpillars))
## [1] 14.41667
Treatment means (¯yi)
pesticide <- gypsyData$pesticide
(treatment.means <- tapply(caterpillars, pesticide, mean))
## Bt Control Dimilin
## 11.75 20.50 11.00
Block means (¯yj)
region <- gypsyData$region
(block.means <- tapply(caterpillars, region, mean))
## 1 2 3 4
## 18.33333 5.00000 13.66667 20.66667
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 4 / 14
Treatment sums-of-squares
b ×
a
i=1
(¯yi − ¯y.)2
b <- 4
b <- nlevels(region)
SS.treat <- b*sum((treatment.means - grand.mean)^2)
SS.treat
## [1] 223.1667
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 5 / 14
Block sums-of-squares
a ×
b
j=1
(¯yj − ¯y.)2
a <- nlevels(pesticide)
SS.block <- a*sum((block.means - grand.mean)^2)
SS.block
## [1] 430.9167
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 6 / 14
Within groups sums-of-squares
a
i=1
b
j=1
(yij − ¯yi − ¯yj + ¯y.)2
treatment.means.long <- rep(treatment.means, each=b)
block.means.long <- rep(block.means, times=a)
SS.within <- sum((caterpillars - treatment.means.long -
block.means.long + grand.mean)^2)
SS.within
## [1] 114.8333
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 7 / 14
Within groups sums-of-squares
a
i=1
b
j=1
(yij − ¯yi − ¯yj + ¯y.)2
treatment.means.long <- rep(treatment.means, each=b)
block.means.long <- rep(block.means, times=a)
SS.within <- sum((caterpillars - treatment.means.long -
block.means.long + grand.mean)^2)
SS.within
## [1] 114.8333
NOTE: For this to work, treatment.means and block.means
must be in the same order as in the original data.
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 7 / 14
Create ANOVA table
df.treat <- a-1
df.block <- b-1
df.within <- df.treat*df.block
ANOVAtable <- data.frame(
df = c(df.treat, df.block, df.within),
SS = c(SS.treat, SS.block, SS.within))
rownames(ANOVAtable) <- c("Treatment", "Block", "Within")
ANOVAtable
## df SS
## Treatment 2 223.1667
## Block 3 430.9167
## Within 6 114.8333
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 8 / 14
Create ANOVA table, continued. . .
Mean squares
MSE <- ANOVAtable$SS / ANOVAtable$df
ANOVAtable$MSE <- MSE
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 9 / 14
Create ANOVA table, continued. . .
Mean squares
MSE <- ANOVAtable$SS / ANOVAtable$df
ANOVAtable$MSE <- MSE
F values
F <- c(MSE[1]/MSE[3], MSE[2]/MSE[3], NA)
ANOVAtable$F <- F
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 9 / 14
Create ANOVA table, continued. . .
Mean squares
MSE <- ANOVAtable$SS / ANOVAtable$df
ANOVAtable$MSE <- MSE
F values
F <- c(MSE[1]/MSE[3], MSE[2]/MSE[3], NA)
ANOVAtable$F <- F
P-values
P <- c(1 - pf(F[1], 2, 6), 1 - pf(F[2], 3, 6), NA)
ANOVAtable$P <- P
round(ANOVAtable, 3)
## df SS MSE F P
## Treatment 2 223.167 111.583 5.830 0.039
## Block 3 430.917 143.639 7.505 0.019
## Within 6 114.833 19.139 NA NA
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 9 / 14
Reminder about P-values
Critical value
qf(0.95, df1=2, df2=6) # 95% of the distribution is before this value of F
## [1] 5.143253
P-value
1-pf(F[1], df1=2, df2=6) # Proportion of the distribution beyond this F value
## [1] 0.03921514
0 2 4 6 8 10
0.00.20.40.60.81.0
F
critical value
F−value
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 10 / 14
Using aov
aov1 <- aov(caterpillars ~ pesticide + region, gypsyData)
summary(aov1)
## Df Sum Sq Mean Sq F value Pr(>F)
## pesticide 2 223.2 111.58 5.830 0.0392 *
## region 3 430.9 143.64 7.505 0.0187 *
## Residuals 6 114.8 19.14
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 11 / 14
Using aov
aov1 <- aov(caterpillars ~ pesticide + region, gypsyData)
summary(aov1)
## Df Sum Sq Mean Sq F value Pr(>F)
## pesticide 2 223.2 111.58 5.830 0.0392 *
## region 3 430.9 143.64 7.505 0.0187 *
## Residuals 6 114.8 19.14
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' '
round(ANOVAtable, 3)
## df SS MSE F P
## Treatment 2 223.167 111.583 5.830 0.039
## Block 3 430.917 143.639 7.505 0.019
## Within 6 114.833 19.139 NA NA
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 11 / 14
Using aov
Look what happens if we ignore the blocking variable
aov2 <- aov(caterpillars ~ pesticide, gypsyData)
summary(aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## pesticide 2 223.2 111.58 1.84 0.214
## Residuals 9 545.8 60.64
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 12 / 14
Using aov
Look what happens if we ignore the blocking variable
aov2 <- aov(caterpillars ~ pesticide, gypsyData)
summary(aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## pesticide 2 223.2 111.58 1.84 0.214
## Residuals 9 545.8 60.64
Why is the effect of pesticide no longer significant?
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 12 / 14
Treating block effects as random effects
aov3 <- aov(caterpillars ~ pesticide + Error(region), gypsyData)
summary(aov3)
##
## Error: region
## Df Sum Sq Mean Sq F value Pr(>F)
## Residuals 3 430.9 143.6
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## pesticide 2 223.2 111.58 5.83 0.0392 *
## Residuals 6 114.8 19.14
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 13 / 14
Treating block effects as random effects
aov3 <- aov(caterpillars ~ pesticide + Error(region), gypsyData)
summary(aov3)
##
## Error: region
## Df Sum Sq Mean Sq F value Pr(>F)
## Residuals 3 430.9 143.6
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## pesticide 2 223.2 111.58 5.83 0.0392 *
## Residuals 6 114.8 19.14
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The values of the ANOVA table are the same as before, and there is no reason
to use random effects here if interest only lies in testing the null hypothesis
concerning pesticides. Later, we will see cases where it is important to use
random and fixed effects.
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 13 / 14
Assignment: Due before lab next week
Plantations of Pinus caribaea were established at four locations on Puerto Rico. Four spacings were used at each
location to determine the effect of stocking density on tree height. Twenty years after the plantations were
established, the following tree heights were recorded:
Location Spacing (ft) Height (ft)
Caracoles 5 72
7 80
10 85
14 91
Utado 5 75
7 90
10 94
14 112
Guzman 5 88
7 95
10 94
14 91
Lares 5 79
7 94
10 104
14 106
Create an R script to the address the following:
(1) What are the null and alternative hypotheses?.
(2) Test for effects of location and spacing on plant height using the aov function. Do the ANOVA again but
without aov . Treat the block effects as fixed, not random. HINTS:
Spacing must be treated as a factor.
You must put the group means and block means in the correct order when computing the
sums-of-squares.
(3) Perform a Tukey test to determine which spacings differ.
(4) Summarize the main results in 2-3 sentences. Upload the script to ELC the day before your next lab.
Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 14 / 14

More Related Content

Similar to Blocking lab

Biom-33-GxE II.ppt
Biom-33-GxE II.pptBiom-33-GxE II.ppt
Biom-33-GxE II.pptbirhankassa
 
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
 
Variant calling v4
Variant calling v4Variant calling v4
Variant calling v4Shaojun Xie
 
QM-013-DOE Introduction
QM-013-DOE IntroductionQM-013-DOE Introduction
QM-013-DOE Introductionhandbook
 
Lab on contrasts, estimation, and power
Lab on contrasts, estimation, and powerLab on contrasts, estimation, and power
Lab on contrasts, estimation, and powerrichardchandler
 

Similar to Blocking lab (9)

Biom-33-GxE II.ppt
Biom-33-GxE II.pptBiom-33-GxE II.ppt
Biom-33-GxE II.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...
 
Split-plot Designs
Split-plot DesignsSplit-plot Designs
Split-plot Designs
 
20120423.NGS.Rennes
20120423.NGS.Rennes20120423.NGS.Rennes
20120423.NGS.Rennes
 
Variant calling v4
Variant calling v4Variant calling v4
Variant calling v4
 
QM-013-DOE Introduction
QM-013-DOE IntroductionQM-013-DOE Introduction
QM-013-DOE Introduction
 
Lab on contrasts, estimation, and power
Lab on contrasts, estimation, and powerLab on contrasts, estimation, and power
Lab on contrasts, estimation, and power
 
Anova; analysis of variance
Anova; analysis of varianceAnova; analysis of variance
Anova; analysis of variance
 
Analysis of variance
Analysis of varianceAnalysis of variance
Analysis of variance
 

More from richardchandler

Model Selection and Multi-model Inference
Model Selection and Multi-model InferenceModel Selection and Multi-model Inference
Model Selection and Multi-model Inferencerichardchandler
 
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 (9)

Model Selection and Multi-model Inference
Model Selection and Multi-model InferenceModel Selection and Multi-model Inference
Model Selection and Multi-model Inference
 
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

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
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
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
 
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
 
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
 
Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)DHURKADEVIBASKAR
 
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tantaDashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tantaPraksha3
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
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
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsssuserddc89b
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
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
 
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
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sé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
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PPRINCE C P
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 

Recently uploaded (20)

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
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
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) |
 
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
 
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
 
Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)
 
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tantaDashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
Dashanga agada a formulation of Agada tantra dealt in 3 Rd year bams agada tanta
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physics
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
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.
 
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
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
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...
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C P
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 

Blocking lab

  • 1. Lab 6 – Randomized Complete Block Design September 24 & 25, 2018 FANR 6750 Richard Chandler and Bob Cooper
  • 2. Recap Like one-way ANOVA but experimental units are organized into blocks to account for extraneous sources of variation Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
  • 3. Recap Like one-way ANOVA but experimental units are organized into blocks to account for extraneous sources of variation Blocks could be regions, time periods, individual subjects, etc. . . Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
  • 4. Recap Like one-way ANOVA but experimental units are organized into blocks to account for extraneous sources of variation Blocks could be regions, time periods, individual subjects, etc. . . Blocking must occur during the design phase of the study Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
  • 5. Recap Like one-way ANOVA but experimental units are organized into blocks to account for extraneous sources of variation Blocks could be regions, time periods, individual subjects, etc. . . Blocking must occur during the design phase of the study Additive model: yij = µ + αi + βj + εij Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 2 / 14
  • 6. Gypsy Moth Data gypsyData <- read.csv("gypsyData.csv") gypsyData$region <- factor(gypsyData$region) gypsyData ## caterpillars pesticide region ## 1 16 Bt 1 ## 2 3 Bt 2 ## 3 10 Bt 3 ## 4 18 Bt 4 ## 5 25 Control 1 ## 6 10 Control 2 ## 7 15 Control 3 ## 8 32 Control 4 ## 9 14 Dimilin 1 ## 10 2 Dimilin 2 ## 11 16 Dimilin 3 ## 12 12 Dimilin 4 Note: Numeric grouping variables must be coded as factors. Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 3 / 14
  • 7. Compute the means Grand mean (¯y.) caterpillars <- gypsyData$caterpillars (grand.mean <- mean(caterpillars)) ## [1] 14.41667 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 4 / 14
  • 8. Compute the means Grand mean (¯y.) caterpillars <- gypsyData$caterpillars (grand.mean <- mean(caterpillars)) ## [1] 14.41667 Treatment means (¯yi) pesticide <- gypsyData$pesticide (treatment.means <- tapply(caterpillars, pesticide, mean)) ## Bt Control Dimilin ## 11.75 20.50 11.00 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 4 / 14
  • 9. Compute the means Grand mean (¯y.) caterpillars <- gypsyData$caterpillars (grand.mean <- mean(caterpillars)) ## [1] 14.41667 Treatment means (¯yi) pesticide <- gypsyData$pesticide (treatment.means <- tapply(caterpillars, pesticide, mean)) ## Bt Control Dimilin ## 11.75 20.50 11.00 Block means (¯yj) region <- gypsyData$region (block.means <- tapply(caterpillars, region, mean)) ## 1 2 3 4 ## 18.33333 5.00000 13.66667 20.66667 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 4 / 14
  • 10. Treatment sums-of-squares b × a i=1 (¯yi − ¯y.)2 b <- 4 b <- nlevels(region) SS.treat <- b*sum((treatment.means - grand.mean)^2) SS.treat ## [1] 223.1667 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 5 / 14
  • 11. Block sums-of-squares a × b j=1 (¯yj − ¯y.)2 a <- nlevels(pesticide) SS.block <- a*sum((block.means - grand.mean)^2) SS.block ## [1] 430.9167 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 6 / 14
  • 12. Within groups sums-of-squares a i=1 b j=1 (yij − ¯yi − ¯yj + ¯y.)2 treatment.means.long <- rep(treatment.means, each=b) block.means.long <- rep(block.means, times=a) SS.within <- sum((caterpillars - treatment.means.long - block.means.long + grand.mean)^2) SS.within ## [1] 114.8333 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 7 / 14
  • 13. Within groups sums-of-squares a i=1 b j=1 (yij − ¯yi − ¯yj + ¯y.)2 treatment.means.long <- rep(treatment.means, each=b) block.means.long <- rep(block.means, times=a) SS.within <- sum((caterpillars - treatment.means.long - block.means.long + grand.mean)^2) SS.within ## [1] 114.8333 NOTE: For this to work, treatment.means and block.means must be in the same order as in the original data. Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 7 / 14
  • 14. Create ANOVA table df.treat <- a-1 df.block <- b-1 df.within <- df.treat*df.block ANOVAtable <- data.frame( df = c(df.treat, df.block, df.within), SS = c(SS.treat, SS.block, SS.within)) rownames(ANOVAtable) <- c("Treatment", "Block", "Within") ANOVAtable ## df SS ## Treatment 2 223.1667 ## Block 3 430.9167 ## Within 6 114.8333 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 8 / 14
  • 15. Create ANOVA table, continued. . . Mean squares MSE <- ANOVAtable$SS / ANOVAtable$df ANOVAtable$MSE <- MSE Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 9 / 14
  • 16. Create ANOVA table, continued. . . Mean squares MSE <- ANOVAtable$SS / ANOVAtable$df ANOVAtable$MSE <- MSE F values F <- c(MSE[1]/MSE[3], MSE[2]/MSE[3], NA) ANOVAtable$F <- F Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 9 / 14
  • 17. Create ANOVA table, continued. . . Mean squares MSE <- ANOVAtable$SS / ANOVAtable$df ANOVAtable$MSE <- MSE F values F <- c(MSE[1]/MSE[3], MSE[2]/MSE[3], NA) ANOVAtable$F <- F P-values P <- c(1 - pf(F[1], 2, 6), 1 - pf(F[2], 3, 6), NA) ANOVAtable$P <- P round(ANOVAtable, 3) ## df SS MSE F P ## Treatment 2 223.167 111.583 5.830 0.039 ## Block 3 430.917 143.639 7.505 0.019 ## Within 6 114.833 19.139 NA NA Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 9 / 14
  • 18. Reminder about P-values Critical value qf(0.95, df1=2, df2=6) # 95% of the distribution is before this value of F ## [1] 5.143253 P-value 1-pf(F[1], df1=2, df2=6) # Proportion of the distribution beyond this F value ## [1] 0.03921514 0 2 4 6 8 10 0.00.20.40.60.81.0 F critical value F−value Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 10 / 14
  • 19. Using aov aov1 <- aov(caterpillars ~ pesticide + region, gypsyData) summary(aov1) ## Df Sum Sq Mean Sq F value Pr(>F) ## pesticide 2 223.2 111.58 5.830 0.0392 * ## region 3 430.9 143.64 7.505 0.0187 * ## Residuals 6 114.8 19.14 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 11 / 14
  • 20. Using aov aov1 <- aov(caterpillars ~ pesticide + region, gypsyData) summary(aov1) ## Df Sum Sq Mean Sq F value Pr(>F) ## pesticide 2 223.2 111.58 5.830 0.0392 * ## region 3 430.9 143.64 7.505 0.0187 * ## Residuals 6 114.8 19.14 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' round(ANOVAtable, 3) ## df SS MSE F P ## Treatment 2 223.167 111.583 5.830 0.039 ## Block 3 430.917 143.639 7.505 0.019 ## Within 6 114.833 19.139 NA NA Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 11 / 14
  • 21. Using aov Look what happens if we ignore the blocking variable aov2 <- aov(caterpillars ~ pesticide, gypsyData) summary(aov2) ## Df Sum Sq Mean Sq F value Pr(>F) ## pesticide 2 223.2 111.58 1.84 0.214 ## Residuals 9 545.8 60.64 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 12 / 14
  • 22. Using aov Look what happens if we ignore the blocking variable aov2 <- aov(caterpillars ~ pesticide, gypsyData) summary(aov2) ## Df Sum Sq Mean Sq F value Pr(>F) ## pesticide 2 223.2 111.58 1.84 0.214 ## Residuals 9 545.8 60.64 Why is the effect of pesticide no longer significant? Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 12 / 14
  • 23. Treating block effects as random effects aov3 <- aov(caterpillars ~ pesticide + Error(region), gypsyData) summary(aov3) ## ## Error: region ## Df Sum Sq Mean Sq F value Pr(>F) ## Residuals 3 430.9 143.6 ## ## Error: Within ## Df Sum Sq Mean Sq F value Pr(>F) ## pesticide 2 223.2 111.58 5.83 0.0392 * ## Residuals 6 114.8 19.14 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 13 / 14
  • 24. Treating block effects as random effects aov3 <- aov(caterpillars ~ pesticide + Error(region), gypsyData) summary(aov3) ## ## Error: region ## Df Sum Sq Mean Sq F value Pr(>F) ## Residuals 3 430.9 143.6 ## ## Error: Within ## Df Sum Sq Mean Sq F value Pr(>F) ## pesticide 2 223.2 111.58 5.83 0.0392 * ## Residuals 6 114.8 19.14 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 The values of the ANOVA table are the same as before, and there is no reason to use random effects here if interest only lies in testing the null hypothesis concerning pesticides. Later, we will see cases where it is important to use random and fixed effects. Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 13 / 14
  • 25. Assignment: Due before lab next week Plantations of Pinus caribaea were established at four locations on Puerto Rico. Four spacings were used at each location to determine the effect of stocking density on tree height. Twenty years after the plantations were established, the following tree heights were recorded: Location Spacing (ft) Height (ft) Caracoles 5 72 7 80 10 85 14 91 Utado 5 75 7 90 10 94 14 112 Guzman 5 88 7 95 10 94 14 91 Lares 5 79 7 94 10 104 14 106 Create an R script to the address the following: (1) What are the null and alternative hypotheses?. (2) Test for effects of location and spacing on plant height using the aov function. Do the ANOVA again but without aov . Treat the block effects as fixed, not random. HINTS: Spacing must be treated as a factor. You must put the group means and block means in the correct order when computing the sums-of-squares. (3) Perform a Tukey test to determine which spacings differ. (4) Summarize the main results in 2-3 sentences. Upload the script to ELC the day before your next lab. Recap Blocked ANOVA “By Hand” Blocked ANOVA Using aov 14 / 14