dmcFitSubject: dmcFitSubject

Description Usage Arguments Value Examples

View source: R/dmcFit.R

Description

Fit theoretical data generated from dmcSim to observed data by minimizing the root-mean-square error ("RMSE") between a weighted combination of the CAF and CDF functions using optim (Nelder-Mead). Alternative cost functions include squared percentage error ("SPE"), and g-squared statistic ("GS").

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
dmcFitSubject(
  resOb,
  nTrl = 1e+05,
  startVals = list(),
  minVals = list(),
  maxVals = list(),
  fixedFit = list(),
  fitInitialGrid = TRUE,
  fitInitialGridN = 10,
  fixedGrid = list(),
  nCAF = 5,
  nDelta = 19,
  pDelta = vector(),
  tDelta = 1,
  costFunction = "RMSE",
  spDist = 1,
  drDist = 0,
  drShape = 3,
  drLim = c(0.1, 0.7),
  rtMax = 5000,
  subjects = c(),
  printInputArgs = TRUE,
  printResults = FALSE,
  optimControl = list(),
  numCores = 2
)

Arguments

resOb

Observed data (see flankerData and simonTask for data format) and the function dmcObservedData to create the required input from either an R data frame or external *.txt/*.csv files

nTrl

Number of trials to use within dmcSim.

startVals

Starting values for to-be estimated parameters. This is a list with values specified individually for amp, tau, drc, bnds, resMean, resSD, aaShape, spShape, spBias, sigm (e.g., startVals = list(amp = 20, tau = 200, drc = 0.5, bnds = 75, resMean = 300, resSD = 30, aaShape = 2, spShape = 3, spBias = 0, sigm = 4)).

minVals

Minimum values for the to-be estimated parameters. This is a list with values specified individually for amp, tau, drc, bnds, resMean, resSD, aaShape, spShape, spBias, sigm (e.g., minVals = list(amp = 10, tau = 5, drc = 0.1, bnds = 20, resMean = 200, resSD = 5, aaShape = 1, spShape = 2, spBias = -20, sigm = 1)).

maxVals

Maximum values for the to-be estimated parameters. This is a list with values specified individually for amp, tau, drc, bnds, resMean, resSD, aaShape, spShape, spBias, sigm (e.g., maxVals = list(amp = 40, tau = 300, drc = 1.0, bnds = 150, resMean = 800, resSD = 100, aaShape = 3, spShape = 4, spBias = 20, sigm = 10))

fixedFit

Fix parameter to starting value. This is a list with bool values specified individually for amp, tau, drc, bnds, resMean, resSD, aaShape, spShape, spBias, sigm (e.g., fixedFit = list(amp = F, tau = F, drc = F, bnds = F, resMean = F, resSD = F, aaShape = F, spShape = F, spBias = T, sigm = T))

fitInitialGrid

TRUE/FALSE

fitInitialGridN

10 linear steps between parameters min/max values (reduce if searching more than ~2/3 initial parameters)

fixedGrid

Fix parameter for initial grid search. This is a list with bool values specified individually for amp, tau, drc, bnds, resMean, resSD, aaShape, spShape, spBias, sigm (e.g., fixedGrid = list(amp = T, tau = F, drc = T, bnds = T, resMean = T, resSD = T, aaShape = T, spShape = T, spBias = T, sigm = T)). As a default, the initial gridsearch only searches the tau space.

nCAF

Number of CAF bins.

nDelta

Number of delta bins.

pDelta

An alternative option to nDelta by directly specifying required percentile values (vector of values 0-100)

tDelta

The type of delta calculation (1=direct percentiles points, 2=percentile bounds (tile) averaging)

costFunction

The cost function to minimise: root mean square error ("RMSE": default), squared percentage error ("SPE"), or likelihood-ratio chi-square statistic ("GS")

spDist

The starting point (sp) distribution (0 = constant, 1 = beta, 2 = uniform)

drDist

The drift rate (dr) distribution type (0 = constant, 1 = beta, 2 = uniform)

drShape

The drift rate (dr) shape parameter

drLim

The drift rate (dr) range

rtMax

The limit on simulated RT (decision + non-decisional components)

subjects

NULL (aggregated data across all subjects) or integer for subject number

printInputArgs

TRUE (default) /FALSE

printResults

TRUE/FALSE (default)

optimControl

Additional control parameters passed to optim (see optim details section)

numCores

Number of cores to use

Value

dmcFitSubject returns a list of objects of class "dmcfit"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Code below can exceed CRAN check time limit, hence donttest
# Example 1: Flanker data from Ulrich et al. (2015)
fit <- dmcFitSubject(flankerData, nTrl = 1000, subjects = c(1, 2));
plot(fit, flankerData, subject = 1)
plot(fit, flankerData, subject = 2)
summary(fit)

# Example 2: Simon data from Ulrich et al. (2015)
fit <- dmcFitSubject(simonData, nTrl = 1000, subject = c(1, 2))
plot(fit, simonData, subject = 1)
plot(fit, simonData, subject = 2)
summary(fit)

DMCfun documentation built on Oct. 25, 2021, 9:09 a.m.