The randSC
function computes a randomization test for single or
multiple baseline single-case data. The function is based on an algorithm
from the SCRT
package (Bulte & Onghena, 2009, 2012), but rewritten
and extended for the use in AB designs.
rand_test(
data,
dvar,
pvar,
statistic = "Mean B-A",
number = 500,
complete = FALSE,
limit = 5,
startpoints = NA,
exclude.equal = FALSE,
graph = FALSE,
output = "c",
phases = c("A", "B"),
seed = NULL
)randSC(...)
rand.test(...)
A single-case data frame. See scdf
to learn about this format.
Character string with the name of the dependent variable. Defaults to the attributes in the scdf file.
Character string with the name of the phase variable. Defaults to the attributes in the scdf file.
Defines the statistic on which the comparison of phases A
and B is based on. Default setting is statistic = "Mean B-A"
). The
following comparisons are possible:
"Mean A-B"
: Uses
the difference between the mean of phase A and the mean of phase B. This is
appropriate if a decrease of scores was expected for phase B.
"Mean B-A"
: Uses the difference between the mean of phase B and
the mean of phase A. This is appropriate if an increase of scores was
expected for phase B.
"Mean |A-B|"
: Uses the absolute value of
the difference between the means of phases A and B.
"Median
A-B"
: The same as "Mean A-B"
, but based on the median.
"Median B-A"
: The same as "Mean B-A"
, but based on the
median.
Sample size of the randomization distribution. The exactness
of the p-value can not exceed \(1/number\) (i.e., number = 100
results in p-values with an exactness of one percent). Default is
number = 500
. For faster processing use number = 100
. For more
precise p-values set number = 1000
.
If TRUE, the distribution is based on a complete permutation of all possible starting combinations. This setting overwrites the number Argument. The default setting is FALSE.
Minimal number of data points per phase in the sample. The
first number refers to the A-phase and the second to the B-phase (e.g.,
limit = c(5,3)
). If only one number is given, this number is applied
to both phases. Default is limit = 5
.
Alternative to the limit
-parameter
startpoints
exactly defines the possible start points of phase B
(e.g., startpoints = 4:9
restricts the phase B start points to
measurements 4 to 9. startpoints
overruns the limit
-parameter.
If set to exclude.equal = FALSE
, which is the
default, random distribution values equal to the observed distribution are
counted as null-hypothesis conform. That is, they decrease the probability
of rejecting the null-hypothesis (increase the p-value).
exclude.equal
should be set to TRUE
if you analyse one
single-case design (not a multiple baseline data set) to reach a sufficient
power. But be aware, that it increases the chance of an alpha-error.
If graph = TRUE
, a histogram of the resulting
distribution is plotted. It's FALSE
by default.
If set to the default output = "C"
, detailed
information is provided. Set output = "p"
, to only return the
resulting p value.
A vector of two characters or numbers indicating the two
phases that should be compared. E.g., phases = c("A","C")
or
phases = c(2,4)
for comparing the second and the fourth phase. Phases
could be combined by providing a list with two elements. E.g., phases
= list(A = c(1,3), B = c(2,4))
will compare phases 1 and 3 (as A) against 2
and 4 (as B). Default is phases = c("A","B")
.
A seed number for the random generator.
Further arguments passed to the function.
Character string from function call (see
Arguments
above).
Number of single-cases.
Number of data points in phase A.
Number of data points in phase B.
Numeric from function call (see Arguments
above).
A vector defining the start points passed from the
function call (see Arguments
above).
P-value of the randomization test for the given data.
Sample size of
randomization distribution from function call (see Arguments
above).
Logical argument from function call (see Arguments
above).
Test statistic observed for the given
single-case data. (see statistic
in the Arguments
above.)
Z-value of observed test statistic.
Probability of z-value.
Test statistic distribution from randomized data sets.
Number of possible combinations under the given restrictions.
TRUE
indicates that a corrected number of combinations was used. This happens, if
the number of possible combinations (under the given restrictions) undercuts
the requested number
of combinations.
Bulte, I., & Onghena, P. (2009). Randomization tests for multiple-baseline designs: An extension of the SCRT-R package. Behavior Research Methods, 41, 477-485.
Bulte, I., & Onghena, P. (2012). SCRT: Single-Case Randomization Tests. Available from: https://CRAN.R-project.org/package=SCRT
# NOT RUN {
## Compute a randomization test on the first case of the byHeart2011 data and include a graph
rand_test(byHeart2011[1], statistic = "Median B-A", graph = TRUE, seed = 123)
## Compute a randomization test on the Grosche2011 data using complete permutation
rand_test(Grosche2011, statistic = "Median B-A", complete = TRUE, limit = 4, seed = 123)
# }
Run the code above in your browser using DataLab