This function simulates the model under theta, generates observation and plot them against the data. Since simulation and observation processes can be stochastic, nReplicates can be plotted.

plotFit(
  fitmodel,
  theta,
  initState,
  data,
  nReplicates = 1,
  summary = TRUE,
  alpha = min(1, 10/nReplicates),
  allVars = FALSE,
  nonExtinct = NULL,
  observation = TRUE,
  plot = TRUE
)

Arguments

fitmodel

a fitmodel object

theta

named numeric vector. Values of the parameters. Names should match fitmodel$thetaNames.

initState

named numeric vector. Initial values of the state variables. Names should match fitmodel$stateNames.

data

data frame. Observation times and observed data. The time column must be named "time" and the observation column must be named "obs".

nReplicates

numeric, number of replicated simulations.

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

alpha

transparency of the trajectories (between 0 and 1).

allVars

logical, if FALSE only the observations are plotted. Otherwise, all state variables are plotted.

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.

observation

logical, if TRUE simulated observation are generated by rTrajObs.

plot

if TRUE the plot is displayed, and returned otherwise.

Value

if plot == FALSE, a list of 2 elements is returned:

  • simulations data.frame of nReplicates simulated observations.

  • plot the plot of the fit.