sim.staircase: Simulate Psychophysical Staircase Procedure

View source: R/sim.staircase.R

sim.staircaseR Documentation

Simulate Psychophysical Staircase Procedure

Description

Simulates one or multiple interleaved psychophysical staircases based on specified parameters. The simulation assumes an observer with a given sensitivity (mu) and precision (sd).

Usage

sim.staircase(
  sc.specs,
  mu,
  sd,
  maxTrials,
  maxReversals,
  maxSteps,
  delta.gradient,
  seed = NULL
)

Arguments

sc.specs

A list of data frames, each containing specifications for a staircase:

  • startValue: Initial stimulus value

  • direction: Direction of the staircase (-1 for descending, 1 for ascending)

  • up.param: Parameters for upward steps (list with "delta" and "steps")

  • down.param: Parameters for downward steps (list with "delta" and "steps")

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:

  • "fixed": Constant step size

  • "exp": Exponentially decreasing step size

  • "half": Step size halves after half of reversals

seed

Random seed for reproducibility (optional)

Details

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

Value

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)

Examples

# 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"
)


ccamp83/mu documentation built on Nov. 7, 2024, 5:17 p.m.