Replication and blocking

Experimental Design in R

Joanne Xiong

Data Scientist

Replication

  • Must repeat an experiment to fully assess variability
  • If we only conduct a drug efficacy experiment on one person, how can we properly generalize those results? (We can't!)
library(dplyr)
mtcars %>%
    count(cyl)
    cyl  n
1   4     11
2   6      7
3   8     14
Experimental Design in R

Blocking

  • Helps control variability by making treatment groups more alike
  • Inside of groups, differences will be minimal. Across groups, differences will be larger
  • One example is blocking treatment groups by sex
Experimental Design in R

Boxplots

# Boxplot of MPG by Car Cylinders
ggplot(mtcars, aes(x=as.factor(cyl), 
                   y=mpg)) + 
  geom_boxplot(fill="slateblue", 
               alpha=0.2) + 
  xlab("cyl")

alt text

Experimental Design in R

Functions for modeling

  • Linear models
    lm(formula, data, na.action,...)
    
  • One-way ANOVA model
    aov(formula, data = NULL, ...)
    
  • Nested ANOVA model
    anova(object,...)
    
Experimental Design in R

Let's practice!

Experimental Design in R

Preparing Video For Download...