View source: R/extended_s3_methods.R
| coef<- | R Documentation |
Extract or set the coefficients/parameters objects supported by dRiftDM.
coef(object, ...) <- value
## S3 replacement method for class 'drift_dm'
coef(object, ..., eval_model = FALSE) <- value
## S3 method for class 'drift_dm'
coef(object, ..., select_unique = TRUE, select_custom_prms = TRUE)
## S3 method for class 'fits_agg_dm'
coef(object, ...)
## S3 method for class 'fits_ids_dm'
coef(object, ...)
## S3 method for class 'mcmc_dm'
coef(object, ..., .f = mean, id = NULL)
## S3 method for class 'coefs_dm'
print(
x,
...,
round_digits = drift_dm_default_rounding(),
print_rows = 10,
some = FALSE,
show_header = TRUE,
show_note = TRUE
)
object |
an object of type drift_dm, |
... |
additional arguments passed forward (to |
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 |
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 |
select_custom_prms |
logical, indicating if custom parameters shall be
returned as well. Only has an effect if |
.f |
the function to be applied to each parameter of a chain. Must
either return a single value or a vector (with always the same length).
Default is |
id |
an optional numeric or character vector specifying the IDs of
participants from whom to summarize samples. Only applicable when the model was
estimated hierarchically. Use |
x |
an object of type |
round_digits |
integer, controls the number of digits shown. Default is 3. |
print_rows |
integer, controls the number of rows shown. |
some |
logical. If |
show_header |
logical. If |
show_note |
logical. If |
coef.*() are methods for the generic stats::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 is TRUE, dRiftDM tries to provide
unique parameter labels.
For objects of type drift_dm, coefs() returns either a named
numeric vector if select_unique = TRUE, or a matrix if
select_unique = FALSE. If select_custom_prms = TRUE, custom parameters
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. If select_custom_prms = TRUE, the data.frame will also contain
columns for the custom parameters. The returned data.frame has the class
label coefs_dm to easily plot histograms for each parameter
(see hist.coefs_dm).
For objects of type fits_agg_dm, returns the same as coef.drift_dm()
(i.e., as if calling coef() with an object of type drift_dm)
For objects of type mcmc_dm, the return type depends on the model structure
and the .f output:
If the model is non-hierarchical or id is a single value (not NA),
the function returns either a vector or a matrix, depending on whether
.f returns a single value or a vector.
In the hierarchical case, when id is a vector or NA, the function
returns a data.frame. If .f returns a single value, the data.frame
will contain one row per participant (with an ID column and one column
per parameter). If .f returns a vector, the data.frame will include
an additional column .f_out, coding the output of .f in long
format.
drift_dm()
# 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()
coef(a_model) # gives the free and unique parameters
coef(a_model, select_unique = FALSE) # gives the entire parameter matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.