update: Update Method for Various Objects

View source: R/S3Update.R

updateR Documentation

Update Method for Various Objects

Description

The update function provides a unified interface for refreshing or modifying existing analysis objects produced by the Qval package, including CDM, validation, sim.data and fit classes. By passing additional arguments, users can rerun fitting or simulation routines without reconstructing the entire object from scratch.

Usage

update(x, ...)

## S3 method for class 'CDM'
update(x, ...)

## S3 method for class 'validation'
update(x, ...)

## S3 method for class 'sim.data'
update(x, ...)

## S3 method for class 'fit'
update(x, ...)

Arguments

x

An object of class CDM, validation, and sim.data.

...

Additional arguments specific to the method being updated:

  • For CDM: Y, Q, model, method, mono.constraint, maxitr, verbose.

  • For validation: Y, Q, CDM.obj, par.method, mono.constraint, model, method, search.method, iter.level, maxitr, eps, alpha.level, criter, verbose.

  • For sim.data: Q, N, IQ, model, distribute, control, verbose.

  • For fit: Y, Q, model.

Details

The update methods internally extract the original call arguments from the input object, combine them with any new parameters provided in ..., and re-invoke the corresponding constructor (CDM, validation, sim.data and fit). This approach ensures consistency and preserves all untouched settings from the original object.

Value

An updated object of the same class as x, reflecting any changes in the supplied parameters.

Methods (by class)

  • update(CDM): Update method for CDM objects

  • update(validation): Update method for validation objects

  • update(sim.data): Update method for sim.data objects

  • update(fit): Update method for fit objects

Examples

set.seed(123)
library(Qval)


################################################################
# Example 1: summary a CDM object                              #
################################################################
Q <- sim.Q(3, 20)
IQ <- list(P0 = runif(20, 0, 0.2), P1 = runif(20, 0.8, 1))
data.obj <- sim.data(Q, N = 500, IQ = IQ, 
                     model = "GDINA", distribute = "horder")
CDM.obj <- CDM(data.obj$dat, Q, model = "GDINA", method = "BM")
summary(CDM.obj)

CDM.updated <- update(CDM.obj, method = "EM", maxitr = 1000)
summary(CDM.updated)


################################################################
# Example 2: summary a validation object                       #
################################################################
MQ <- sim.MQ(Q, 0.1)
CDM.obj2 <- CDM(data.obj$dat, MQ)
validation.obj <- validation(data.obj$dat, MQ, CDM.obj2, 
                             method = "GDI")
summary(validation.obj)

validation.updated <- update(validation.obj, method = "Hull")
summary(validation.updated)


################################################################
# Example 3: summary a sim.data object                         #
################################################################
data.obj2 <- sim.data(Q = sim.Q(3, 10), N = 1000)
summary(data.obj2)

data.updated <- update(data.obj2, N = 200)
summary(data.updated)


################################################################
# Example 4: summary a fit object                              #
################################################################
fit.obj <- fit(data.obj$dat, Q, model = "GDINA")
summary(fit.obj)

data.updated <- update(fit.obj, model = "DINA")
summary(data.updated)



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

Related to update in Qval...