Learn R Programming

Qval (version 1.2.3)

update: 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 CDM update(x, ...)

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

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

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

Value

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

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.

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

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.

Examples

Run this code
set.seed(123)
library(Qval)

# \donttest{
################################################################
# 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)
# }

Run the code above in your browser using DataLab