Learn R Programming

latrend (version 1.3.0)

postprob: Posterior probability per fitted trajectory

Description

Get the posterior probability matrix with element \((i,j)\) indicating the probability of trajectory \(i\) belonging to cluster \(j\).

Usage

# S4 method for lcModel
postprob(object, ...)

Arguments

object

The lcModel.

...

Additional arguments.

Value

A I-by-K matrix with I = nIds(object) and K = nClusters(object).

Implementation

Classes extending lcModel should override this method.

setMethod("postprob", "lcModelExt", function(object, ...) {
  # return trajectory-specific posterior probability matrix
})

Troubleshooting

If you are getting errors about undefined model signatures when calling postprob(model), check whether the postprob() function is still the one defined by the latrend package. It may have been overridden when attaching another package (e.g., lcmm). If you need to attach conflicting packages, load them first.

Details

This method should be extended by lcModel implementations. The default implementation returns uniform probabilities for all observations.

See Also

trajectoryAssignments predictPostprob predictAssignments

Other model-specific methods: clusterTrajectories(), coef.lcModel(), converged(), deviance.lcModel(), df.residual.lcModel(), fitted.lcModel(), fittedTrajectories(), lcModel-class, logLik.lcModel(), model.frame.lcModel(), nobs.lcModel(), predict.lcModel(), predictAssignments(), predictForCluster(), predictPostprob(), residuals.lcModel(), sigma.lcModel(), time.lcModel()

Examples

Run this code
# NOT RUN {
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, latrendData)

postprob(model)

if (rlang::is_installed("lcmm")) {
  gmmMethod = lcMethodLcmmGMM(
    fixed = Y ~ Time,
    mixture = ~ Time,
    id = "Id",
    time = "Time"
  )
  gmmModel <- latrend(gmmMethod, data = latrendData)
  postprob(gmmModel)
}
# }

Run the code above in your browser using DataLab