pspline.estimate.scalars: Calculates confidence intervals for scalars estimated from...

Description Usage Arguments Details Value

View source: R/scalar.R

Description

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

Usage

1
2
3
4
5
6
7
pspline.estimate.scalars(
  model,
  predictors,
  outcomes,
  samples = 100,
  level = 0.95
)

Arguments

model

model returned by gam or gamm

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

Details

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.

Value

data frame of estimates, as described above


pspline.inference documentation built on Jan. 19, 2021, 5:07 p.m.