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")),
|
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"))
|
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)
|
unique(X)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ boxplot(t(out))
|
|||||||
``` r
|
``` r
|
||||||
pval <- replicate(2000, {
|
pval <- replicate(2000, {
|
||||||
y <- means + rnorm(n, sd = 10)
|
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
|
summary(m)[[1]]$"Pr(>F)"[3] # test of interaction
|
||||||
})
|
})
|
||||||
mean(pval < 0.05)
|
mean(pval < 0.05)
|
||||||
|
|||||||
@ -4,9 +4,7 @@ measurements
|
|||||||
|
|
||||||
## MASS anorexia data
|
## MASS anorexia data
|
||||||
|
|
||||||
1. Analyze the original data:
|
Data preparation
|
||||||
- In R, see ?MASS::anorexia
|
|
||||||
- Data preparation
|
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
data(anorexia, package = "MASS")
|
data(anorexia, package = "MASS")
|
||||||
@ -20,11 +18,13 @@ lattice::xyplot(Postwt ~ Prewt, dat, groups = Treat,
|
|||||||
type = c("g", "r", "p"), auto.key = TRUE)
|
type = c("g", "r", "p"), auto.key = TRUE)
|
||||||
```
|
```
|
||||||
|
|
||||||
- Estimate the average treatment effect (ATE) for FT relative to CBT.
|
1. Analyze the original data:
|
||||||
- What is the 95% CI for the ATE?
|
- In R, see ?MASS::anorexia
|
||||||
- What are the pre- and post-weight means for the two groups?
|
- Estimate the average treatment effect (ATE) for FT relative to
|
||||||
- What are the baseline-adjusted means for the two groups?
|
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:
|
2. Run a power simulation for a replication study:
|
||||||
- Draw plausible pre-weights.
|
- Draw plausible pre-weights.
|
||||||
- Specify the minimum relevant effect.
|
- Specify the minimum relevant effect.
|
||||||
@ -41,5 +41,3 @@ lattice::xyplot(Postwt ~ Prewt, dat, groups = Treat,
|
|||||||
- the R code, output, and plots (if any)
|
- the R code, output, and plots (if any)
|
||||||
|
|
||||||
Render the R or Rmd file to HTML.
|
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
|
Last modified: 2026-01-09
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
library(lattice)
|
library("lattice")
|
||||||
library(lme4)
|
library("lme4")
|
||||||
```
|
```
|
||||||
|
|
||||||
# Reanalysis
|
# Reanalysis
|
||||||
|
|||||||
@ -8,8 +8,8 @@ Exercises: Data simulation for crossed random-effects models
|
|||||||
“manually”
|
“manually”
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
library(lattice)
|
library("lattice")
|
||||||
library(lme4)
|
library("lme4")
|
||||||
|
|
||||||
#--------------- (1) Create data frame ----------------------------------------
|
#--------------- (1) Create data frame ----------------------------------------
|
||||||
datsim <- expand.grid(subject = factor(c("s1" , "s2" , "s3" )),
|
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)
|
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)
|
y01 <- MASS::mvrnorm(3, mu = c(0, 0), Sigma = sig)
|
||||||
y0 <- rep(y01[,1], each = 6)
|
y0 <- rep(y01[,1], each = 6)
|
||||||
y1 <- rep(c(0, y01[1,2],
|
y1 <- rep(c(0, y01[1, 2],
|
||||||
0, y01[2,2],
|
0, y01[2, 2],
|
||||||
0, y01[3,2]), each = 3)
|
0, y01[3, 2]), each = 3)
|
||||||
|
|
||||||
datsim$rt <- b0 + b1 + w + y0 + y1 + e
|
datsim$rt <- b0 + b1 + w + y0 + y1 + e
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user