View source: R/sim.staircase.R
sim.staircase | R Documentation |
Simulates one or multiple interleaved psychophysical staircases based on specified parameters. The simulation assumes an observer with a given sensitivity (mu) and precision (sd).
sim.staircase(
sc.specs,
mu,
sd,
maxTrials,
maxReversals,
maxSteps,
delta.gradient,
seed = NULL
)
sc.specs |
A list of data frames, each containing specifications for a staircase:
|
mu |
Mean of the observer's psychometric function (sensitivity) |
sd |
Standard deviation of the observer's psychometric function (precision) |
maxTrials |
Maximum number of trials to run |
maxReversals |
Maximum number of reversals before terminating a staircase |
maxSteps |
Maximum number of steps allowed in each direction |
delta.gradient |
Type of gradient for step size adjustment:
|
seed |
Random seed for reproducibility (optional) |
The function implements an adaptive staircase procedure commonly used in psychophysics. It can handle multiple interleaved staircases, each with its own parameters. The observer's responses are simulated using a cumulative normal distribution with the specified mu and sd parameters.
The staircase procedure continues until either:
The maximum number of trials is reached
The maximum number of reversals is reached for all staircases
The maximum number of steps is reached for all staircases
A data frame containing trial-by-trial staircase data with columns:
trialN: Trial number
staircaseID: Identifier for the staircase
stepN: Step number within the staircase
stepRep: Number of repetitions at current step
reversalN: Number of reversals occurred
delta: Step size used
value: Stimulus value
resp: Observer's response (0 or 1)
# Single descending staircase
sc.spec <- list(data.frame(
startValue = 10,
direction = -1,
up.param = I(list(delta = 2, steps = 1)),
down.param = I(list(delta = -2, steps = 3))
))
result <- sim.staircase(
sc.specs = sc.spec,
mu = 5,
sd = 1,
maxTrials = 100,
maxReversals = 10,
maxSteps = 50,
delta.gradient = "fixed"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.