View source: R/fitRTConfModels.R
fitRTConfModels  R Documentation 
This function is a wrapper of the function fitConfModel
(see
there for more information). It calls the function for every possible combination
of model and participant in model
and data
respectively.
Also, see dWEV
, d2DSD
, dDDMConf
,
and dRM
for more
information about the parameters.
fitRTConfModels(data, models = c("dynaViTE", "2DSD", "PCRMt"),
nRatings = NULL, fixed = list(sym_thetas = FALSE), restr_tau = Inf,
grid_search = TRUE, opts = list(), optim_method = "bobyqa",
logging = FALSE, precision = 1e05, parallel = TRUE, n.cores = NULL,
...)
data 
a

models 
character vector with following possible elements "dynWEV", "2DSD", "IRM", "PCRM", "IRMt", and "PCRMt" for the models to be fit. 
nRatings 
integer. Number of rating categories. If 
fixed 
list. List with parameter value pairs for parameters that should not be fitted. (see Details). 
restr_tau 
numerical or 
grid_search 
logical. If 
opts 
list. A list for more control options in the optimization routines
(depending on the 
optim_method 
character. Determines which optimization function is used for
the parameter estimation. Either 
logging 
logical. If 
precision 
numerical scalar. For 2DSD and dynWEV only. Precision of calculation.
(in the respective models) for the density functions (see 
parallel 
"models", "single", "both" or 
n.cores 
integer vector or 
... 
Possibility of giving alternative variable names in data frame
(in the form 
The fitting involves a first grid search through an initial grid. Then the best nAttempts
parameter sets are chosen for an optimization, which is done with an algorithm, depending on the argument
optimmethod
. The NelderMead algorithm uses the R function optim
.
The optimization routine is restarted nRestarts
times with the starting parameter set equal to the
best parameters from the previous routine.
stimulus, response and correct. Two of these columns must be given in data. If all three are given, correct will have no effect (and will be not checked!). stimulus can always be given in numerical format with values 1 and 1. response can always be given as a character vector with "lower" and "upper" as values. Correct must always be given as a 01vector. If stimulus is given together with response and they both do not match the above format, they need to have the same values/levels (if factor). In the case that only stimulus/response is given in any other format together with correct, the unique values will be sorted increasingly and the first value will be encoded as "lower"/1 and the second as "upper"/+1.
fixed. Parameters that should not be fitted but kept constant. These will be dropped from the initial grid search
but will be present in the output, to keep all parameters for prediction in the result. Includes the
possibility for symmetric confidence thresholds for both alternative (sym_thetas
=logical). Other examples are
z =.5
, sv=0
, st0=0
, sz=0
. For race models, the possibility of setting a='b'
(or vice versa)
leads to identical upper bounds on the decision processes, which is the equivalence for z=.5
in a diffusion process
opts. A list with numerical values. Possible options are listed below (together with the optimization method they are used for).
nAttempts
(all) number of best performing initial parameter sets used for optimization; default 5
nRestarts
(all) number of successive optim
routines for each of the starting parameter sets; default 5,
maxfun
('bobyqa'
) maximum number of function evaluations; default: 5000,
maxit
('NelderMead' and 'LBFGSB'
) maximum iterations; default: 2000,
reltol
('NelderMead'
) relative tolerance; default: 1e6),
factr
('LBFGSB'
) tolerance in terms of reduction factor of the objective, default: 1e10)
Gives data frame with rows for each modelparticipant combination and columns for the different parameters
as fitted result as well as additional information about the fit (negLogLik
(for final parameters),
k
(number of parameters), N
(number of data rows), BIC
, AICc
and AIC
)
Sebastian Hellmann, sebastian.hellmann@ku.de
Hellmann, S., Zehetleitner, M., & Rausch, M. (2023). Simultaneous modeling of choice, confidence and response time in visual perception. Psychological Review 2023 Mar 13. doi: 10.1037/rev0000411. Epub ahead of print. PMID: 36913292.
# 1. Generate data from two artificial participants
# Get random drift direction (i.e. stimulus category) and
# stimulus discriminability (two steps: hard, easy)
stimulus < sample(c(1, 1), 400, replace=TRUE)
discriminability < sample(c(1, 2), 400, replace=TRUE)
# generate data for participant 1
data < rWEV(400, a=2, v=stimulus*discriminability*0.5,
t0=0.2, z=0.5, sz=0.1, sv=0.1, st0=0, tau=4, s=1, w=0.3)
# discretize confidence ratings (only 2 steps: unsure vs. sure)
data$rating < as.numeric(cut(data$conf, breaks = c(Inf, 1, Inf), include.lowest = TRUE))
data$participant = 1
data$stimulus < stimulus
data$discriminability < discriminability
# generate data for participant 2
data2 < rWEV(400, a=2.5, v=stimulus*discriminability*0.7,
t0=0.1, z=0.7, sz=0, sv=0.2, st0=0, tau=2, s=1, w=0.5)
data2$rating < as.numeric(cut(data$conf, breaks = c(Inf, 0.3, Inf), include.lowest = TRUE))
data2$participant = 2
data2$stimulus < stimulus
data2$discriminability < discriminability
# bind data from participants
data < rbind(data, data2)
data < data[data$response!=0, ] # drop not finished decision processes
data < data[,3] # drop conf measure (unobservable variable)
head(data)
# 2. Use fitting function
## Not run:
# Fitting takes very long to run and uses multiple (6) cores with this
# call:
fitRTConfModels(data, models=c("dynWEV", "PCRM"), nRatings = 2,
logging=FALSE, parallel="both",
n.cores = c(2,3), # fit two participantmodel combination in parallel
condition="discriminability")# tell which column is "condition"
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.