prepare_data: Prepare mouse-tracking trajectories for state-space modeling...

View source: R/prepare_data.R

prepare_dataR Documentation

Prepare mouse-tracking trajectories for state-space modeling via Stan

Description

Prepare mouse-tracking trajectories for state-space modeling via Stan

Usage

prepare_data(
  X = NULL,
  preprocess = TRUE,
  N = 61,
  Z.formula = NULL,
  Z.contrast = "treatment",
  yT = "AUTO",
  yD = "AUTO"
)

Arguments

X

(dataframe) a data frame of x-y trajectories and experimental design (see Details)

preprocess

(boolean) indicates whether x-y trajectories should be pre-processed (default preprocess=TRUE)

N

(integer) number of timesteps for trajectory normalization (default N=61)

Z.formula

(character) a formula of the contrasts for the model matrix Z (see model.matrix)

Z.contrast

(character) type of contrasts (default: treatment) for the model matrix Z (see model.matrix)

yT

(numeric) position in angles of the target. The default option yT="AUTO" will automatically determine the target position from the observed data

yD

(numeric) position in angles of the distractor. The default option yD="AUTO" will automatically determine the target position from the observed data

Details

The function prepares the mouse-tracking trajectories to be modeled for the state-space analysis. It automatically processes trajectories according to time-normalization, translation, and atan2 conversion. Users can skip pre-processing by setting preprocess=FALSE.

The input dataframe X needs to be organized using the long format with information being organized as nested. In particular, X must contains the following variables:

sbj

The ID number of participants

trial

The ID number of trials

factors

1,...,Q factors for the categorical variables of the design. They may have different levels.

timestep

The ID number of the recorded x-y trajectories

x

The recorded x-trajectories associated to trials and experimental levels

y

The recorded y-trajectories associated to trials and experimental levels

See language and congruency as examples of datasets format required by ssMousetrack package.

Value

a list containing (i) the new dataframe of the pre-processed dataset (X_processed) and (ii) the needed data for run_ssm

Examples


data(congruency)
dataout <- prepare_data(X = congruency,preprocess = TRUE,Z.formula = "~congruency*plausibility")
str(dataout)


ssMousetrack documentation built on April 5, 2023, 5:11 p.m.