November 18, 2021

Announcements

  • HW 8 due tomorrow Nov 19 11:55p
  • MP2 Pre-approval due TUESDAY Nov 23 at 11:55p
  • Zoom Office hours
    • Friday 1:30-3:30p
    • Slots now open!
  • Where to get HW help
    • Spinelli center tutoring Sun-Thurs 7-9p, Sabin-Reed 301.
    • Post questions to #homework8-questions channel on Slack!
    • Direct message me on Slack.
  • SDS Graduate School PanelNov 22 7-8p via Zoom
    • See Moodle for more details.
  • Thank you for your help with Biostats candidates!

Agenda

  1. Levene’s Test
  2. Multiple comparisons
  3. Repeated measures
  4. MP2 work time

Example: Walking Babies

data("WalkingBabies")
ds <- WalkingBabies %>%
  group_by(Group) %>%
  summarize(n = n(),
            mean = mean(Age),
            sd = sd(Age))

ds
## # A tibble: 4 x 4
##   Group                 n  mean    sd
##   <fct>             <int> <dbl> <dbl>
## 1 exercise control      6  11.4 1.90 
## 2 final report          6  12.4 0.871
## 3 special exercises     6  10.1 1.45 
## 4 weekly report         6  11.6 1.56

Example: Walking Babies

ds %>%
  summarize(max(sd)/min(sd))
## # A tibble: 1 x 1
##   `max(sd)/min(sd)`
##               <dbl>
## 1              2.18

So we fail to meet the condition of equal variances? (The S condition)

Levene’s Test

The biggest SD not more than 2 times as large as the smallest SD is only a rule of thumb.

Levene’s test is an ANOVA to test the null hypothesis:

\[H_0 = \sigma^2_1=\sigma^2_2=\sigma^2_3=\sigma^2_4\] \[H_A= not\:all\:variances\:are\:equal\]

Levene’s Test in R

library(car)

leveneTest(Age ~ Group, data = WalkingBabies)
## Levene's Test for Homogeneity of Variance (center = median)
##       Df F value Pr(>F)
## group  3  0.3082 0.8191
##       20

Using Levene’s Test for homogeneity of variance, we fail to reject the null hypothesis, that is we fail to find evidence that the S condition is not met, \(F(3, 20)=0.31\), \(p = .819\). We can proceed as if this condition is met.

Levene’s Test for Factorial Data

Let’s try it for the PigFeed data.

data("PigFeed")
leveneTest(WgtGain ~ Antibiotic*B12, data = PigFeed)
## Levene's Test for Homogeneity of Variance (center = median)
##       Df F value Pr(>F)
## group  3  1.8089 0.2235
##        8

Using Levene’s Test for homogeneity of variance, we fail to reject the null hypothesis, that is we fail to find evidence that the S condition is not met, \(F(3, 8)=1.81\), \(p = .224\). We can proceed as if this condition is met.

Multiple Tests

data("Leafhoppers")
mod <- lm(Days ~ Diet, data = Leafhoppers)
anova(mod)
## Analysis of Variance Table
## 
## Response: Days
##           Df Sum Sq Mean Sq F value   Pr(>F)   
## Diet       3   3.92  1.3067  17.422 0.009248 **
## Residuals  4   0.30  0.0750                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Fisher’s LSD and Bonferroni Correction

library(agricolae)
LSD.test(mod, "Diet", p.adj = "none")$groups
##          Days groups
## Sucrose   3.8      a
## Glucose   2.8      b
## Fructose  2.2     bc
## Control   2.0      c
LSD.test(mod, "Diet", p.adj = "bonferroni")$groups
##          Days groups
## Sucrose   3.8      a
## Glucose   2.8     ab
## Fructose  2.2      b
## Control   2.0      b

Tukey’s HSD

mod <- aov(Days ~ Diet, data = Leafhoppers)
TukeyHSD(mod, "Diet")
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Days ~ Diet, data = Leafhoppers)
## 
## $Diet
##                  diff        lwr     upr     p adj
## Fructose-Control  0.2 -0.9148496 1.31485 0.8805808
## Glucose-Control   0.8 -0.3148496 1.91485 0.1337642
## Sucrose-Control   1.8  0.6851504 2.91485 0.0095276
## Glucose-Fructose  0.6 -0.5148496 1.71485 0.2677272
## Sucrose-Fructose  1.6  0.4851504 2.71485 0.0145912
## Sucrose-Glucose   1.0 -0.1148496 2.11485 0.0703156

Tuplips

A plant breeder wishes to study the effects of soil drainage and variety of tulip bulbs on flower production. Twelve 3m by 10m experimental sites are available in the test garden–each is a .5m deep trench. You can manipulate soil drainage by changing the ratio of sand to clay for the soil you put in a trench. After talking to your collaborator, you decided that four different levels of soil drainage would suffice. You’ll be testing 15 different types of tulips, and measuring flower production in the spring.

Repeated Measures

Between Subjects Design

Within Subjects Desgin (Complete Block Design)

Split-Plot Design

If you suspect a design in a split-plot design, you should be able to answer the following questions:

  1. What are the whole plots, that is, what is the nuisance factor?
  2. What is the between-blocks factor? Is it observational or experimental?
  3. What is the within-blocks factor? Is it observational or experimental?

Diabetic Dogs

The disease diabetes affects the rate of turnover of lactic acid in a system of biochemical reactions called the Cori cycle. This experiment compares two methods of using radioactive carbon-14 to measure rate of turnover. Method 1 is injection all at once, and method 2 is infused continuously. 10 dogs were sorted into two groups, 5 were controls and 5 had their pancreas removed (to make it diabetic). The rate of turnover was then measured twice for each dog, once for each method. The order of the two methods was randomly assigned.

Parsnip Plants

Under the control conditions of this study, wild parsnip plants averaged about a thousand seeds from their first set of flowers (primary umbels), about twice as many from the second set of flowers, but only about 250 from the third set. For plants attacked by the parsnip webworm, which destroyed most of the primary umbels, the pattern was quite different: the seed production from primary, secondary, and tertiary umbels averaged about 200, 2400, and 1300, respectively.

Formal ANOVA for the Split-Plot Design

\[{y}_{ijk}={\mu}+{\alpha}_{i}+{\beta}_{j(i)}+{\gamma}_{k}+({\alpha\gamma})_{ik}+{e}_{ijk}\]

  • \({\mu}\) is the benchmark
  • \({\alpha}_{i}\) effect of level i of the between-blocks factor, \(i\) from \(1\) to \(a\)
  • \({\beta}_{j(i)}\) effect of block \(j\) (for level \(i\) of the between block factor), \(j\) from \(1\) to \(n\)
  • \({\gamma}_{k}\) effect of level \(k\) of the within-block factor, \(k\) from \(1\) to \(t\)
  • \(({\alpha\gamma})_{ik}\) interaction effect for level \(i\) of the between-blocks factor with level \(k\) of the within-blocks factor

ANOVA Source Table for the Split-Plot Design

Source SS df MS F
Between \(t\frac{N}{a}\sum_{i=1}^{a}(\bar{y}_{i..}-\bar{y}_{...})^{2}\) \(a-1\) \(\frac{{SS}_{A}}{{df}_{A}}\) \(\frac{{MS}_{A}}{{MS}_{B}}\)
Blocks \(t\sum_{i=1}^{a}\sum_{j=1}^{n}(\bar{y}_{ij.}-\bar{y}_{i..})^{2}\) \(N-a\) \(\frac{{SS}_{B}}{{df}_{B}}\) \(\frac{{MS}_{B}}{{MS}_{E}}\)
Within \(Na\sum_{k=1}^{K}(\bar{y}_{..k}-\bar{y}_{...})^{2}\) \(t-1\) \(\frac{{SS}_{T}}{{df}_{T}}\) \(\frac{{MS}_{T}}{{MS}_{E}}\)
Interaction \(\sum_{i=1}^{a}\sum_{k=1}^{t}\frac{N}{a}(\bar{y}_{i.k}-\bar{y}_{i..}-\bar{y}_{..k}+\bar{y}_{...})^{2}\) \((a-1)(t-1)\) \(\frac{{SS}_{AT}}{{df}_{AT}}\) \(\frac{{MS}_{AT}}{{MS}_{E}}\)
Error \(\sum_{i=1}^{a}\sum_{j=1}^{N}\sum_{k=1}^{t}({y}_{ijk}-\bar{y}_{i.k}-\bar{y}_{.j.}-\bar{y}_{..k}+\bar{y}_{i..})^{2}\) \((N-a)(t-1)\) \(\frac{{SS}_{E}}{{df}_{E}}\)

Split-Plot Analysis in R

Crabgrass

The purpose of this experiment was to study the way one species of crabgrass competed with itself and with another species for nitrogen (N), phosphorus (P), and potassium (K). Bunches of crabgrass were planted in vermiculite, in 16 Styrofoam cups; after the seeds head sprouted, the plants were thinned to 20 plants per cup. Each of the 16 cups were randomly assigned to get one of 8 nutrient combinations added to its vermiculite. For example, yes-nitrogen/no-phosphorus/yes-potassium. The response is mean dry weight per plant, in milligrams.

Osomoregulation

Worms that live at the mouth of a river must deal with varying concentrations of salt. Osomoregulating worms are able to maintain relatively constant concentration of salt in the body. An experiment wanted to test the effects of mixtures of salt water on two species of worms: Nereis virens (N) and Goldfingia gouldii (G). Eighteen worms of each species were weighted, then randomly assigned in equal numbers to one of three conditions. Six worms of each kind were placed in 100% sea water, 67% sea water, or 33% sea water. The worms were then weighted after 30, 60, and 90 minutes, then placed in 100% sea water and weighted one last time 30 minutes later. The response was body weight as percentage of initial body weight.

Creepy Animals

The effects of exposure to images of different domestic animal species in either aggressive or submissive postures on mood was tested with a split-plot/repeated measures design. Using a computer to randomize, participants were randomly assigned to either view images of dogs or images of cats. All participants saw both an aggressive animal and a submissive animal, and their moods were assessed via self-report after each image. The order of presentation (aggressive then submission, or submissive then aggressive) was randomized to control for order effects.

MP2 Work Time!!

  • MP2 groups
  • Time to discuss your MP2 projects. Goals for today
    • Pre-approval surveys due on Tuesday Nov 23!!