Skip to contents

Repeatedly simulates experiments with simulate_role_data and applies three decision rules to each: the naive rule that reads a significant \(X \times Z_{post}\) interaction as moderation (and otherwise checks joint significance of the \(X \to Z\) and \(Z \to Y\) paths), role_test in a post-only design, and role_test with a baseline measure.

Usage

role_simulation(
  worlds = c("neither", "moderator", "mediator", "curved_mediator", "cancelling", "both"),
  n = 400,
  reps = 1000,
  B = 499,
  margin = 0.25,
  alpha = 0.05,
  cores = 1,
  seed = NULL
)

Arguments

worlds

Character vector of worlds. Default all six.

n

Sample size per simulated experiment. Default 400.

reps

Replications per world. Default 1000.

B

Permutations per randomization test. Default 499.

margin, alpha

Passed to role_test. Defaults 0.25 and 0.05.

cores

Number of worker processes (uses parallel). Default 1.

seed

Seed for reproducibility (L'Ecuyer streams when cores > 1).

Value

A data frame of class "role_simulation" with one row per replication and rule (world, truth, rep, rule, verdict). Its summary() method returns the share of correct verdicts, moderator verdicts, and undetermined verdicts by world and rule.

Examples

# \donttest{
sims <- role_simulation(worlds = c("moderator", "cancelling"), reps = 20, B = 199)
summary(sims)
#>        world     truth      rule pct_correct pct_moderator pct_undetermined
#> 1  moderator moderator     naive          75            75                0
#> 2  moderator moderator post_only          40            40               30
#> 3  moderator moderator  pre_post          90            90                0
#> 4 cancelling  mediator     naive          10            55                0
#> 5 cancelling  mediator post_only          30            25               25
#> 6 cancelling  mediator  pre_post         100             0                0
# }