compute_history {bistablehistory} | R Documentation |
Computes cumulative history for the time-series
Description
Computes cumulative history for each state in the time-series.
Usage
compute_history(
data,
state,
duration = NULL,
onset = NULL,
random_effect = NULL,
session = NULL,
run = NULL,
tau = 1,
mixed_state = 0.5,
history_init = 0
)
Arguments
data |
A table with time-series. |
state |
String, the name of the column that specifies perceptual state. The column type should be a factor with two or three levels (the third level is assumed to correspond to a transition/mixed phase) or should be convertible to a two level factor (as it would be impossible to infer the identity of transition/ mixed phase). |
duration |
String, name of the column with duration of individual
perceptual dominance phases. Optional, you can specify |
onset |
String, name of the column with onsets of the perceptual
dominance states. Optional, used to compute duration of the dominance
phases, if these are not provided explicitly via |
random_effect |
String, name of the column that identifies random effect, e.g. individual participants, stimuli for a single participant, etc. If omitted, no random effect is assumed. If specified and there is more than one level (participant, stimulus, etc.), it is used in a hierarchical model. |
session |
String, name of the column that identifies unique
experimental session for which a mean dominance phase duration will
be computed (see |
run |
String, name of the column that identifies unique runs/blocks. If omitted, the data is assumed to belong to a single time series. Code assumes that run IDs are different within an experimental session but can be the same between the session. E.g. session A, runs 1, 2, 3.. and session B, runs 1, 2, 3 but not session A, runs 1, 2, 1. |
tau |
Time constant of exponential growth/decay
normalized to the mean duration of clear percepts within each |
mixed_state |
Specifies an activation level during
transition/mixed phases (state #3, see |
history_init |
Initial value for cumulative history computation. Either a numeric scalar in 0..1 range or a vector of two numbers in 0..1 range. In the latter case, two histories will start at different levels. |
Value
A matrix nrow(data)
× 2 with computed history values
Examples
df <- compute_history(br_singleblock, state = "State",
duration = "Duration", tau = 1,
mixed_state = 0.5, history_init = 0)