Learn R Programming

latrend (version 1.2.1)

predictAssignments: Predict the cluster assignments for new trajectories

Description

Computes the posterior probability based on the provided (observed) data.

Usage

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

Arguments

object

The lcModel object.

newdata

Optional data.frame for which to compute the model predictions. If omitted, the model training data is used. Cluster trajectory predictions are made when ids are not specified.

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.

...

Additional arguments.

Value

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

Details

The default implementation uses predictPostprob to determine the cluster membership.

See Also

predictPostprob predict.lcModel

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(), postprob(), predict.lcModel(), predictForCluster(), predictPostprob(), residuals.lcModel(), sigma.lcModel(), time.lcModel()

Examples

Run this code
# NOT RUN {
data(latrendData)
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