Update title in README; rebuild
This commit is contained in:
parent
d411821974
commit
f029510984
Binary file not shown.
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -3,8 +3,8 @@ Power for mixed-effects models
|
||||
Last modified: 2026-01-09
|
||||
|
||||
``` r
|
||||
library(lattice)
|
||||
library(lme4)
|
||||
library("lattice")
|
||||
library("lme4")
|
||||
```
|
||||
|
||||
# Reanalysis
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user