clock_model: Object-oriented implementation of the Frank clock algorithm.

Description Details Fields Methods Examples

Description

The clock_model class defines a predictive model to fit RT and reward data using data from the clock task. The algorithm can fit group-level data (optimize theta over all subjects and runs), subject-level multi-run data (optimize theta over multiple runs within subject), or single-run data.

Details

At initialization, data to be fit can be passed using the clock_data parameter, and should be of class clockdata_group (for group data), clockdata_subject (for multi-run subject data), or clockdata_run (for single-run data).

After initializing the object, one or more parameter objects are added to the prediction equation using the $add_params(...) method. Bounds on the parameters can be specified at initialization.

Fields

params:

list of param objects used to predict RTs. Note: parameters are evaluated in order.

noiseWt:

A numeric scalar (in milliseconds) specifying how much random uniform noise to add to predicted RTs. Default: 0

SSE:

Total sum of squared errors for fitted theta values.

AIC:

Akaike Information Criterion for fitted theta values.

clock_data:

Clock data to be fit. Should be of class clockdata_group, clockdata_subject, or clockdata_run. DO NOT ASSIGN YOURSELF.

use_global_avg_RT:

Whether to use the global reaction time across all runs within subject as reference for scale and K.

global_avg_RT:

Average reaction time across all runs within subject.

all_by:

character vector that is the union of all run-level fields that define vary-by-run parameters

clock_fit:

clock_fit object storing all information about result of algorithm fit (e.g., expected value)

Methods

add_params(...):

Method to add parameter objects to prediction equation. Should be a list of params or a single param.

fit(toFit=NULL, random_starts=NULL, profile=TRUE):

Fit clock_data using the list of params. Data to fit can be set at call to $fit() using the toFit parameter.

incremental_fit=function(toFit=NULL, plot=TRUE, njobs=1L):

Based on the params list, test model subsets building from 1:p parameters. Useful for checking AICs to verify utility of each parameter.

list_params():

Returns a data.frame describing the parameters, current values, and bounds of this model.

params_current():

Named vector of current values for all parameters.

params_minimum():

Named vector of lower bounds for all parameters.

params_maximum():

Named vector of upper bounds for all parameters.

params_initial():

Named vector of initial values for all parameters.

params_par_scale():

Named vector of expected log parameter scale for all parameters.

reorder_params(neworder):

Re-orders the parameter list according to a named character vector, neworder. Useful because params evaluated in order.

set_data(cdata):

Sets the clock dataset to be fit. cdata should be a clockdata object. Use this method if you wish to alter the clock_data field.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#use example fMRI dataset distrbuted with package
exSubj <- clockdata_subject(subject_ID="008", dataset=clocksubject_fMRI_008jh)

exModel <- clock_model()
exModel$add_params(
   meanRT(max_value=4000),
   autocorrPrevRT(),
   goForGold(),
   go(),
   noGo(),
   meanSlowFast(),
   exploreBeta()
)

exModel$set_data(exSubj)
incrFit <- exModel$incremental_fit(njobs=6)
fit <- exModel$fit(random_starts=5)

#Design matrix matching Badre et al. 2012 Neuron model.
dmat <- fit$build_design_matrix(regressors=c("mean_uncertainty", "rel_uncertainty", "rpe_pos", "rpe_neg", "rt"),
    event_onsets=c("clock_onset", "clock_onset", "feedback_onset", "feedback_onset", "feedback_onset"),
    durations=c("rt", "rt", "feedback_duration", "feedback_duration", 0), baselineCoefOrder=2, writeTimingFiles=TRUE)

PennStateDEPENdLab/fitclock documentation built on May 8, 2019, 1:29 a.m.