Learn R Programming

latrend (version 1.5.0)

lcFitMethods: Method fit modifiers

Description

A collection of special methods that adapt the fitting procedure of the underlying longitudinal cluster method. 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.

Usage

lcFitConverged(method, maxRep = Inf)

lcFitRep(method, rep = 10, metric, maximize)

lcFitRepMin(method, rep = 10, metric)

lcFitRepMax(method, rep = 10, metric)

Arguments

method

The lcMethod to use for fitting.

maxRep

The maximum number of fit attempts

rep

The number of fits

metric

The internal metric to assess the fit.

maximize

Whether to maximize the metric. Otherwise, it is minimized.

Examples

Run this code

data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time", nClusters = 2)
metaMethod <- lcFitConverged(method, maxRep = 10)
metaMethod
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
model <- latrend(repMethod, latrendData)

minMethod <- lcFitRepMin(method, rep = 10, metric = "RSS")

maxMethod <- lcFitRepMax(method, rep = 10, metric = "ASW")

Run the code above in your browser using DataLab