lcModelPartition {latrend} | R Documentation |
Create a lcModel with pre-defined partitioning
Description
Represents an arbitrary partitioning of a set of trajectories. As such, this model has no predictive capabilities. The cluster trajectories are represented by the specified center function (mean by default).
Usage
lcModelPartition(
data,
response,
trajectoryAssignments,
nClusters = NA,
clusterNames = character(),
time = getOption("latrend.time"),
id = getOption("latrend.id"),
name = "part",
center = meanNA,
method = NULL,
converged = TRUE,
model = NULL,
envir = parent.frame()
)
Arguments
data |
A |
response |
The name of the response variable. |
trajectoryAssignments |
A |
nClusters |
The number of clusters. Should be |
clusterNames |
The names of the clusters, or a function with input |
time |
The name of the time variable. |
id |
The name of the trajectory identification variable. |
name |
The name of the method. |
center |
The |
method |
Optional |
converged |
Set the converged state. |
model |
An optional object to attach to the |
envir |
The |
Examples
# comparing a model to the ground truth using the adjusted Rand index
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, latrendData, nClusters = 3)
# extract the reference class from the Class column
trajLabels <- aggregate(Class ~ Id, head, 1, data = latrendData)
trajLabels$Cluster <- trajLabels$Class
refModel <- lcModelPartition(latrendData, response = "Y", trajectoryAssignments = trajLabels)
if (require("mclustcomp")) {
externalMetric(model, refModel, "adjustedRand")
}