Compute the posterior confusion matrix (PCM). The entry \((i,j)\) represents the probability (or number, in case of scale = TRUE) of a trajectory belonging to cluster \(i\) is assigned to cluster \(j\) under the specified trajectory cluster assignment strategy.

confusionMatrix(object, strategy = which.max, scale = TRUE, ...)

Arguments

object

The model, of type lcModel.

strategy

The strategy for assigning trajectories to a specific cluster, see trajectoryAssignments(). If strategy = NULL, the posterior probabilities are used as weights (analogous to a repeated evaluation of strategy = which.weight).

scale

Whether to express the confusion in probabilities (scale = TRUE), or in terms of the number of trajectories.

...

Additional arguments passed to trajectoryAssignments().

Value

A K-by-K confusion matrix with K = nClusters(object).

Examples

data(latrendData)

if (rlang::is_installed("lcmm")) {
  method <- lcMethodLcmmGMM(
    fixed = Y ~ Time,
    mixture = ~ Time,
    random = ~ 1,
    id = "Id",
    time = "Time"
  )
  model <- latrend(method, latrendData)
  confusionMatrix(model)
}
#>              A            B
#> A 1.000000e+00 7.016739e-09
#> B 1.065267e-11 1.000000e+00