subset.lcModels: Subsetting a lcModels list based on method arguments

subset.lcModelsR Documentation

Subsetting a lcModels list based on method arguments

Description

Subsetting a lcModels list based on method arguments

Usage

## S3 method for class 'lcModels'
subset(x, subset, drop = FALSE, ...)

Arguments

x

The lcModels or list of lcModel to be subsetted.

subset

Logical expression based on the lcModel method arguments, indicating which lcModel objects to keep.

drop

Whether to return a lcModel object if the result is length 1.

...

Not used.

Value

A lcModels list with the subset of lcModel objects.

Functionality

  • Print an argument summary for each of the models.

  • Convert to a data.frame of method arguments.

  • Subset the list.

  • Compute an internal metric or external metric.

  • Obtain the best model according to minimizing or maximizing a metric.

  • Obtain the summed estimation time.

  • Plot a metric across a variable.

  • Plot the cluster trajectories.

See Also

Other lcModels functions: as.lcModels(), lcModels-class, lcModels, max.lcModels(), min.lcModels(), plotMetric(), print.lcModels()

Examples

data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")

model1 <- latrend(method, latrendData, nClusters = 1)
model2 <- latrend(method, latrendData, nClusters = 2)
model3 <- latrend(method, latrendData, nClusters = 3)

rngMethod <- lcMethodRandom("Y", id = "Id", time = "Time")
rngModel <- latrend(rngMethod, latrendData)

models <- lcModels(model1, model2, model3, rngModel)

subset(models, nClusters > 1 & .method == 'lmkm')

latrend documentation built on March 31, 2023, 5:45 p.m.