diff --git a/01_intro/powersim-intro.pdf b/01_intro/powersim-intro.pdf index 9531ec0..bb2ddc4 100644 Binary files a/01_intro/powersim-intro.pdf and b/01_intro/powersim-intro.pdf differ diff --git a/03_anova/powersim-anova.md b/03_anova/powersim-anova.md index 5e5761d..e518c24 100644 --- a/03_anova/powersim-anova.md +++ b/03_anova/powersim-anova.md @@ -35,7 +35,7 @@ dat <- data.frame( A = factor(rep(1:2, each = n/2), labels = c("low", "high")), B = factor(rep(rep(1:2, each = n/4), 2), labels = c("low", "high")) ) -X <- model.matrix(~ A*B, dat) +X <- model.matrix(~ A * B, dat) unique(X) ``` @@ -73,7 +73,7 @@ boxplot(t(out)) ``` r pval <- replicate(2000, { y <- means + rnorm(n, sd = 10) - m <- aov(y ~ A*B, dat) + m <- aov(y ~ A * B, dat) summary(m)[[1]]$"Pr(>F)"[3] # test of interaction }) mean(pval < 0.05) diff --git a/04_ancova/exercises-ancova2.md b/04_ancova/exercises-ancova2.md index 8a26156..7ba5699 100644 --- a/04_ancova/exercises-ancova2.md +++ b/04_ancova/exercises-ancova2.md @@ -4,9 +4,7 @@ measurements ## MASS anorexia data -1. Analyze the original data: - - In R, see ?MASS::anorexia - - Data preparation +Data preparation ``` r data(anorexia, package = "MASS") @@ -20,11 +18,13 @@ lattice::xyplot(Postwt ~ Prewt, dat, groups = Treat, type = c("g", "r", "p"), auto.key = TRUE) ``` -- 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? - +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. @@ -41,5 +41,3 @@ lattice::xyplot(Postwt ~ Prewt, dat, groups = Treat, - the R code, output, and plots (if any) Render the R or Rmd file to HTML. - -### Reference diff --git a/04_ancova/intro-ancova.pdf b/04_ancova/intro-ancova.pdf index c9da59d..c8581d8 100644 Binary files a/04_ancova/intro-ancova.pdf and b/04_ancova/intro-ancova.pdf differ diff --git a/05_mixed1/intro-lmm.pdf b/05_mixed1/intro-lmm.pdf index f1e4113..ba7cf61 100644 Binary files a/05_mixed1/intro-lmm.pdf and b/05_mixed1/intro-lmm.pdf differ diff --git a/05_mixed1/powersim-lmm.md b/05_mixed1/powersim-lmm.md index a0fc3b9..c6b596b 100644 --- a/05_mixed1/powersim-lmm.md +++ b/05_mixed1/powersim-lmm.md @@ -3,8 +3,8 @@ Power for mixed-effects models Last modified: 2026-01-09 ``` r -library(lattice) -library(lme4) +library("lattice") +library("lme4") ``` # Reanalysis diff --git a/06_mixed2/exercises-datsimlmm.md b/06_mixed2/exercises-datsimlmm.md index aa653f4..d8e26d0 100644 --- a/06_mixed2/exercises-datsimlmm.md +++ b/06_mixed2/exercises-datsimlmm.md @@ -8,8 +8,8 @@ Exercises: Data simulation for crossed random-effects models “manually” ``` r -library(lattice) -library(lme4) +library("lattice") +library("lme4") #--------------- (1) Create data frame ---------------------------------------- datsim <- expand.grid(subject = factor(c("s1" , "s2" , "s3" )), @@ -40,9 +40,9 @@ e <- rnorm(18, mean = 0, sd = se) sig <- matrix(c(sy0^2, ry * sy0 * sy1, ry * sy0 * sy1, sy1^2), 2, 2) y01 <- MASS::mvrnorm(3, mu = c(0, 0), Sigma = sig) y0 <- rep(y01[,1], each = 6) -y1 <- rep(c(0, y01[1,2], - 0, y01[2,2], - 0, y01[3,2]), each = 3) +y1 <- rep(c(0, y01[1, 2], + 0, y01[2, 2], + 0, y01[3, 2]), each = 3) datsim$rt <- b0 + b1 + w + y0 + y1 + e diff --git a/06_mixed2/intro-datsimlmm.pdf b/06_mixed2/intro-datsimlmm.pdf index c7aef9c..ba3dd91 100644 Binary files a/06_mixed2/intro-datsimlmm.pdf and b/06_mixed2/intro-datsimlmm.pdf differ diff --git a/README.md b/README.md index 93b92a2..58ef581 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -Power simulations +Methods Workshop WS 2025/26: Power simulations ================ -Nora Wickelmaier January, 21-22, 2026 ## Schedule