This function use faceting to plot all trajectories in a data frame. Convenient to see results of several simulations, or data. Also, if data is present, then an additional plot is displayed with data and potentially observation generated.

plotTraj(
  traj = NULL,
  stateNames = NULL,
  data = NULL,
  timeColumn = "time",
  linesData = FALSE,
  summary = TRUE,
  replicateColumn = "replicate",
  nonExtinct = NULL,
  alpha = 1,
  plot = TRUE,
  colour = "red",
  initDate = NULL,
  same = FALSE
)

Arguments

traj

data.frame, output of fitmodel$simulate or simulateModelReplicates.

stateNames

character vector. Names of the state variables to plot. Names must match fitmodel$stateNames. If NULL (default) all state variables are plotted.

data

data frame. Observation times and observed data. The time column must be named as given by timeColumn, whereas the name of the data column should match one of fitmodel$stateNames.

timeColumn

character vector. The column in the data that indicates time

linesData

logical. If TRUE, the data will be plotted as lines

summary

logical. If TRUE, the mean, median as well as the 50th and 95th percentile of the trajectories are plotted (default). If FALSE, all individual trajectories are plotted (transparency can be set with alpha).

replicateColumn

character Vector. The column in the data that indicates the replicate (if multiple replicates are to be plotted, i.e. if summary is FALSE

nonExtinct

character vector. Names of the infected states which must be non-zero so the epidemic is still ongoing. When the names of these states are provided, the extinction probability is plotted by computing the proportion of faded-out epidemics over time. An epidemic has faded-out when all the infected states (whose names are provided) are equal to 0. This is only relevant for stochastic models. In addition, if summary == TRUE, the summaries of the trajectories conditioned on non-extinction are shown. Default to NULL.

alpha

transparency of the trajectories (between 0 and 1).

plot

if TRUE the plot is displayed, and returned otherwise.

colour

character vector. If a character, will use that colour to plot trajectories. If "all", use all available colours. If NULL, don't set the colour.

initDate

character. Date of the first point of the time series (default to NULL). If provided, the x-axis will be in calendar format. NB: currently only works if the unit of time is the day.

same

logical (default: FALSE); if TRUE, trajectories will be plotted in the same panel.