Learn R Programming

dRiftDM (version 0.3.1)

nobs.drift_dm: Get the Number of Observations for a drift_dm Object

Description

This method retrieves the total number of observations in the obs_data list of a drift_dm object.

Usage

# S3 method for drift_dm
nobs(object, ...)

Value

An integer representing the total number of observations across all conditions in object$obs_data. If obs_data doesn't exist, the function returns 0

Arguments

object

a drift_dm object, which potentially contains the observed data in object$obs_data.

...

additional arguments

Details

The function iterates over each element in object$obs_data, counts the entries in each nested component, and returns the cumulative sum as the total observation count.

It was written to provide an nobs method for calculating the log-likelihood (logLik), AIC (stats::AIC), and BIC (stats::BIC) statistics for objects of type drift_dm.

Examples

Run this code
# get a pre-built model and data set for demonstration purpose
a_model <- dmc_dm()
obs_data(a_model) <- dmc_synth_data

# then get the number of observations by accessing the model
nobs(a_model)

# same number of observations as in the original data set
nrow(dmc_synth_data)

Run the code above in your browser using DataLab