This vignette describes a scoring method similar to Heuer, Rinck, and Becker (2007); double difference of median reaction times (RTs) for correct responses on Approach Avoidance Task data. It is a subtraction comparing approach bias towards test stimuli relative to approach bias towards control stimuli (avoid_test - approach_test) - (avoid_control - approach_control).
Load the included AAT dataset and inspect its documentation.
data("ds_aat", package = "splithalfr")
?ds_aat
The columns used in this example are:
Only select trials from assessment blocks.
ds_aat <- subset(ds_aat, block_type == "assess")
The variables appr
and stim
were
counterbalanced. Below we illustrate this for the first participant.
ds_1 <- subset(ds_aat, UserID == 1)
table(ds_1$appr, ds_1$stim)
The scoring function calculates the score of a single participant as follows:
fn_score <- function (ds) {
median_avoid_test <- median(
ds[ds$appr == "no" & ds$cat == "test" & ds$response == 1, ]$rt
)
median_approach_test <- median(
ds[ds$appr == "yes" & ds$cat == "test" & ds$response == 1, ]$rt
)
median_avoid_control <- median(
ds[ds$appr == "no" & ds$cat == "control" & ds$response == 1, ]$rt
)
median_approach_control <- median(
ds[ds$appr == "yes" & ds$cat == "control" & ds$response == 1, ]$rt
)
return (
(median_avoid_test - median_approach_test) -
(median_avoid_control - median_approach_control)
)
}
Let’s calculate the AAT score for the participant with UserID 14. NB - This score has also been calculated manually via Excel in the splithalfr repository.
fn_score(subset(ds_aat, UserID == 14))
To calculate the AAT score for each participant, we will use R’s
native by
function and convert the result to a data
frame.
scores <- by(
ds_aat,
ds_aat$UserID,
fn_score
)
data.frame(
UserID = names(scores),
score = as.vector(scores)
)
To calculate split-half scores for each participant, use the function
by_split
. The first three arguments of this function are
the same as for by
. An additional set of arguments allow
you to specify how to split the data and how often. In this vignette we
will calculate scores of 1000 permutated splits. The trial properties
app
and stim
were counterbalanced in the AAT
design. We will stratify splits by these trial properties. See the
vignette on splitting methods for more ways to split the data.
The by_split
function returns a data frame with the
following columns:
participant
, which identifies participantsreplication
, which counts replicationsscore_1
and score_2
, which are the scores
calculated for each of the split datasetsCalculating the split scores may take a while. By default,
by_split
uses all available CPU cores, but no progress bar
is displayed. Setting ncores = 1
will display a progress
bar, but processing will be slower.
split_scores <- by_split(
ds_aat,
ds_aat$UserID,
fn_score,
replications = 1000,
stratification = paste(ds_aat$app, ds_aat$stim)
)
Next, the output of by_split
can be analyzed in order to
estimate reliability. By default, functions are provided that calculate
Spearman-Brown adjusted Pearson correlations
(spearman_brown
), Flanagan-Rulon
(flanagan_rulon
), Angoff-Feldt (angoff_feldt
),
and Intraclass Correlation (short_icc
) coefficients. Each
of these coefficient functions can be used with split_coef
to calculate the corresponding coefficients per split, which can then be
plotted or averaged, for instance via a simple mean
.
# Spearman-Brown adjusted Pearson correlations per replication
coefs <- split_coefs(split_scores, spearman_brown)
# Distribution of coefficients
hist(coefs)
# Mean of coefficients
mean(coefs)
Finally, we can estimate the Calculate bootstrapped confidence
intervals for the value of the reliability coefficient in the population
by bootstrapping participants. For this, we’ll need to repeatedly sample
participants from the population, calculate a collection of reliability
coefficients between the split scores of that sample of participants,
and average those coefficients together. Hence, the call to
split_ci
below, takes (1) the split scores produced by
calling by_split
(split_scores
), (2) the
reliability coefficient we used above (spearman_brown
), and
(3) the method for averaging coefficients we used above
(mean
).
The bootstrap can take even longer than the split, and doesn’t show any progress bar, but it also uses all available CPU cores by default.
# Conduct a bootstrap (of participants)
bootstrap_result <- split_ci(split_scores, spearman_brown, mean)
# Report confidence intervals
library(boot)
print(boot.ci(bootstrap_result, type="bca"))