dmethod | R Documentation |
This function applies the "delta method" to functions of parameters of model objects, provided that functions can be specified to extract the parameter estimates and the (estimated) covariance matrix of the estimator from the object. Derivatives are computed using numerical differentiation. Alternatively standard errors can be approximated using a bootstrap approach described by Mandel (2013). It is based on the deltaMethod
function from the car package, but uses numerical rather than analytical derivatives, and has a few other options.
dmethod(
object,
pfunc,
pname = NULL,
cfunc = coef,
vfunc = vcov,
tfunc,
fname,
B = 0,
sample = FALSE,
level = 0.95,
df = Inf,
...
)
object |
Model object. Just about any object can be specified provided that functions can also be specified to extract the parameter estimates and the estimated covariance matrix of the estimators. |
pfunc |
A character object that is function of the parameters that can be evaluated by R. Parameters must be referenced by name as specified by |
pname |
Names of the parameters extracted by |
cfunc |
Function for extracting the parameter estimates from |
vfunc |
Function for extracting the estimated covariance matrix of the estimator from |
tfunc |
Function for transforming the result of |
fname |
Character string(s) for function names for output. |
B |
Number of bootstrap samples. The default ( |
sample |
Return sample of simulated realizations from sampling distribution when B > 0. |
level |
Confidence level in (0,1) (default is 0.95). |
df |
Degrees of freedom (infinite by default). |
... |
Optional arguments for |
By default the function applies the delta method using numerical differentiation. However if B
> 0 then a bootstrap method described by Mandel (2013) is used which avoids needing to compute derivatives.
Mandel, M. (2013). Simulation-based confidence intervals for functions with complicated derivatives. The American Statistician, 62, 76-81.
# estimation of LD50 for each type of insecticide
m <- glm(cbind(deaths, total - deaths) ~ insecticide * log2(deposit),
family = binomial, data = insecticide)
dmethod(m, "2^c(-b0/b3, -(b0+b1)/(b3+b4), -(b0+b2)/(b3+b5))",
paste("b", 0:5, sep = ""), fname = c("BHC","both","DDT"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.