Skip to contents

Extract or set the coefficients/parameters of drift_dm or fits_ids_dm objects

Usage

coef(object, ...) <- value

# S3 method for class 'drift_dm'
coef(object, ..., eval_model = FALSE) <- value

# S3 method for class 'drift_dm'
coef(object, ..., select_unique = TRUE)

# S3 method for class 'fits_ids_dm'
coef(object, ...)

Arguments

object

an object of type drift_dm or fits_ids_dm (see load_fits_ids).

...

additional arguments passed to the respective method

value

numerical, a vector with valid values to update the model's parameters. Must match with the number of (unique and free) parameters.

eval_model

logical, indicating if the model should be re-evaluated or not when updating the parameters (see re_evaluate_model). Default is FALSE.

select_unique

logical, indicating if only those parameters shall be returned that are considered unique (e.g., when a parameter is set to be identical across three conditions, then the parameter is only returned once). Default is TRUE. This will also return only those parameters that are estimated.

Value

For objects of type drift_dm, coefs() returns either a named numeric vector for select_unique = TRUE, or the prms_matrix matrix for select_unique = FALSE. If custom parameters exist, they are added to the matrix.

For objects of type fits_ids_dm, coefs() returns a data.frame. If select_unique = TRUE, the columns will be the (unique, free) parameters, together with a column coding IDs. If select_unique = FALSE, the columns will be the parameters as listed in the columns of prms_matrix (see drift_dm), together with columns coding the conditions and IDs. The returned data.frame has the class label coefs_dm to easily plot histograms for each parameter (see hist.coefs_dm).

Details

coef() are methods for the generic coef function; coefs<-() is a generic replacement function, currently supporting objects of type drift_dm.

The argument value supplied to the coefs<-() function must match with the vector returned from coef(<object>). It is possible to update just part of the (unique) parameters.

Whenever the argument select_unique = TRUE, dRiftDM tries to provide unique parameter labels.

See also

Examples

# get a pre-built model and a data set for demonstration purpose
# (when creating the model, set the discretization to reasonable values)
a_model <- dmc_dm(t_max = 1.5, dx = .0025, dt = .0025)
coef(a_model) # gives the free and unique parameters
#>        muc          b    non_dec sd_non_dec        tau          A      alpha 
#>       4.00       0.60       0.30       0.02       0.04       0.10       4.00 
coef(a_model, select_unique = FALSE) # gives the entire parameter matrix
#>        muc   b non_dec sd_non_dec  tau a    A alpha peak_l
#> comp     4 0.6     0.3       0.02 0.04 2  0.1     4   0.04
#> incomp   4 0.6     0.3       0.02 0.04 2 -0.1     4   0.04