Description Usage Arguments Details Value
This function performs Monte Carlo sampling of a GAM/GAMM outbreak model.
For each sampled curve, it calls outcomess
to calculate scalar outcomes
It then calculates and returns the confidence interval of each scalar outcome
1 2 3 4 5 6 7 | pspline.estimate.scalars(
model,
predictors,
outcomes,
samples = 100,
level = 0.95
)
|
model |
model returned by |
predictors |
data.frame of predictor values at which the model will be evaluated |
outcomes |
function returning calculated scalar outcomes, as described above |
samples |
number of samples of outcomes to draw |
level |
confidence level for estimates |
The outcomes
function must accept (model
, params
, predictors
) and return a one-row data frame
in which each column lists the value of a single scalar outcome calculated from the model
estimates.
A typical implementation of the outcomes
function would call predict
on
model
and predictors
to obtain model variable estimates at predictor values, then
calculate the scalar outcomes of interest and return them in a data frame.
For example, to calculate the time of outbreak peak, you might use this function for outcomes
:
calc_peak = function(model, params, time) {
incidence = predict(model, data.frame(time=time), type="response")
data.frame(peak=time[which.max(incidence)])
}
The data frame returned by pspline.estimate.scalars
contains three columns for each
outcome calculated by outcomes
: for outcome x
returned by outcomes
,
pspline.estimate.scalars
returns columns x.lower
, x.median
, and x.upper
, corresponding
to lower confidence limit, median, and upper confidence limit of x
.
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.