Learn R Programming

latrend (version 1.2.1)

externalMetric,lcModel,lcModel-method: Compute external model metric(s)

Description

Compute one or more external metrics for two or more lcModel objects.

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

Many of the external metrics depend on implementations in other packages:

  • clusterCrit desgraupes2018clustercritlatrend

  • mclustcomp you2018mclustcomplatrend

  • igraph csardi2006igraphlatrend

  • psych revelle2019psychlatrend

See mclustcomp::mclustcomp() for a grouped overview of similarity metrics.

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

Usage

# S4 method for lcModel,lcModel
externalMetric(
  object,
  object2,
  name = getOption("latrend.externalMetric"),
  ...
)

# S4 method for lcModels,missing externalMetric(object, object2, name = "adjustedRand")

# S4 method for lcModels,character externalMetric(object, object2 = "adjustedRand")

# S4 method for lcModels,lcModel externalMetric(object, object2, name, drop = TRUE)

# S4 method for list,lcModel externalMetric(object, object2, name, drop = TRUE)

Arguments

object

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

object2

The other lcModel to compare with.

name

The name(s) of the external metric(s) to compute. If no names are given, the names specified in the latrend.externalMetric option (none by default) are used.

...

Additional arguments.

drop

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

Value

For externalMetric(lcModel, lcModel): A numeric vector of the computed metrics.

A named numeric vector containing the computed model metrics.

For externalMetric(lcModels): A distance matrix of class dist representing the pairwise comparisons.

For externalMetric(lcModels, name): A distance matrix of class dist representing the pairwise comparisons.

For externalMetric(lcModels, lcModel): A named numeric vector or data.frame containing the computed model metrics.

For externalMetric(list, lcModel): A named numeric vector or data.frame containing the computed model metrics.

Implementation

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

Details

List of currently supported external metrics:

Metric name Description Function / Reference
adjustedRand Adjusted Rand index mclustcomp::mclustcomp(), hubert1985comparinglatrend
CohensKappa Cohen's kappa psych::cohen.kappa(), cohen1960coefficientlatrend
F F-score mclustcomp::mclustcomp()
F1 F1-score, also referred to as the S<U+00F8>rensen<U+2013>Dice Coefficient, or Dice similarity coefficient mclustcomp::mclustcomp()
FolkesMallows Fowlkes-Mallows index mclustcomp::mclustcomp()
Hubert Hubert index clusterCrit::extCriteria()
Jaccard Jaccard index mclustcomp::mclustcomp()
jointEntropy Joint entropy between model assignments mclustcomp::mclustcomp()
Kulczynski Kulczynski index clusterCrit::extCriteria()
MaximumMatch Maximum match measure mclustcomp::mclustcomp()
McNemar McNemar statistic clusterCrit::extCriteria()
MeilaHeckerman Meila-Heckerman measure mclustcomp::mclustcomp()
Mirkin Mirkin metric mclustcomp::mclustcomp()
MI Mutual information mclustcomp::mclustcomp()
NMI Normalized mutual information igraph::compare()
NSJ Normalized version of splitJoin. The proportion of edits relative to the maximum changes (twice the number of ids)
NVI Normalized variation of information mclustcomp::mclustcomp()
Overlap Overlap coefficient, also referred to as the Szymkiewicz<U+2013>Simpson coefficient mclustcomp::mclustcomp() vijaymeena2016surveylatrend
PD Partition difference mclustcomp::mclustcomp()
Phi Phi coefficient. clusterCrit::extCriteria()
precision precision clusterCrit::extCriteria()
Rand Rand index mclustcomp::mclustcomp()
recall recall clusterCrit::extCriteria()
RogersTanimoto Rogers-Tanimoto dissimilarity clusterCrit::extCriteria()
RusselRao Russell-Rao dissimilarity clusterCrit::extCriteria()
SMC Simple matching coefficient mclustcomp::mclustcomp()
splitJoin total split-join index igraph::split_join_distance()
splitJoin.ref Split-join index of the first model to the second model
SokalSneath1 Type-1 Sokal-Sneath dissimilarity clusterCrit::extCriteria()
SokalSneath2 Type-2 Sokal-Sneath dissimilarity clusterCrit::extCriteria()
VI Variation of information mclustcomp::mclustcomp()
Wallace1 Type-1 Wallace criterion mclustcomp::mclustcomp()
Wallace2 Type-2 Wallace criterion mclustcomp::mclustcomp()
WMSSE Weighted minimum sum of squared errors between cluster trajectories
WMMSE Weighted minimum mean of squared errors between cluster trajectories
WMMAE Weighted minimum mean of absolute errors between cluster trajectories

References

See Also

metric

Other metric functions: defineExternalMetric(), defineInternalMetric(), getExternalMetricDefinition(), getExternalMetricNames(), getInternalMetricDefinition(), getInternalMetricNames(), metric()

Examples

Run this code
# NOT RUN {
data(latrendData)
model1 <- latrend(lcMethodKML("Y", id = "Id", time = "Time"), latrendData)
model2 <- latrend(lcMethodLcmmGMM(fixed = Y ~ Time, mixture = ~ Time,
   id = "Id", time = "Time"), latrendData)
ari <- externalMetric(model1, model2, 'adjustedRand')
# }

Run the code above in your browser using DataLab