plot.egf {epigrowthfit}R Documentation

Plot Nonlinear Mixed Effects Models of Epidemic Growth

Description

A method for printing objects of class egf.

Usage

## S3 method for class 'egf'
plot(x, type = c("interval", "cumulative", "rt"),
     time_as = c("Date", "numeric"), delta = 1, log = TRUE, zero = NA,
     show_predict = TRUE, show_doubling = FALSE, level = 0.95,
     control = egf_control_plot(), cache = NULL, plot = TRUE,
     subset = NULL, order = NULL, xlim = NULL, ylim = NULL,
     main = NULL, sub = NULL, xlab = NULL, ylab = NULL, ...)

Arguments

x

an egf object.

type

a character string indicating a type of plot. The options are: interval incidence ("interval"), cumulative incidence ("cumulative"), and per capita growth rate ("rt").

time_as

a character string indicating how numeric times are displayed on the bottom axis. The options are: as is ("numeric") and with a calendar ("Date"). In the latter case, horizontal user coordinates on measure time in days since midnight on January 1, 1970.

delta

a positive number indicating a step size on the time axis. Predicted curves are evaluated on a grid with this spacing. When type = "interval", counts observed over shorter or longer intervals delta0 are scaled by a factor of delta/delta0 so that their scale matches that of predicted incidence. Scaled counts can be highlighted via control. If x specifies a model with day of week effects, then delta = 1 is used unconditionally.

log

a logical. If TRUE, then the dependent variable is plotted on a logarithmic scale.

zero

a positive number indicating a line on which to plot zeros when log = TRUE and type = "interval" or "cumulative". NA is to place zeros on the bottom axis. NULL is to suppress zeros.

show_predict

an integer flag: 2 is to draw predicted curves with confidence bands, 1 is draw predicted curves only, 0 is to draw neither.

show_doubling

an integer flag: 2 is to print initial doubling time estimates in the top margin with confidence intervals, 1 is to print estimates only, 0 is to print neither. Nothing is printed for models without a well-defined initial exponential growth rate.

level

a number in the interval (0,1) indicating confidence level, used when show_predict = 2 or show_doubling = 2.

control

an egf_control_plot object controlling the appearance of most plot elements.

cache

a plot.egf object returned by a previous evaluation of plot(x, ...). Fitted and predicted values and standard errors stored in cache are reused to avoid recomputation.

plot

a logical. If FALSE, then plotting does not occur. Useful when only the returned plot.egf object is desired.

subset

an index vector for the rows of mf = model.frame(object, "combined") or a language object evaluating to such a vector. Only time series corresponding to indexed rows are plotted and only fitting windows corresponding to indexed rows are highlighted; the default is to plot all series and to highlight all windows. Evaluation of language objects follows the implementation of subset.data.frame.

order

a permutation of seq_len(nrow(mf)) or a language object evaluating in mf to such a vector. order indicates the order in which time series are plotted; the default indicates the original order.

xlim, ylim

numeric vectors of length 2 specifying axis limits, which are recycled for all plots. If time_as = "Date", then xlim can instead be a Date, POSIXct, or POSIXlt vector.

main, sub, xlab, ylab

character or expression vectors or (main, sub) language objects evaluating in mf to such vectors. These are used to generate plot (main, sub) and axis (xlab, ylab) labels.

...

unused optional arguments.

Details

Computation of fitted and predicted values and standard errors is performed before any plots are created. To avoid waste of computation time, cached computations are returned even if an error is thrown during plotting. To ensure that the cache is preserved, assign the result of the function call to a name:

cache <- plot(x, \dots)

. Caching functionality must be used with care, as mismatch between x and cache will not be detected. Constructions such as plot(y, cache = plot(x, ...), ...), where x and y are different egf objects, should not be expected to produce correct results.

Value

A data frame inheriting from class plot.egf.

If argument cache was supplied in the function call, then this data frame is the result of augmenting cache with any new computations.

See Also

The generic function plot.

Examples

example("egf", package = "epigrowthfit")

l <- list(legend = list(cex = 0.8),
          value = list(cex = 0.8, font = 2),
          ci = list(cex = 0.8))
control <- egf_control_plot(doubling = l)

op <- par(mar = c(3.5, 5, 5, 1))
plot(m1,
     type = "interval",
     show_predict = 2L,
     show_doubling = 2L,
     control = control)
plot(m1,
     type = "cumulative",
     main = "Fitted exponential model",
     sub = quote(paste("Country", country)))
par(op)

op <- par(mar = c(3.5, 9.5, 5, 1))
plot(m1, type = "rt", subset = quote(country %in% LETTERS[4:6]))
par(op)

[Package epigrowthfit version 0.15.3 Index]