Exercise: Analysis and power simulation for baseline/follow-up measurements ================ ## MASS anorexia data Data preparation ``` r data(anorexia, package = "MASS") dat <- subset(anorexia, Treat != "Cont") |> # exclude control group droplevels() # drop empty factor levels lbs2kg <- 0.4535924 dat$Prewt <- lbs2kg * dat$Prewt # to kg dat$Postwt <- lbs2kg * dat$Postwt lattice::xyplot(Postwt ~ Prewt, dat, groups = Treat, type = c("g", "r", "p"), auto.key = TRUE) ``` 1. Analyze the original data: - In R, see ?MASS::anorexia - Estimate the average treatment effect (ATE) for FT relative to CBT. - What is the 95% CI for the ATE? - What are the pre- and post-weight means for the two groups? - What are the baseline-adjusted means for the two groups? 2. Run a power simulation for a replication study: - Draw plausible pre-weights. - Specify the minimum relevant effect. - Set the remaining parameters to plausible values. - What is the sample size required for the test to detect the effect with 80% power? - How robust is the power simulation when you repeat it with a new set of pre-weights? Try it! - Recover the parameters of the ANCOVA model. 3. Create a renderable R script or an R Markdown file that includes - a header with title, author, date - at least one section head line - the homework questions and your answers - the R code, output, and plots (if any) Render the R or Rmd file to HTML.