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:
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.
# S4 method for lcModel
metric(object, name = getOption("latrend.metric", c("WRSS", "APPA.mean")), ...)# S4 method for list
metric(object, name, drop = TRUE)
# S4 method for lcModels
metric(object, name, drop = TRUE)
The lcModel
, lcModels
, or list
of lcModel
objects to compute the metrics for.
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.
Whether to return a numeric vector
instead of a data.frame
in case of a single metric.
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.
See the documentation of the defineInternalMetric()
function for details on how to define your own metrics.
List of currently supported metrics:
Metric name | Description | Function / Reference |
AIC |
Akaike information criterion | stats::AIC() , akaike1974newlatrend |
APPA.mean |
Mean of the average posterior probability of assignment (APPA) across clusters | APPA() , nagin2005grouplatrend |
APPA.min |
Lowest APPA among the clusters | APPA() , nagin2005grouplatrend |
BIC |
Bayesian information criterion | stats::BIC() , schwarz1978estimatinglatrend |
CAIC |
Consistent Akaike information criterion | bozdogan1987modellatrend |
CLC |
Classification likelihood criterion | mclachlan2000finitelatrend |
converged |
Whether the model converged during estimation | converged() |
deviance |
The model deviance | stats::deviance() |
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 | biernacki2000assessinglatrend |
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 | mahalanobis1936generalizedlatrend |
MSE |
Mean squared error of the fitted trajectories (assigned to the most likely respective cluster) to the observed trajectories | |
relativeEntropy , RE |
The normalized version of entropy , scaled between [0, 1]. |
ramaswamy1993empiricallatrend, muthen2004latentlatrend |
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 | sclove1987applicationlatrend |
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 |
|
WRSS |
RSS weighted by cluster-assignment probability |
externalMetric min.lcModels max.lcModels
Other metric functions:
defineExternalMetric()
,
defineInternalMetric()
,
externalMetric,lcModel,lcModel-method
,
getExternalMetricDefinition()
,
getExternalMetricNames()
,
getInternalMetricDefinition()
,
getInternalMetricNames()
# NOT RUN {
data(latrendData)
model <- latrend(lcMethodLcmmGMM(fixed = Y ~ Time, mixture = ~ Time,
id = "Id", time = "Time"), latrendData)
bic <- metric(model, "BIC")
ic <- metric(model, c("AIC", "BIC"))
# }
Run the code above in your browser using DataLab