randomization_test {scdtb}R Documentation

Randomization Test for Single-Case Experiments

Description

Performs a randomization test on data from single-case experiments. This function allows for the assessment of treatment effects by comparing the observed outcome difference to a distribution of differences obtained through permutation. It supports various constraints on permutation sequences, such as fixed or observed maximum and minimum consecutive sequences of a particular condition. The function also provides graphical summaries of the raw data and the distribution of mean differences.

Usage

randomization_test(
  .df,
  .out,
  .cond,
  .time,
  num_permutations = NULL,
  consec = c("observed", "fixed"),
  max_consec = NULL,
  min_consec = NULL,
  cond_levels = NULL,
  cond_labels = NULL,
  conf.level = 0.95,
  .bins = 30
)

Arguments

.df

A data frame containing the variables of interest.

.out

The name of the outcome variable in .df.

.cond

The name of the condition variable in .df. This variable should have two levels.

.time

The name of the time variable in .df.

num_permutations

The number of permutations to perform. If NULL, all possible permutations are considered.

consec

Specifies the constraint on consecutive sequences for permutation. Can be "observed" for the observed sequence length or "fixed" for a specified sequence length. Defaults to "observed".

max_consec

The maximum number of consecutive observations of the same condition to allow in permutations. If NULL, no maximum is enforced. To implement max_consec, consec must be set to "fixed".

min_consec

The minimum number of consecutive observations of the same condition to allow in permutations. If NULL, no minimum is enforced. To implement min_consec, consec must be set to "fixed".

cond_levels

Explicitly sets the levels of the condition variable. If NULL, the levels are derived from the data.

cond_labels

Labels for the condition levels. If NULL, levels are used as labels.

conf.level

The confidence level for the confidence interval calculation. Defaults to 0.95.

.bins

The number of bins to use for the histogram of the test statistic distribution. Defaults to 30.

Value

A list containing the original difference in means, the p-value of the test, the distribution of test statistics under the null hypothesis, confidence intervals, and plots of the distribution of mean differences and the raw data.

References

Onghena, P. (2020). One by One: The design and analysis of replicated randomized single-case experiments.In R. van de Schoot & M. Mioecvic (Eds.), Small Sample Size Solutions: A Guide for Applied Researchers and Practitioners (1st ed., pp. 15). Routledge. doi:10.4324/9780429273872-8

Examples

result <- randomization_test(sleeping_pills, .out = "sever_compl",
                             .cond = "treatment", .time = "day",
                             num_permutations = 100,
                             cond_levels = c("C", "E"))

result$conf_int


[Package scdtb version 0.1.0 Index]