plot_traj: Plot observed longitudinal trajectories using facets

Description Usage Arguments Value Examples

Description

This is a convenience function that allows the user to easily plot the observed longitudinal biomarker trajectory for each individual. Each individual is shown in a separate facet in the plot. This function can be useful to assess whether the "true" parameter values passed to simjm are generating realistic longitudinal trajectories for the simulated biomarkers.

Usage

1
2
plot_traj(yvar = "Yij_1", data, data_filter = NULL, timevar = "tij",
  idvar = "id")

Arguments

yvar

Name of the variable corresponding to the longitudinal biomarker.

data

The data frame with simulated data for the longitudinal submodel. The variable indicating the individual should be called "id", as is the case in the data frames returned by simjm.

data_filter

Optionally, a condition wrapped in quotes indicating the subset of individuals to include in the plot (for example we could use data_filter = "id <= 20" to include plots the first 20 individuals). If NULL then a separate facet is included for every individual in data.

timevar

Name of the variable corresponding to time.

idvar

Name of the variable identifying individuals.

Value

A ggplot object that can be further customised using the ggplot2 package.

Examples

1
2
3
  dat <- simjm(n = 20, random_trajectory = "poly", b_sd = c(2,2,2), seed = 123)
  plot_traj("Yij_1", data = dat$Long1)
  plot_traj("Yij_1", data = dat$Long1, data_filter = "id <= 10")

sambrilleman/simjm documentation built on May 29, 2019, 2:54 p.m.