# 1. Plot prior to simulation to check data plausibility
design <- define_design(
id = "subject",
between = list(group = c("Control", "Treatment")),
within = list(time = c("pre", "post"))
)
fixed_effects <- list(
`(Intercept)` = 10,
groupTreatment = 2,
timepost = 1,
`groupTreatment:timepost` = 3
)
random_effects <- list(
subject = list(`(Intercept)` = 3),
sd_resid = 3
)
plot_sim_model(
y ~ group * time + (1|subject),
design = design,
fixed_effects = fixed_effects,
random_effects = random_effects,
n = 30
)
# \donttest{
# 2. Plot from PowRPriori object after simulation
power_results <- power_sim(
formula = y ~ group * time + (1|subject),
design = design,
fixed_effects = fixed_effects,
random_effects = random_effects,
test_parameter = "groupTreatment:timepost",
n_start = 20,
n_increment = 5,
n_sims = 100, # Using a smaller n_sims for a quick example
parallel_plan = "multisession"
)
# Power curve
plot_sim_model(power_results, type = "power_curve")
# Plot sample data with automated aesthetics extraction
plot_sim_model(power_results, type = "data")
# }
Run the code above in your browser using DataLab