Select the lcModel with the lowest metric value

# S3 method for class 'lcModels'
min(x, name, ...)

Arguments

x

The lcModels object

name

The name of the internal metric.

...

Additional arguments.

Value

The lcModel with the lowest metric value

Functionality

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)

models <- lcModels(model1, model2, model3)

min(models, "WMAE")
#> Longitudinal cluster model using lmkm
#> lcMethodLMKM specifying "lm-kmeans"
#>  time:           "Time"
#>  id:             "Id"
#>  nClusters:      3
#>  center:         function (x) {    mean(x, na.rm = TRUE)}
#>  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", "M
#>  formula:        Y ~ Time
#> 
#> Cluster sizes (K=3):
#>        A        B        C 
#> 72 (36%) 78 (39%) 50 (25%) 
#> 
#> Number of obs: 2000, strata (Id): 200
#> 
#> Scaled residuals:
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -3.55483 -0.55670 -0.04454  0.00000  0.59256  5.41874 
#>