Learn R Programming

latrend (version 1.6.1)

predictAssignments: Predict the cluster assignments for new trajectories

Description

Predict the most likely cluster membership for each trajectory in the given data.

Usage

predictAssignments(object, newdata = NULL, ...)

# S4 method for lcModel predictAssignments(object, newdata = NULL, strategy = which.max, ...)

Value

A factor of length nrow(newdata) that indicates the assigned cluster per trajectory per observation.

Arguments

object

The model.

newdata

A data.frame of trajectory data for which to compute trajectory assignments.

...

Not used.

strategy

A function returning the cluster index based on the given vector of membership probabilities. By default (strategy = which.max), trajectories are assigned to the most likely cluster.

Details

The default implementation uses predictPostprob to determine the cluster membership.

See Also

predictPostprob predict.lcModel

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

Examples

Run this code
if (FALSE) {
data(latrendData)
if (require("kml")) {
  model <- latrend(method = lcMethodKML("Y", id = "Id", time = "Time"), latrendData)
  predictAssignments(model, newdata = data.frame(Id = 999, Y = 0, Time = 0))
}
}

Run the code above in your browser using DataLab