plot_BEND {BEND} | R Documentation |
Plot a BEND Model (PREM, CREM, BPREM)
Description
Generates a "spaghetti plot" of observed longitudinal trajectories for each individual. If the results from a BEND
function are supplied, the trajectory defined by the mean parameters is shown in bold. If fitting a mixture (PREMM
or CI-PREMM
) or bivariate model (BPREM
), the mean trajectories for classes or outcomes will be distinguished by color.
Usage
plot_BEND(
data,
id_var,
time_var,
y_var,
y2_var = NULL,
results = NULL,
xlab = "X",
ylab = "Y",
colors = NULL,
mean_colors = NULL,
legend_pos = "topright",
...
)
Arguments
data |
Data frame in long format, where each row describes a measurement occasion for a given individual. It is assumed that each individual has the same number of assigned timepoints (a.k.a., rows). |
id_var |
Name of column that contains ids for individuals with repeated measures in a longitudinal dataset. |
time_var |
Name of column that contains the time variable. |
y_var |
Name of column that contains the outcome variable. |
y2_var |
(for |
results |
The output of |
xlab |
X-axis label for the generated plot. |
ylab |
Y-axis label for the generated plot. |
colors |
Colors for each class ( |
mean_colors |
Colors for the trajectory defined by the mean parameters for each class ( |
legend_pos |
(optional) Option to change legend position (default = "topright"). |
... |
(optional) Other parameters to pass to the |
Value
No return value, called to generate plot.
Author(s)
Corissa T. Rohloff
Examples
# load simulated data
data(SimData_PREM)
# plot observed data
plot_BEND(data = SimData_PREM,
id_var = "id",
time_var = "time",
y_var = "y")
# load fitted model results
data(results_prem)
# plot fitted results
plot_BEND(data = SimData_PREM,
id_var = "id",
time_var = "time",
y_var = "y",
results = results_prem)