A collection of special methods that adapt the fitting procedure of the underlying longitudinal cluster method.
NOTE: the underlying implementation is experimental and may change in the future.
Supported fit methods:
lcFitConverged
: Fit a method until a converged result is obtained.
lcFitRep
: Repeatedly fit a method and return the best result based on a given internal metric.
lcFitRepMin
: Repeatedly fit a method and return the best result that minimizes the given internal metric.
lcFitRepMax
: Repeatedly fit a method and return the best result that maximizes the given internal metric.
lcFitConverged(method, maxRep = Inf)
lcFitRep(method, rep = 10, metric, maximize)
lcFitRepMin(method, rep = 10, metric)
lcFitRepMax(method, rep = 10, metric)
Meta methods are immutable and cannot be updated after instantiation. Calling update()
on a meta method is only used to update arguments of the underlying lcMethod object.
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time", nClusters = 2)
metaMethod <- lcFitConverged(method, maxRep = 10)
metaMethod
#> lcFitConverged encapsulating:
#> lcMethodLMKM specifying "lm-kmeans"
#> time: "Time"
#> id: "Id"
#> nClusters: 2
#> center: meanNA
#> standardize: scale
#> method: "qr"
#> model: TRUE
#> y: FALSE
#> qr: TRUE
#> singular.ok: TRUE
#> contrasts: NULL
#> iter.max: 10
#> nstart: 1
#> algorithm: c("Hartigan-Wong", "Lloyd", "Forgy", "Ma
#> formula: Y ~ Time
#> with meta-method arguments:
#> lcFitConverged specifying "lm-kmeans"
#> maxRep: 10
model <- latrend(metaMethod, latrendData)
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time", nClusters = 2)
repMethod <- lcFitRep(method, rep = 10, metric = "RSS", maximize = FALSE)
repMethod
#> lcFitRep encapsulating:
#> lcMethodLMKM specifying "lm-kmeans"
#> time: "Time"
#> id: "Id"
#> nClusters: 2
#> center: meanNA
#> standardize: scale
#> method: "qr"
#> model: TRUE
#> y: FALSE
#> qr: TRUE
#> singular.ok: TRUE
#> contrasts: NULL
#> iter.max: 10
#> nstart: 1
#> algorithm: c("Hartigan-Wong", "Lloyd", "Forgy", "Ma
#> formula: Y ~ Time
#> with meta-method arguments:
#> lcFitRep specifying "lm-kmeans"
#> rep: 10
#> metric: "RSS"
#> maximize: FALSE
model <- latrend(repMethod, latrendData)
minMethod <- lcFitRepMin(method, rep = 10, metric = "RSS")
maxMethod <- lcFitRepMax(method, rep = 10, metric = "ASW")