Transform or extract the trajectories from the given object to a standardized format.
Trajectories are ordered by Id and observation time.
For estimated models; get the trajectories used for estimation, along with the cluster membership. This data can be used for plotting or post-hoc analysis.
trajectories(
object,
id = idVariable(object),
time = timeVariable(object),
response = responseVariable(object),
cluster = "Cluster",
...
)# S4 method for data.frame
trajectories(
object,
id = idVariable(object),
time = timeVariable(object),
response = responseVariable(object),
cluster = "Cluster",
...
)
# S4 method for matrix
trajectories(
object,
id = idVariable(object),
time = timeVariable(object),
response = responseVariable(object),
cluster = "Cluster",
...
)
# S4 method for call
trajectories(object, ..., envir)
# S4 method for lcModel
trajectories(
object,
id = idVariable(object),
time = timeVariable(object),
response = responseVariable(object),
cluster = "Cluster",
...
)
A data.frame
with columns matching the id
, time
, response
and cluster
name arguments.
The data or model or extract the trajectories from.
The identifier variable name, see idVariable.
The time variable name, see timeVariable.
The response variable name, see responseVariable.
Experimental feature for data.frame input: a vector of cluster membership per id
Arguments passed to trajectoryAssignments for generating the Cluster column.
The environment
used to evaluate the data object in (e.g., in case object
is of type call
).
The standardized data format is for method estimation by latrend, and for plotting functions.
The generic function removes unused factor levels in the Id column, and any trajectories which are only comprised of NAs in the response.
plotTrajectories latrend
data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, latrendData)
trajectories(model)
Run the code above in your browser using DataLab