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 BPREM only) Name of column that contains the second outcome variable.

results

The output of BEND model to the data. If results=NULL, only a spaghetti plot of the data will be generated.

xlab

X-axis label for the generated plot.

ylab

Y-axis label for the generated plot.

colors

Colors for each class (PREMM or CI-PREMM) or outcome (BPREM). By default, up to 5 colors are provided in the following order: “blue” (class 1 and outcome 1), “red” (class 2 and outcome 2), “green” (class 3), “gold” (class 4), “gray” (class 5).

mean_colors

Colors for the trajectory defined by the mean parameters for each class (PREMM or CI-PREMM) or outcome (BPREM). By default, up to 5 colors are provided in the following order: “darkblue” (class 1 and outcome 1), “darkred” (class 2 and outcome 2), “darkgreen” (class 3), “gold4” (class 4), “darkgray” (class 5).

legend_pos

(optional) Option to change legend position (default = "topright").

...

(optional) Other parameters to pass to the plot() function.

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)


[Package BEND version 1.0 Index]