library("splithalf")
library("tidyr")
This script runs splithalf with many possible combinations of the options. Its main use is to ensure that the splithalf function
# Thanks to Nathaniel Haines for the suggestion and the starting code (https://github.com/sdparsons/splithalf/issues/9).
set.seed(01042021)
<- 60 ## sample size
n_participants <- 80
n_trials <- 2
n_blocks
<- data.frame(participant_number = rep(1:n_participants,
sim_data each = n_blocks * n_trials),
trial_number = rep(1:n_trials,
times = n_blocks * n_participants),
block_name = rep(c("A","B"),
each = n_trials,
length.out = n_participants * n_trials * n_blocks),
trial_type = rep(c("congruent","congruent",
"incongruent","incongruent"),
length.out = n_participants * n_trials * n_blocks / 2),
RT = rnorm(n_participants * n_trials * n_blocks,
500,
200),
ACC = 1)
<- data.frame(participant_number = rep(1:n_participants,
sim_data_acc each = n_blocks * n_trials),
trial_number = rep(1:n_trials,
times = n_blocks * n_participants),
block_name = rep(c("A","B"),
each = n_trials,
length.out = n_participants * n_trials * n_blocks),
trial_type = rep(c("congruent","congruent",
"incongruent","incongruent"),
length.out = n_participants * n_trials * n_blocks / 2),
RT = rnorm(n_participants * n_trials * n_blocks,
500,
200),
ACC = c(rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .5),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .7),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .9),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .5),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .7),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .9)))
<- list(score = c("average",
params "difference",
"difference_of_difference"),
halftype = c("oddeven",
"halfs",
"random"),
averae = c("mean",
"median") )
expand.grid(params) %>%
::arrange(., score, halftype) dplyr
splithalf(data = sim_data,
outcome = "RT",
score = "average",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data,
outcome = "RT",
score = "average",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data,
outcome = "RT",
score = "average",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data,
outcome = "RT",
score = "average",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data,
outcome = "RT",
score = "average",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean",
plot = TRUE)
splithalf(data = sim_data,
outcome = "RT",
score = "average",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median",
plot = TRUE)
splithalf(data = sim_data,
outcome = "RT",
score = "difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data,
outcome = "RT",
score = "difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data,
outcome = "RT",
score = "difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data,
outcome = "RT",
score = "difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data,
outcome = "RT",
score = "difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean",
plot = TRUE)
splithalf(data = sim_data,
outcome = "RT",
score = "difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median",
plot = TRUE)
splithalf(data = sim_data,
outcome = "RT",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data,
outcome = "RT",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data,
outcome = "RT",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data,
outcome = "RT",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data,
outcome = "RT",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean",
plot = TRUE)
splithalf(data = sim_data,
outcome = "RT",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent",
average = "median",
plot = TRUE)
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "average",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "average",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "average",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "average",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "average",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean",
plot = TRUE)
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "average",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median",
plot = TRUE)
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean",
plot = TRUE)
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median",
plot = TRUE)
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "oddeven",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "halfs",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median")
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean",
plot = TRUE)
splithalf(data = sim_data_acc,
outcome = "accuracy",
score = "difference_of_difference",
conditionlist = c("A", "B"),
halftype = "random",
permutations = 500,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "median",
plot = TRUE)
Runs several multiverse
set.seed(01042021)
<- 80 ## sample size
n_participants <- 120
n_trials <- 2
n_blocks
<- data.frame(participant_number = rep(1:n_participants,
sim_data_mv each = n_blocks * n_trials),
trial_number = rep(1:n_trials,
times = n_blocks * n_participants),
block_name = rep(c(1,2),
each = n_trials,
length.out = n_participants * n_trials * n_blocks),
trial_type = rep(c("congruent","congruent",
"incongruent","incongruent"),
length.out = n_participants * n_trials * n_blocks / 2),
RT = rnorm(n_participants * n_trials * n_blocks,
500,
200),
ACC = c(rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .5),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .7),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .9),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .5),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .7),
rbinom(n_participants *
*
n_trials / 6,
n_blocks 1, .9)))
<- list(
specifications ACC_cutoff = c(0, 0.5),
RT_min = c(0, 200),
RT_max = c(2000, 3000),
RT_sd_cutoff = c(0, 2),
split_by = c("subject", "trial"),
averaging_method = c("mean")
)
<- splithalf(data = sim_data,
mv_splithalf outcome = "RT",
score = "difference",
conditionlist = c("A"),
halftype = "random",
permutations = 50,
var.RT = "RT",
var.condition = "block_name",
var.participant = "participant_number",
var.compare = "trial_type",
var.ACC = "ACC",
compare1 = "congruent",
compare2 = "incongruent",
average = "mean")
<- splithalf.multiverse(input = mv_splithalf,
multiverse specifications = specifications)
multiverse.plot(multiverse = multiverse,
title = "sim_multiverse")
<- testretest.multiverse(data = sim_data_acc,
icc2
specifications,test = "ICC2",
score = "difference",
var.participant = "participant_number",
var.ACC = "ACC",
var.RT = "RT",
var.time = "block_name",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent")
multiverse.plot(icc2)
<- testretest.multiverse(data = sim_data_acc,
icc3
specifications,test = "ICC3",
score = "difference",
var.participant = "participant_number",
var.ACC = "ACC",
var.RT = "RT",
var.time = "block_name",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent")
multiverse.plot(icc3)
<- testretest.multiverse(data = sim_data_acc,
retest_cor
specifications,test = "cor",
score = "difference",
var.participant = "participant_number",
var.ACC = "ACC",
var.RT = "RT",
var.time = "block_name",
var.compare = "trial_type",
compare1 = "congruent",
compare2 = "incongruent")
multiverse.plot(retest_cor)