Homework 6

Course

STAT218

Due

May 1, 2025

library(tidyverse)
library(effectsize)
library(emmeans)

In a study, female mice were randomly assigned to four treatment groups to investigate whether restricting dietary intake increases life expectancy:

  1. The longevity dataset contains observations of lifetime in weeks for 237 mice from the study described above. In this problem you’ll test whether diet restriction has an effect on longevity.

    1. Make side-by-side boxplots of the lifespan data in each treatment group. Assess whether the model assumptions for ANOVA seem plausible.
    2. Compute summary statistics by treatment group: sample means, standard deviations, sample sizes, and standard errors for the sample means.
    3. Test for an effect of diet restriction on mean lifespan. Interpret the result of the test in context following the narrative format from class.
    4. Estimate the effect size of diet restriction on mean lifespan; provide and interpret a (two-sided) 95% confidence interval.
# read in data and preview
load('data/longevity.RData')

# part a: side-by-side boxplots

# part b: summary statistics by treatment group

# part c: omnibus test for effect of diet on mean lifespan

# part d: estimate effect size
  1. [your answer here]
  2. (no written answer necessary)
  3. [your answer here]
  4. [your answer here]
  1. Imagine you are designing a follow up study on dietary restriction.

    1. If there are the same number of levels of dietary restriction as in the original study, how many mice per group would you need to detect an effect size of η2=0.2 80% of the time using a 5% level test?
    2. If there are only two levels of dietary restriction, and you want to detect a difference in mean lifespan of 1 week or more 90% of the time using a 5% level test, how many mice do you need in your study? (Round the largest standard deviation from the original study to the next nearest whole number for a conservative estimate.)
    3. If there are six levels of dietary restriction, how many mice per group would you need to detect an effet of the same magnitude as estimated in the original study 85% of the time with a 5% level test?
# part a: same number of levels, effect size 0.2

# part b: two levels, difference of 2 weeks

# part c: six levels, effect size same as in original study
  1. [your answer here]
  2. [your answer here]
  3. [your answer here]
  1. [Extra credit] Continuing to refer to the longevity study above, follow the example from lecture to compute interval estimates for log-contrasts and back-transform interval endpoints to obtain estimates for the percent change in median lifespan relative to the control group. Report the comparison between the normal (N/N85) diet and the unrestricted (NP) diet. (Note: log(...) in R computes the natural logarithm ln(x) by default; the function exp(...) computes the exponential ex by default; the two are inverses.)
# load data
load('data/longevity.RData')

# fit anova model to log lifetimes

# estimate contrasts with control

# back-transform point estimate for n85/np contrast

# back-transform interval estimates

[your answer here]

  1. The plantgrowth dataset includes measurements of dry weight of plants grown using one of two fertilizer treatments or no fertilizer (control); treatments were randomly allocated to plants.

    1. Construct side-by-side boxplots of the data to assess ANOVA model assumptions.
    2. Fit an ANOVA model and test for a difference in mean dry weight among treatment groups at the 5% significance level. Report the results in context following conventional style.
    3. Estimate the effect size of fertilizer treatments on dry weight; provide a two-sided 95% confidence interval and interpret the interval in context.
    4. Test for significant differences in mean dry weight between each treatment compared with the control at the 5% level. Identify any significant differences.
    5. How do you explain the apparent discrepancy between the omnibus test and the post-hoc comparisons?
# load and inspect data
load('data/plantgrowth.RData')

# construct side-by-side boxplots

# fit anova model and perform omnibus test

# estimate effect size

# test for contrasts with control
  1. [your answer here]
  2. [your answer here]
  3. [your answer here]
  4. [your answer here]
  5. [your answer here]

Footnotes

  1. Weindruch, R., Walford, R.L., Fligiel, S. and Guthrie D. (1986). The Retardation of Aging in Mice by Dietary Restriction: Longevity, Cancer, Immunity and Lifetime Energy Intake, Journal of Nutrition 116(4):641–54.↩︎