lcMethod objects represent the specification of a method for longitudinal clustering. Furthermore, the object class contains the logic for estimating the respective method.

You can specify a longitudinal cluster method through one of the method-specific constructor functions, e.g., lcMethodKML(), lcMethodLcmmGBTM(), or lcMethodDtwclust(). Alternatively, you can instantiate methods through methods::new(), e.g., by calling new("lcMethodKML", response = "Value"). In both cases, default values are specified for omitted arguments.

Details

Because the lcMethod arguments may be unevaluated, argument retrieval functions such as [[ accept an envir argument. A default environment can be assigned or obtained from a lcMethod object using the environment() function.

Slots

arguments

A list representing the arguments of the lcMethod object. Arguments are not evaluated upon creation of the method object. Instead, arguments are stored similar to a call object, and are only evaluated when a method is fitted. Do not modify or access.

sourceCalls

A list of calls for tracking the original call after substitution. Used for printing objects which require too many characters (e.g. ,function definitions, matrices). Do not modify or access.

Method arguments

An lcMethod objects represent the specification of a method with a set of configurable parameters (referred to as arguments).

Arguments can be of any type. It is up to the lcMethod implementation of validate() to ensure that the required arguments are present and are of the expected type.

Arguments can have almost any name. Exceptions include the names "data", "envir", and "verbose". Furthermore, argument names may not start with a period (".").

Arguments cannot be directly modified, i.e., lcMethod objects are immutable. Modifying an argument involves creating an altered copy through the update.lcMethod method.

Implementation

The base class lcMethod provides the logic for storing, evaluating, and printing the method parameters.

Subclasses of lcMethod differ only in the fitting procedure logic.

To implement your own lcMethod subclass, you'll want to implement at least the following functions:

For more complex methods, the additional functions as part of the fitting procedure will be of use.

Examples

method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time", nClusters = 2)
method
#> 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

method <- new("lcMethodLMKM", formula = Y ~ Time, id = "Id", time = "Time", nClusters = 2)

# get argument names
names(method)
#>  [1] "time"        "id"          "nClusters"   "center"      "standardize"
#>  [6] "method"      "model"       "y"           "qr"          "singular.ok"
#> [11] "contrasts"   "iter.max"    "nstart"      "algorithm"   "formula"    

# evaluate argument
method$nClusters
#> [1] 2

# create a copy with updated nClusters argument
method3 <- update(method, nClusters = 3)