View source: R/fanplot_stationary.R
fanplot_stationary | R Documentation |
Plots a fanplot to display quantiles of (negative binomial approximations) of the week-wise stationary distributions
fanplot_stationary(
stat_mom,
unit = 1,
probs = 1:99/100,
interpolate_probs = TRUE,
add_pred_means = TRUE,
fan.col = colorRampPalette(c("darkgreen", "gray90")),
pt.col = "red",
pt.cex = 0.3,
l.col = "black",
mean_col = "black",
mean_lty = "dashed",
ln = NULL,
ln.col = "red",
rlab = NULL,
style = "fan",
add = FALSE,
timepoints = 1:nrow(stat_mom$mu_matrix)/stat_mom$freq,
add_legend = FALSE,
width_legend = 0.1 * (max(timepoints) - min(timepoints)),
probs_legend = c(1, 25, 50, 75, 99)/100,
hlines = NULL,
vlines = NULL,
ylim = NULL,
xlab = "t",
ylab = "No. infected",
return_matrix = FALSE,
...
)
stat_mom |
the stationary moments 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_pred_means |
logical: add line showing the the predictive means |
fan.col , ln , ln.col , rlab , style |
graphical parameters passed on to |
pt.col , pt.cex , l.col |
graphical parameters for display of observed values |
add |
logical: add to existing plot? |
timepoints |
vector giving the x-coordinates for the fanplot (generates |
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 |
hlines , vlines |
coordinates for horizontal and vertical grid lines |
ylim |
limit for the y-axis, passed to |
xlab , ylab |
axis labels |
return_matrix |
logical: return matrix passed to |
... |
other arguments passed on to |
means_col , mean_lty |
graphical parameters for display of predictive means |
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)
# specify and fit model
control_salmonella <- list(end = list(f = addSeason2formula(~ 1), lag = 1),
ar = list(f = addSeason2formula(~ 1), lag = 1),
family = "NegBinM")
fit_salmonella <- hhh4(salmonella, control_salmonella)
# obtain periodically stationary moments:
stat_mom <- stationary_moments(fit_salmonella)
# plot periodically stationary means:
fanplot_stationary(stat_mom, add_legend = TRUE)
# add paths of the six seasons in the data set:
for(i in 0:5){
lines(1:52/52, salmonella@observed[(i*52 + 1):((i + 1)*52)], col = "blue")
}
legend("topleft", col = "blue", lty = 1, legend = "observed seasons")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.