deltaMethod {car} | R Documentation |
deltaMethod
is a generic function that uses the delta method to get a
first-order approximate
standard error for a nonlinear function of a vector of random variables
with known or estimated covariance matrix.
deltaMethod(object, ...) ## Default S3 method: deltaMethod(object, g, vcov., func=g, ...) ## S3 method for class 'lm' deltaMethod(object, g, vcov.=vcov, parameterPrefix="b", ...) ## S3 method for class 'nls' deltaMethod(object, g, vcov.=vcov, ...) ## S3 method for class 'multinom' deltaMethod(object, g, vcov.=vcov, parameterPrefix="b", ...) ## S3 method for class 'polr' deltaMethod(object, g, vcov.=vcov, ...) ## S3 method for class 'survreg' deltaMethod(object, g, vcov.=vcov, ...) ## S3 method for class 'coxph' deltaMethod(object, g, vcov.=vcov, ...)
object |
For the default method, object is a named vector of p
elements. This means that the call names(object) would return a list
of p character strings that are the names of the elements of
object . For the other methods, object is a
regression object for which coef(object) returns a vector of parameter
estimates. |
g |
A quoted string that is the function of the parameter estimates to be evaluated; see the details below. |
vcov. |
The (estimated) covariance matrix of the coefficient
estimates. For the default method, this argument is required. For all
other methods, this argument must either provide the estimated covariance
matrix or a function that when applied
to object returns a covariance matrix. The default is
to use the function vcov . |
func |
A quoted string used to annotate output. The default of
func = g is usually appropriate. |
parameterPrefix |
Typically a single letter with default
"b" giving the prefix of the
names of the parameter names used in the argument g for some
regression models; see details. |
... |
Additional arguments; not currently used. |
Suppose x is a random vector of length p that is at least approximately normally distributed with mean β and estimated covariance matrix C. Then any function g(β) of β, is estimated by g(x), which is in large samples normally distributed with mean g(β) and estimated variance h'Ch, where h is the first derivative of g(β) with respect to β evaluated at x. This function returns both g(x) and its standard error, the square root of the estimated variance.
The default method requires that you provide x in the argument
object
, C in the argument vcov.
, and a text expression
in argument g
that when evaluated gives the function g.
Since
the delta method is often applied to functions of regression parameter
estimates, the argument object
may be the name of a regression
object from which the vector x will be taken from coef(object)
,
and C will be taken from vcov(object)
unless you provide
some other estimate of variance, for example, using a sandwich estimator. Methods
have been provided for several common regression models.
For regression models for which methods are not provided, you must extract
the named vector of coefficient estimates and and estimate of its covariance
matrix and then apply the default deltaMethod
function.
In the argument g
you must provide a quoted character string
that gives the function of interest. For example, if you set
m2 <- lm(Y ~ X1 + X2)
, then deltaMethod(m2,"X1/X2")
applies the
delta method to the ratio of the coefficient estimates for X1
and
X2
. For the product of the interecpt and the coefficient of X2
,
use deltaMethod(m2, "(Intercept)*X2")
, since the name of the interecpt
parameter estimate is (Intercept)
.
For models of type lm
, glm
and polr
, you can replace the
names in the coefficient vector by b0
, b1
, ..., bp
; you can
also change the prefix b
using the parameterPrefix
argument.
For multinom
objects you
can only use the parameter names starting with the prefix, not the names of
the corresponding regressors.
For nonlinear regression objects of type nls, the call coef(object)
returns the estimated
coefficient vectors with names corresponding to parameter names.
For example,
m2 <- nls(y ~ theta/(1 + gamma * x), start = list(theta=2, gamma=3))
will
have parameters named c("theta", "gamma")
.
In many other familiar regression methods, such as lm and glm, the names of
the coefficient estimates are the corresponding variable names, not
parameter names.
A data.frame with two components
named Estimate
for the estimate, SE
for its standard error.
The value of g
is given as a row label.
Sanford Weisberg, sandy@stat.umn.edu, and John Fox jfox@mcmaster.ca
Fox, J. (2008) Applied Regression Analysis and Generalized Linear Models, Second Edition. Sage.
Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.
S. Weisberg (2005) Applied Linear Regression, Third Edition, Wiley, Section 6.1.2.
First derivatives of g
are computed using symbolic differentiation
by the function D
.
m1 <- lm(time ~ t1 + t2, data = Transact) deltaMethod(m1, "b1/b2") # ratio of coefficients deltaMethod(m1, "t1/t2") # use names of preds. rather than coefs. deltaMethod(m1, "t1/t2", vcov=hccm) # use hccm function to est. vars. # The next example calls the default method by extracting the # vector of estimates and covariance matrix explicitly deltaMethod(coef(m1), "t1/t2", vcov.=vcov(m1))