Learn R Programming

latrend (version 1.1.0)

trajectoryAssignments: Get the cluster membership of each trajectory

Description

Get the cluster membership of each trajectory

Usage

# S4 method for lcModel
trajectoryAssignments(object, strategy = which.max, ...)

Arguments

object

The lcModel to obtain the cluster assignments from.

strategy

A function returning the cluster index based on the given vector of membership probabilities. By default, ids are assigned to the cluster with the highest probability.

...

Any additional arguments passed to the strategy function.

Details

While the default strategy is which.max, it is recommended to use which.is.max instead, as this function breaks ties randomly. Another strategy to consider is the function which.weight, which enables weighted sampling of cluster assignments.

Examples

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

# assign ids at random using weighted sampling
trajectoryAssignments(model, strategy = which.weight)
# }

Run the code above in your browser using DataLab