metric: Compute internal model metric(s)

metricR Documentation

Compute internal model metric(s)

Description

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:

  • \insertCite

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

  • \insertCite

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

  • \insertCite

    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.

Usage

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

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

## S4 method for signature '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 name Description Function / Reference
AIC Akaike 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(), \insertCiteakaike1974newlatrend
APPA.mean Mean 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(), \insertCitenagin2005grouplatrend
APPA.min Lowest APPA among the clusters APPA(), \insertCitenagin2005grouplatrend
ASW Average silhouette width based on the Euclidean distance \insertCiterousseeuw1987silhouetteslatrend
BIC Bayesian 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(), \insertCiteschwarz1978estimatinglatrend
CAIC Consistent Akaike information criterion \insertCitebozdogan1987modellatrend
CLC Classification likelihood criterion \insertCitemclachlan2000finitelatrend
converged Whether the model converged during estimation converged()
deviance The model deviance stats::deviance()
Dunn The Dunn index \insertCitedunn1974welllatrend
entropy Entropy of the posterior probabilities
estimationTime The time needed for fitting the model estimationTime()
ED Euclidean distance between the cluster trajectories and the assigned observed trajectories
ED.fit Euclidean distance between the cluster trajectories and the assigned fitted trajectories
ICL.BIC Integrated classification likelihood (ICL) approximated using the BIC \insertCitebiernacki2000assessinglatrend
logLik Model log-likelihood stats::logLik()
MAE Mean absolute error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories
Mahalanobis Mahalanobis distance between the cluster trajectories and the assigned observed trajectories \insertCitemahalanobis1936generalizedlatrend
MSE Mean squared error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories
relativeEntropy, RE A 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]. \insertCiteramaswamy1993empiricallatrend, \insertCitemuthen2004latentlatrend
RMSE Root mean squared error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories
RSS Residual sum of squares under most likely cluster allocation
scaledEntropy See relativeEntropy
sigma The residual standard deviation stats::sigma()
ssBIC Sample-size adjusted BIC \insertCitesclove1987applicationlatrend
SED Standardized Euclidean distance between the cluster trajectories and the assigned observed trajectories
SED.fit The cluster-weighted standardized Euclidean distance between the cluster trajectories and the assigned fitted trajectories
WMAE MAE weighted by cluster-assignment probability
WMSE MSE weighted by cluster-assignment probability
WRMSE RMSE weighted by cluster-assignment probability
WRSS RSS weighted by cluster-assignment probability

Implementation

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

References

\insertAllCited

See Also

externalMetric min.lcModels max.lcModels

Other metric functions: defineExternalMetric(), defineInternalMetric(), externalMetric,lcModel,lcModel-method, getExternalMetricDefinition(), getExternalMetricNames(), getInternalMetricDefinition(), getInternalMetricNames()

Other lcModel functions: clusterNames(), clusterProportions(), clusterSizes(), clusterTrajectories(), coef.lcModel(), converged(), deviance.lcModel(), df.residual.lcModel(), estimationTime(), externalMetric,lcModel,lcModel-method, fitted.lcModel(), fittedTrajectories(), getCall.lcModel(), getLcMethod(), ids(), lcModel-class, model.frame.lcModel(), nClusters(), nIds(), nobs.lcModel(), plot-lcModel-method, plotClusterTrajectories(), plotFittedTrajectories(), postprob(), predict.lcModel(), predictAssignments(), predictForCluster(), predictPostprob(), qqPlot(), residuals.lcModel(), sigma.lcModel(), strip(), time.lcModel(), trajectoryAssignments()

Examples

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

if (require("clusterCrit")) {
  metric(model, c("WMAE", "Dunn"))
}

latrend documentation built on March 31, 2023, 5:45 p.m.