plotClusterTrajectories | R Documentation |
Plot cluster trajectories
Plot the cluster trajectories of a lcModel
## S4 method for signature 'data.frame'
plotClusterTrajectories(
object,
response,
cluster = "Cluster",
time = getOption("latrend.time"),
center = meanNA,
trajectories = c(FALSE, "sd", "se", "80pct", "90pct", "95pct", "range"),
facet = !isFALSE(as.logical(trajectories[1])),
id = getOption("latrend.id"),
...
)
## S4 method for signature 'lcModel'
plotClusterTrajectories(
object,
what = "mu",
at = time(object),
clusterLabels = NULL,
trajectories = FALSE,
facet = !isFALSE(as.logical(trajectories[1])),
trajAssignments = trajectoryAssignments(object),
...
)
object |
The (cluster) trajectory data. |
response |
The response variable name. |
cluster |
The cluster assignment column |
time |
The time variable name. |
center |
A function for aggregating multiple points at the same point in time |
trajectories |
Whether to additionally plot the original trajectories ( Note that visualizing the expected intervals is currently only supported for time-aligned trajectories, as the interval is computed at each unique moment in time.
By default ( |
facet |
Whether to facet by cluster. This is done by default when |
id |
Id column. Only needed when |
... |
Arguments passed to |
what |
The distributional parameter to predict. By default, the mean response 'mu' is predicted. The cluster membership predictions can be obtained by specifying |
at |
An optional vector of the times at which to compute the cluster trajectory predictions. |
clusterLabels |
Cluster display names. By default it's the cluster name with its proportion enclosed in parentheses. |
trajAssignments |
The cluster assignments for the fitted trajectories. Only used when |
A ggplot
object.
clusterTrajectories plotFittedTrajectories plotTrajectories plot
Other lcModel functions:
clusterNames()
,
clusterProportions()
,
clusterSizes()
,
clusterTrajectories()
,
coef.lcModel()
,
converged()
,
deviance.lcModel()
,
df.residual.lcModel()
,
estimationTime()
,
externalMetric,lcModel,lcModel-method
,
fitted.lcModel()
,
fittedTrajectories()
,
getCall.lcModel()
,
getLcMethod()
,
ids()
,
lcModel-class
,
metric()
,
model.frame.lcModel()
,
nClusters()
,
nIds()
,
nobs.lcModel()
,
plot-lcModel-method
,
plotFittedTrajectories()
,
postprob()
,
predict.lcModel()
,
predictAssignments()
,
predictForCluster()
,
predictPostprob()
,
qqPlot()
,
residuals.lcModel()
,
sigma.lcModel()
,
strip()
,
time.lcModel()
,
trajectoryAssignments()
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, latrendData, nClusters = 3)
if (require("ggplot2")) {
plotClusterTrajectories(model)
# show assigned trajectories
plotClusterTrajectories(model, trajectories = TRUE)
# show 95th percentile observation interval
plotClusterTrajectories(model, trajectories = "95pct")
# show observation standard deviation
plotClusterTrajectories(model, trajectories = "sd")
# show observation standard error
plotClusterTrajectories(model, trajectories = "se")
# show observation range
plotClusterTrajectories(model, trajectories = "range")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.