Description Usage Arguments Details Value
This function performs a series of Monte Carlo simulations of a GAM/GAMM outbreak model.
For each simulated outbreak, it calls outcome
to calculate a time series for the
simulated outbreak (for example, the number of cumulative cases vs time).
It then calculates and returns the confidence interval of the simulated time series at
each time point across all simulations
1 2 3 4 5 6 7 | pspline.estimate.timeseries(
model,
predictors,
outcome,
samples = 1000,
level = 0.95
)
|
model |
model returned by |
predictors |
data frame of predictor values at which the model will be evaluated |
outcome |
function returning calculated outcome time series, as described above |
samples |
number of simulations to run |
level |
confidence level for returned estimates |
The outcome
function must accept (model
, params
, time
) and return a vector
containing the outcome time series obtained by evaluating the model at the time points given in time
and
using the model parameters given in params
.
A typical implementation of the outcome
function would call predict
on
model
and time
to obtain the linear predictor matrix, and then post-multiply
that matrix by params
. Having thus obtained model prediction at every time point,
it would calculate the desired time series outcome and return it in a vector.
For example, to calculate the time series of the first derivative of incidence,
you might use this function for outcome
:
calc_deriv = function(model, params, time) {
eps = 0.001
predictors = predict(model, data.frame(time=time), type="lpmatrix")
fit = model$family$linkinv(predictors
predictors_eps = predict(model, data.frame(time=time + eps), type="lpmatrix")
fit_eps = model$family$linkinv(predictors_eps
(fit_eps - fit) / eps
}
The data frame returned by pspline.estimate.timeseries
contains three columns and
one row for each time point in time
. The columns are lower
, median
, and
upper
, containing the median and the confidence interval for the computed
outcome time series at each time point.
data frame of estimates, as described above
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.