Learn R Programming

LCPA (version 1.0.0)

update: S3 Methods: update

Description

The update function provides a unified and convenient interface to refresh or modify existing objects generated by the LCPA package. It allows users to re-run model fitting or data simulation with new parameter settings while preserving all other original configurations. Supported classes include: LCA, LPA, LCPA, LTA, sim.LCA, sim.LPA, and sim.LTA.

Usage

update(x, ...)

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

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

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

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

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

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

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

Value

An object of the same class as x, reconstructed using the original arguments updated with any provided in .... All unchanged parameters are preserved from the original call.

Arguments

x

An object of one of the following classes:

  • LCA — Latent Class Analysis model.

  • LPA — Latent Profile Analysis model.

  • LCPA — Latent Class Prediction Analysis (with covariates).

  • LTA — Latent Transition Analysis model.

  • sim.LCA — Simulated LCA dataset.

  • sim.LPA — Simulated LPA dataset.

  • sim.LTA — Simulated LTA dataset.

...

Additional named arguments passed to override or extend the original call. Valid arguments depend on the class of x:

LCA

response, L, par.ini, method, is.sort, nrep, vis, control.EM, control.Mplus, control.NNE

LPA

response, L, par.ini, constraint, method, is.sort, nrep, vis, control.EM, control.Mplus, control.NNE

LCPA

response, L, ref.class, type, covariates, CEP.error, par.ini, params, is.sort, constraint, method, tol, maxiter, nrep, starts, maxiter.wa, vis, control.EM, control.Mplus, control.NNE

LTA

responses, L, ref.class, type, covariates, CEP.timeCross, CEP.error, covariates.timeCross, par.ini, params, is.sort, constraint, method, tol, maxiter, nrep, starts, maxiter.wa, vis, control.EM, control.Mplus, control.NNE

sim.LCA

N, I, L, poly.value, IQ, distribution, params, is.sort

sim.LPA

N, I, L, constraint, distribution, mean.range, covs.range, params, is.sort

sim.LTA

N, I, L, times, type, rate, constraint, distribution, mean.range, covs.range, poly.value, IQ, covariates, beta, gamma, params, is.sort

Methods (by class)

  • update(LCA): Update method for LCA objects

  • update(LPA): Update method for LPA objects

  • update(LCPA): Update method for LCPA objects

  • update(LTA): Update method for LTA objects

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

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

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

Details

Internally, each method extracts the stored arguments list from the input object x, merges it with user-provided ... using modifyList, then re-invokes the corresponding constructor function (LCA(), LPA(), LCPA(), LTA(), sim.LCA(), etc.) with the merged argument list.

This ensures that:

  • Only explicitly overridden parameters are changed.

  • Default values from the original call remain intact.

  • Complex nested structures (e.g., control lists) can be partially updated.

Note: If an invalid argument is passed (e.g., constraint to LCA), it will be silently ignored unless the underlying constructor validates inputs.

Examples

Run this code
# \donttest{
library(LCPA)

# --- Update LCA ---
data <- sim.LCA(N=500, I=5, L=3)
lca.obj <- LCA(data$response, L=3)
lca.updated <- update(lca.obj, method="EM", nrep=5)

# --- Update LPA ---
data2 <- sim.LPA(N=300, I=4, L=2)
lpa.obj <- LPA(data2$response, L=2, constraint="VE")
lpa.updated <- update(lpa.obj, constraint="VV")

# --- Update Simulation Objects ---
sim.obj1 <- sim.LCA(N=1000)
sim.obj1_updated <- update(sim.obj1, N=2000, IQ=0.8)

sim.obj2 <- sim.LPA(I=6)
sim.obj2_updated <- update(sim.obj2, I=8, mean.range=c(-2,2))

sim.obj3 <- sim.LTA(N=200, I=5, L=2, times=3)
sim.obj3_updated <- update(sim.obj3, N=300, times=4, constraint="ER")
# }

Run the code above in your browser using DataLab