A simple, yet exceedingly useful, approach to estimate the variance of a function using the numerical delta method. A number of packages provide functions that analytically calculate the gradients; we use numerical derivatives, which generalises to models that do not offer analytical derivatives (e.g. ordinary differential equations, integration), or to examples that are tedious or error-prone to calculate (e.g. sums of predictions from GLMs).
# S4 method for mle2
predictnl(object, fun, newdata=NULL, gd=NULL, ...)
# S4 method for stpm2
predictnl(object, fun, newdata=NULL,
link = c("I", "log", "cloglog", "logit"), gd=NULL, ...)
# S4 method for pstpm2
predictnl(object, fun, newdata=NULL,
link = c("I", "log", "cloglog", "logit"), gd=NULL, ...)
# S4 method for aft
predictnl(object, fun, newdata=NULL,
link = c("I", "log", "cloglog", "logit"), gd=NULL, ...)
A data-frame with components Estimate
, lower
and
upper
, with an attribute "newdata" for the newdata
data-frame.
an stpm2
fit
An object with coef
, vcov
and `coef<-`
methods (required).
A function that takes object
as the first argument, possibly with
newdata
and other arguments (required). See notes for why it is
often useful to include newdata
as an argument to the function.
An optional argument that defines newdata to be passed to fun
.
A character string to represent the link on which to calculate the variance and confidence intervals.
An optional matrix of gradients. If this is not specified, then the gradients are calculated using finite differences.
Other arguments that are passed to fun
.
The confidence interval estimation is based on the delta method using numerical differentiation.
stpm2