Generates one long-format dataset from a balanced design. Supply means from
design_term_means() or any conformable matrix with one row per
between-subject cell and one column per within-subject cell.
Arguments
- design
An
anovapowersim_design_specfrombalanced_anova_design().- n
Sample size per between-subject cell. For pure within designs, this is the total sample size.
- means
Numeric matrix of population cell means.
- sd
Common outcome standard deviation.
- r
Compound-symmetric correlation among within-subject cells.
- empirical
Logical; if
TRUE, useMASS::mvrnorm(empirical = TRUE)so the generated sample closely matches the requested means/covariance.
Value
A tibble ready for stats::aov() with columns id, factor
columns, and value.
Examples
d <- balanced_anova_design(between = c(group = 2), within = c(time = 2))
m <- design_term_means(d, term = "group:time", target_pes = 0.2, n = 20)
sim <- simulate_design_dataset(d, n = 20, means = m)
head(sim)
#> # A tibble: 6 × 4
#> id group value time
#> <fct> <fct> <dbl> <fct>
#> 1 1 group1 -1.44 time1
#> 2 1 group1 0.0702 time2
#> 3 2 group1 -0.660 time1
#> 4 2 group1 -1.30 time2
#> 5 3 group1 -0.724 time1
#> 6 3 group1 1.35 time2