View source: R/fanplot_prediction.R
fanplot_prediction | R Documentation |
Plots a fanplot to display quantiles of (negative binomial approximations) of the week-wise predictive distributions
fanplot_prediction(
pred,
unit = 1,
probs = 1:99/100,
interpolate_probs = TRUE,
add_observed = TRUE,
add_pred_means = TRUE,
fan.col = colorRampPalette(c("darkgreen", "gray90")),
pt.col = "red",
pt.cex = 0.6,
l.col = "black",
mean_col = "black",
mean_lty = "dashed",
ln = NULL,
rlab = NULL,
add = FALSE,
add_legend = FALSE,
width_legend = 0.1 * (max(pred$timepoints) - min(pred$timepoints))/pred$freq,
probs_legend = c(1, 25, 50, 75, 99)/100,
ylim = NULL,
xlab = "t",
ylab = "No. infected",
return_matrix = FALSE,
...
)
pred |
the prediction as returned by |
unit |
numeric denoting the unit to display |
probs |
vector of probabilities: which quantiles shall be displayed in the fan plot? |
interpolate_probs |
logical: smooth curves by simple interpolation of quantiles |
add_observed |
logical: shall observed values be added? |
fan.col, ln, rlab |
graphical parameters passed on to |
pt.col, pt.cex, l.col |
graphical parameters for display of observed values |
add |
logical: add to existing plot? |
add_legend |
logical: shall a color key legend be added? |
width_legend |
width of box for color key legend in user coordinates |
probs_legend |
vecor of probabilities to display in the legend |
ylim |
limit for the y-axis, passed to |
xlab, ylab |
axis labels |
return_matrix |
logical: return matrix passed to |
... |
other arguments passed on to |
Only if return_matrix
set to TRUE
: the matrix passed to fanplot::fan
data("salmonella.agona")
# convert old "disProg" to new "sts" data class:
salmonella <- disProg2sts(salmonella.agona)
control_salmonella <- list(end = list(f = addSeason2formula(~ 1), lag = 1),
ar = list(f = addSeason2formula(~ 1), lag = 1),
family = "NegBinM", subset = 6:250)
fit_salmonella <- hhh4_lag(salmonella, control_salmonella) # fit model
# obtain prediction:
pred_mom <- predictive_moments(fit_salmonella, t_condition = 250, lgt = 52)
# plot the prediction only:
fanplot_prediction(pred_mom, add_legend = TRUE)
# or plot it along with the fit:
plot(fit_salmonella)
fanplot_prediction(pred_mom, add = TRUE) # add fan plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.