Learn R Programming

surveillance (version 1.5-0)

twinstim_update: update-method for "twinstim"

Description

Update and (by default) re-fit a "twinstim". This method is especially useful if one wants to add the model environment (which is required for some methods) to a fitted model object a posteriori.

Usage

## S3 method for class 'twinstim':
update(object, endemic, epidemic, optim.args, model,
       ..., evaluate = TRUE)

Arguments

object
a previous "twinstim" fit.
endemic, epidemic
changes to the formulae -- see update.formula and twinstim.
optim.args
see twinstim. If a list, it will modify the original optim.args using modifyList.
model
see twinstim. If this is the only argument to update, re-fitting is cleverly circumvented.
...
Additional arguments to the call, or arguments with changed values.
evaluate
If TRUE (default), evaluate the new call else return the call.

Value

  • If evaluate = TRUE the re-fitted object, otherwise the updated call.

See Also

update.default

Examples

Run this code
if (surveillance.options("allExamples"))
{
  data(imdepi)
  data(imdepifit)

  ## enrich the fit by the model environment
  imdepifit <- update(imdepifit, model=TRUE)
  ## this enables, e.g., intensityplot()s and untrimmed R0 estimates

  ## add another epidemic covariate
  imdepifit2 <- update(imdepifit, epidemic = ~. + log(popdensity),
    # must also update vector of start values!
    optim.args=list(par=c(head(coef(imdepifit),-1),0,tail(coef(imdepifit),1)),
                    fixed="e.siaf.1"), # for reasons of speed
    cumCIF=FALSE)
  
  ## compare with AIC
  AIC(imdepifit, imdepifit2)
}

Run the code above in your browser using DataLab