Learn R Programming

latrend (version 1.6.1)

trajectories: Get the trajectories

Description

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.

Usage

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", ... )

Value

A data.frame with columns matching the id, time, response and cluster name arguments.

Arguments

object

The data or model or extract the trajectories from.

id

The identifier variable name, see idVariable.

time

The time variable name, see timeVariable.

response

The response variable name, see responseVariable.

cluster

Experimental feature for data.frame input: a vector of cluster membership per id

...

Arguments passed to trajectoryAssignments for generating the Cluster column.

envir

The environment used to evaluate the data object in (e.g., in case object is of type call).

Details

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.

See Also

plotTrajectories latrend

Examples

Run this code
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