Learn R Programming

msm (version 0.4.1)

deltamethod: The delta method

Description

Delta method for approximating the standard error of a transformation $g(X)$ of a random variable $X = (x1, x2, \ldots)$, given estimates of the mean and covariance matrix of $X$.

Usage

deltamethod(g, mean, cov, ses=TRUE)

Arguments

g
A formula representing the transformation. It must have arguments labelled x1, x2,... For example, ~ 1 / (x1 + x2)

If the transformation returns a vector, then a list of formulae g1, g2, ...can be provid

mean
The estimated mean of $X$
cov
The estimated covariance matrix of $X$
ses
If TRUE, then the standard errors of $g1(X), g2(X),\ldots$ are returned. Otherwise the covariance matrix of $g(X)$ is returned.

Value

  • A vector containing the standard errors of $g1(X), g2(X),\ldots$ or a matrix containing the covariance of $g(X)$.

Details

The delta method expands a differentiable function of a random variable about its mean, usually with a first-order Taylor approximation, and then takes the variance. For example, an approximation to the covariance matrix of $g(X)$ is given by $$Cov(g(X)) = g'(mu) Cov(X) [g'(mu)]^T$$

where $mu$ is an estimate of the mean of $X$.

References

Oehlert, G. W. A note on the delta method. American Statistician 46(1), 1992

Examples

Run this code
## Simple linear regression, E(y) = alpha + beta x 
x <- 1:100
y <- rnorm(100, 4*x, 5)
toy.lm <- lm(y ~ x)
estmean <- coef(toy.lm)
estvar <- summary(toy.lm)$cov.unscaled

## Approximate standard error of (1 / (alphahat + betahat))
deltamethod (~ 1 / (x1 + x2), estmean, estvar)

Run the code above in your browser using DataLab