obs_data<- | R Documentation |
Functions to get or set the "observed data" of an object.
obs_data(object, ...) <- value
## S3 replacement method for class 'drift_dm'
obs_data(object, ..., eval_model = FALSE) <- value
obs_data(object, ...)
## S3 method for class 'drift_dm'
obs_data(object, ..., messaging = TRUE)
## S3 method for class 'fits_ids_dm'
obs_data(object, ...)
object |
an object of type drift_dm or |
... |
additional arguments passed down to the specific method. |
value |
a data.frame which provides three columns: (1) |
eval_model |
logical, indicating if the model should be re-evaluated or
not when updating the solver settings (see re_evaluate_model).
Default is |
messaging |
logical, indicating if messages shall be displayed or not. |
obs_data()
is a generic accessor function, and obs_data<-()
is a
generic replacement function. The default methods get and set the "observed
data". Their behavior, however, may be a bit unexpected.
In drift_dm objects, the observed data are not stored as a
data.frame. Instead, any supplied observed data set is disassembled into
RTs for the upper and lower boundary and with respect to the different
conditions (ensures more speed and easier programming in the depths of the
package). Yet, obs_data()
returns a data.frame
for drift_dm
objects. This implies that obs_data()
does not merely access
the observed data, but re-assembles it. Consequently, a returned data.frame
for the observed data is likely sorted differently than the data.frame that
was originally set to the model via obs_data<-()
. Also, when the originally
supplied data set provided more conditions than the model, the unused
conditions will not be part of the returned data.frame.
For fits_ids_dm
(see load_fits_ids), the observed data are
stored as a data.frame in the general fit procedure info. This is the
data.frame that obs_data()
will return. Thus, the returned data.frame
will match with the data.frame that was initially supplied to
estimate_model_ids, although with unused conditions being dropped.
In theory, it is possible to update parts of the "observed data". However,
because obs_data()
returns a re-assembled data.frame for
drift_dm objects, great care has to be taken with respect to the
ordering of the argument value
. A message is displayed to remind the user
that the returned data.frame may be sorted differently than expected.
For obs_data()
a (re-assembled) data.frame of the observed data. A
message is displayed to remind the user that the returned data.frame may
be sorted differently than expected.
For obs_data<-()
the updated drift_dm object.
There is only a replacement function for drift_dm objects. This is
because replacing the observed data after the model has been fitted (i.e.,
for a fits_ids_dm
object) doesn't make sense.
drift_dm()
# Set some data to a model -------------------------------------------------
my_model <- dmc_dm() # DMC is pre-built and directly available
# synthetic data suitable for DMC; comes with dRiftDM
some_data <- dmc_synth_data
obs_data(my_model) <- some_data
# Extract data from a model ------------------------------------------------
head(obs_data(my_model))
# Important: ---------------------------------------------------------------
# The returned data.frame may be sorted differently than the one initially
# supplied.
some_data <- some_data[sample(1:nrow(some_data)), ] #' # shuffle the data set
obs_data(my_model) <- some_data
all.equal(obs_data(my_model), some_data)
# so don't do obs_data(my_model)["Cond"] <- ...
# Addition: ----------------------------------------------------------------
# accessor method also available for fits_ids_dm objects
# (see estimate_model_ids)
# get an exemplary fits_ids_dm object
fits <- get_example_fits_ids()
head(obs_data(fits))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.