extract: Extract Components from Qval Package Objects

View source: R/S3Extract.R

extractR Documentation

Extract Components from Qval Package Objects

Description

A unified extractor function for retrieving internal components from objects produced by the Qval package. This method allows users to access key elements such as model results, validation logs, and simulation settings in a structured and object-oriented manner.

Usage

extract(object, what, ...)

## S3 method for class 'CDM'
extract(object, what, ...)

## S3 method for class 'validation'
extract(object, what, ...)

## S3 method for class 'sim.data'
extract(object, what, ...)

## S3 method for class 'fit'
extract(object, what, ...)

Arguments

object

An object of class CDM, validation, sim.data, or fit.

what

A character string specifying the name of the component to extract.

...

Additional arguments (currently ignored).

Details

This generic extractor supports three core object classes: CDM, validation, sim.data and fit. It is intended to streamline access to commonly used internal components without manually referencing object slots. The available components for each class are listed below:

CDM

Cognitive Diagnosis Model fitting results. Available components:

analysis.obj

The internal model fitting object (e.g., GDINA or Baseline Model).

alpha

Estimated attribute profiles (EAP estimates) for each respondent.

P.alpha.Xi

Posterior distribution of latent attribute patterns.

alpha.P

Marginal attribute mastery probabilities (estimated).

P.alpha

Prior attribute probabilities at convergence.

Deviance

Negative twice the marginal log-likelihood (model deviance).

npar

Number of free parameters estimated in the model.

AIC

Akaike Information Criterion.

BIC

Bayesian Information Criterion.

call

The original model-fitting function call.

...

Can extract corresponding value from the GDINA object.

validation

Q-matrix validation results. Available components:

Q.orig

The original Q-matrix submitted for validation.

Q.sug

The suggested (revised) Q-matrix after validation.

time.cost

Total computation time for the validation procedure.

process

Log of Q-matrix modifications across iterations.

iter

Number of iterations performed during validation.

priority

Attribute priority matrix (available for PAA-based methods only).

Hull.fit

Data required to plot the Hull method results (for Hull-based validation only).

call

The original function call used for validation.

sim.data

Simulated data and parameters used in cognitive diagnosis simulation studies:

dat

Simulated dichotomous response matrix (N \times I).

Q

Q-matrix used to generate the data.

attribute

True latent attribute profiles (N \times K).

catprob.parm

Item-category conditional success probabilities (list format).

delta.parm

Item-level delta parameters (list format).

higher.order.parm

Higher-order model parameters (if used).

mvnorm.parm

Parameters for the multivariate normal attribute distribution (if used).

LCprob.parm

Latent class-based success probability matrix.

call

The original function call that generated the simulated data.

fit

Relative fit indices (-2LL, AIC, BIC, CAIC, SABIC) and absolute fit indices (M_2 test, RMSEA_2, SRMSR):

npar

The number of parameters.

-2LL

The Deviance.

AIC

The Akaike information criterion.

BIC

The Bayesian information criterion.

CAIC

The consistent Akaike information criterion.

SABIC

The Sample-size Adjusted BIC.

M2

A vector consisting of M_2 statistic, degrees of freedom, significance level, and RMSEA_2 (Liu, Tian, & Xin, 2016).

SRMSR

The standardized root mean squared residual (SRMSR; Ravand & Robitzsch, 2018).

Value

The requested component. The return type depends on the specified what and the class of the object.

Methods (by class)

  • extract(CDM): Extract fields from a CDM object

  • extract(validation): Extract fields from a validation object

  • extract(sim.data): Extract fields from a sim.data object

  • extract(fit): Extract fields from a fit object

References

Khaldi, R., Chiheb, R., & Afa, A.E. (2018). Feed-forward and Recurrent Neural Networks for Time Series Forecasting: Comparative Study. In: Proceedings of the International Conference on Learning and Optimization Algorithms: Theory and Applications (LOPAL 18). Association for Computing Machinery, New York, NY, USA, Article 18, 1–6. DOI: 10.1145/3230905.3230946.

Liu, Y., Tian, W., & Xin, T. (2016). An application of M2 statistic to evaluate the fit of cognitive diagnostic models. Journal of Educational and Behavioral Statistics, 41, 3–26. DOI: 10.3102/1076998615621293.

Ravand, H., & Robitzsch, A. (2018). Cognitive diagnostic model of best choice: a study of reading comprehension. Educational Psychology, 38, 1255–1277. DOI: 10.1080/01443410.2018.1489524.

Examples

library(Qval)
set.seed(123)


################################################################
# Example 1: sim.data extraction                               #
################################################################
Q <- sim.Q(3, 10)
data.obj <- sim.data(Q, N = 200)
extract(data.obj, "dat")


################################################################
# Example 2: CDM extraction                                    #
################################################################
CDM.obj <- CDM(data.obj$dat, Q)
extract(CDM.obj, "alpha")
extract(CDM.obj, "AIC")


################################################################
# Example 3: validation extraction                             #
################################################################
validation.obj <- validation(data.obj$dat, Q, CDM.obj)
Q.sug <- extract(validation.obj, "Q.sug")
print(Q.sug)

################################################################
# Example 4: fit extraction                                    #
################################################################
fit.obj <- fit(data.obj$dat, Q.sug, model="GDINA")
extract(fit.obj, "M2")



Qval documentation built on June 8, 2025, 10:20 a.m.

Related to extract in Qval...