| trajectories {clustra} | R Documentation |
Cluster longitudinal trajectories over time.
Description
Performs k-means clustering on continuous response measured over time,
where each mean is defined by a thin plate spline fit to all points in a
cluster. Typically, this function is called by clustra.
Usage
trajectories(
data,
k,
group,
maxdf,
conv = c(10, 0),
mccores = 1,
verbose = FALSE,
...
)
Arguments
data |
Data table or data frame with response measurements, one per observation.
Column names are |
k |
Number of clusters (groups) |
group |
Vector of initial group numbers corresponding to |
maxdf |
Integer. Basis dimension of smooth term. See |
conv |
A vector of length two, |
mccores |
Integer number of cores to use by |
verbose |
Logical, whether to produce debug output. A value > 1 will plot tps fit lines in each iteration. |
... |
See |
Value
A list with components
-
deviance- The final deviance in each cluster added across clusters. -
group- Integer vector of group assignments corresponding to uniqueids. -
loss- Numeric matrix with rows corresponding to uniqueids and one column for each cluster. Each entry is the mean squared loss for the data in theidrelative to the cluster model. -
k- An integer giving the requested number of clusters. -
k_cl- An integer giving the converged number of clusters. Can be smaller thankwhen some clusters become too small for degrees of freedom during convergence. -
data_group- An integer vector, giving group assignment as expanded into allidtime points. -
tps- A list withk_clelements, each an object returned by themgcv::bamfit of a cluster thin plate spline model. -
iterations- An integer giving the number of iterations taken. -
counts- An integer vector giving the number ofids in each cluster. -
counts_df- An integer vector giving the total number of observations in each cluster (sum of the number of observations forids belonging to the cluster). -
changes- An integer, giving the number ofids that changed clusters in the last iteration. This is zero if converged.
Author(s)
George Ostrouchov and David Gagnon