Compute one or more internal metrics for the given lcModel object.

Note that there are many metrics available, and there exists no metric that works best in all scenarios. It is recommended to carefully consider which metric is most appropriate for your use case.

Recommended overview papers:

  • arbelaitz2013extensive;textuallatrend provide an extensive overview validity indices for cluster algorithms.

  • vandernest2020overview;textuallatrend provide an overview of metrics for mixture models (GBTM, GMM); primarily likelihood-based or posterior probability-based metrics.

  • henson2007detecting;textuallatrend provide an overview of likelihood-based metrics for mixture models.

Call getInternalMetricNames() to retrieve the names of the defined internal metrics.

See the Details section below for a list of supported metrics.

metric(object, name = getOption("latrend.metric", c("WRSS", "APPA.mean")), ...)

# S4 method for class 'lcModel'
metric(object, name = getOption("latrend.metric", c("WRSS", "APPA.mean")), ...)

# S4 method for class 'list'
metric(object, name, drop = TRUE)

# S4 method for class 'lcModels'
metric(object, name, drop = TRUE)

Arguments

object

The lcModel, lcModels, or list of lcModel objects to compute the metrics for.

name

The name(s) of the metric(s) to compute. If no names are given, the names specified in the latrend.metric option (WRSS, APPA, AIC, BIC) are used.

...

Additional arguments.

drop

Whether to return a numeric vector instead of a data.frame in case of a single metric.

Value

For metric(lcModel): A named numeric vector with the computed model metrics.

For metric(list): A data.frame with a metric per column.

For metric(lcModels): A data.frame with a metric per column.

Supported internal metrics

Metric nameDescriptionFunction / Reference
AICAkaike information criterion. A goodness-of-fit estimator that adjusts for model complexity (i.e., the number of parameters). Only available for models that support the computation of the model log-likelihood through logLik.stats::AIC(), akaike1974newlatrend
APPA.meanMean of the average posterior probability of assignment (APPA) across clusters. A measure of the precision of the trajectory classifications. A score of 1 indicates perfect classification.APPA(), nagin2005grouplatrend
APPA.minLowest APPA among the clustersAPPA(), nagin2005grouplatrend
ASWAverage silhouette width based on the Euclidean distancerousseeuw1987silhouetteslatrend
BICBayesian information criterion. A goodness-of-fit estimator that corrects for the degrees of freedom (i.e., the number of parameters) and sample size. Only available for models that support the computation of the model log-likelihood through logLik.stats::BIC(), schwarz1978estimatinglatrend
CAICConsistent Akaike information criterionbozdogan1987modellatrend
CLCClassification likelihood criterionmclachlan2000finitelatrend
convergedWhether the model converged during estimationconverged()
devianceThe model deviancestats::deviance()
DunnThe Dunn indexdunn1974welllatrend
entropyEntropy of the posterior probabilities
estimationTimeThe time needed for fitting the modelestimationTime()
EDEuclidean distance between the cluster trajectories and the assigned observed trajectories
ED.fitEuclidean distance between the cluster trajectories and the assigned fitted trajectories
ICL.BICIntegrated classification likelihood (ICL) approximated using the BICbiernacki2000assessinglatrend
logLikModel log-likelihoodstats::logLik()
MAEMean absolute error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories
MahalanobisMahalanobis distance between the cluster trajectories and the assigned observed trajectoriesmahalanobis1936generalizedlatrend
MSEMean squared error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories
relativeEntropy, REA measure of the precision of the trajectory classification. A value of 1 indicates perfect classification, whereas a value of 0 indicates a non-informative uniform classification. It is the normalized version of entropy, scaled between [0, 1].ramaswamy1993empiricallatrend, muthen2004latentlatrend
RMSERoot mean squared error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories
RSSResidual sum of squares under most likely cluster allocation
scaledEntropySee relativeEntropy
sigmaThe residual standard deviationstats::sigma()
ssBICSample-size adjusted BICsclove1987applicationlatrend
SEDStandardized Euclidean distance between the cluster trajectories and the assigned observed trajectories
SED.fitThe cluster-weighted standardized Euclidean distance between the cluster trajectories and the assigned fitted trajectories
WMAEMAE weighted by cluster-assignment probability
WMSEMSE weighted by cluster-assignment probability
WRMSERMSE weighted by cluster-assignment probability
WRSSRSS weighted by cluster-assignment probability

Implementation

See the documentation of the defineInternalMetric() function for details on how to define your own metrics.

References

Examples

data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, latrendData)
metric(model, "WMAE")
#>      WMAE 
#> 0.2158127 

if (require("clusterCrit")) {
  metric(model, c("WMAE", "Dunn"))
}
#>      WMAE      Dunn 
#> 0.2158127 0.2204919