
Simulate skewed RT data for the factorial design
Source:R/simulation_functions.R
simulate_rt_data.Rd
This function simulates response time data for the factorial design of the experiment. It was used for power analyses by simulation.
Inspired by Chris Jungerius.
Usage
simulate_rt_data(
n_subj_per_group,
meanlog = 2.1,
sdlog = 0.55,
shift = 5,
tau_0 = 0.9,
tau_vis = 0.75,
tau_spa = 0,
beta_aph = 0,
beta_vis = 0,
beta_spa = 0,
beta_aph_vis = 0,
beta_aph_spa = 0,
seed = NULL,
...
)
Arguments
- n_subj_per_group
Number of subjects per group. The total number of subjects will be
n_subj_per_group * 2
.- meanlog
Mean of the log-normal distribution for the base RT values.
- sdlog
Standard deviation of the log-normal distribution for the base RT values.
- shift
Non-decision time, i.e., the minimum value of the RTs.
- tau_0
By-subject random intercept standard deviation.
- tau_vis
By-subject random slope standard deviation for the visual category.
- tau_spa
By-subject random slope standard deviation for the spatial category.
- beta_aph
Effect of the aphantasia group on the RTs.
- beta_vis
Effect of the visual category on the RTs.
- beta_spa
Effect of the spatial category on the RTs.
- beta_aph_vis
Effect of the interaction between the aphantasia group and the visual category on the RTs.
- beta_aph_spa
Effect of the interaction between the aphantasia group and the spatial category on the RTs.
- seed
Random seed for reproducibility. If
NULL
, no seed is set.- ...
Additional arguments passed to the function. Unused.
Examples
# No main effects
df <- simulate_rt_data(100)
head(df)
#> # A tibble: 6 × 12
#> id group category rt_total trial tau_0 tau_vis tau_spa beta_0 aphantasia
#> <chr> <fct> <fct> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 id001 Aphanta… Visual 36.5 1 0.919 0.898 0 34.7 1
#> 2 id001 Aphanta… Visual 11.6 2 0.919 0.898 0 9.77 1
#> 3 id001 Aphanta… Visual 20.2 3 0.919 0.898 0 18.4 1
#> 4 id001 Aphanta… Visual 14.6 4 0.919 0.898 0 12.8 1
#> 5 id001 Aphanta… Visual 13.7 5 0.919 0.898 0 11.9 1
#> 6 id001 Aphanta… Visual 10.6 6 0.919 0.898 0 8.78 1
#> # ℹ 2 more variables: visual <dbl>, spatial <dbl>
df |>
dplyr::group_by(group, category) |>
dplyr::reframe(
mean_rt = mean(rt_total),
median_rt = median(rt_total),
sd_rt = sd(rt_total),
min_rt = min(rt_total),
max_rt = max(rt_total)
)
#> # A tibble: 6 × 7
#> group category mean_rt median_rt sd_rt min_rt max_rt
#> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Aphantasia Control 14.2 13.1 5.68 5.78 64.3
#> 2 Aphantasia Spatial 14.9 13.5 5.91 5.70 57.3
#> 3 Aphantasia Visual 14.5 13.0 5.97 4.90 41.0
#> 4 Typical Control 14.5 13.2 5.47 4.94 45.0
#> 5 Typical Spatial 14.4 13.2 5.28 5.96 45.7
#> 6 Typical Visual 14.1 13.0 5.47 5.39 46.9
# Visual category effect around 2.5s
df <- simulate_rt_data(100, beta_vis = 2.5)
df |>
dplyr::group_by(group, category) |>
dplyr::reframe(
mean_rt = mean(rt_total),
median_rt = median(rt_total),
sd_rt = sd(rt_total),
min_rt = min(rt_total),
max_rt = max(rt_total)
)
#> # A tibble: 6 × 7
#> group category mean_rt median_rt sd_rt min_rt max_rt
#> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Aphantasia Control 14.2 12.7 5.28 5.76 45.3
#> 2 Aphantasia Spatial 14.5 13.3 5.79 4.65 67.7
#> 3 Aphantasia Visual 17.0 15.6 5.87 7.42 65.6
#> 4 Typical Control 14.4 13.0 5.76 5.19 52.5
#> 5 Typical Spatial 14.2 13.0 5.54 5.93 60.1
#> 6 Typical Visual 16.8 15.6 5.41 8.55 52.1