delta.method {alr3} | R Documentation |
These functions use 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.
delta.method(object, g, parameter.prefix="b",print=TRUE) compute.delta.method(Var, g, values, para.name, print=TRUE)
object |
A regression object of type lm, aov, glm or nls. More
generally, object can be any object for which vcov(object) returns
a covariance matrix and coef(object) returns a vector of parameter
estimates. |
g |
A quoted string that is the nonlinear function to be evaluated; see the details below. |
values |
The estimated values of the parameters. |
para.name |
Names of the parameters, as used in the expression
g . |
parameter.prefix |
If para.name is not set, then parameter names will
be generated to be the parameter.prefix followed by a number. See details
below. |
Var |
Estimated or population covariance matrix of the estimates |
print |
If TRUE, print estimates, else return a list |
The delta method computes the estimate and large-sample standard
error of a nonlinear function of parameter estimates. Suppose the names of
the parameters are “b0”, “b1”,...,“bp”, as would be the
case for an object of type lm
or glm
with parameter.prefix
left at its default value of “b”. In this case, “b0” is the
intercept (if the model has no intercept, then the numbering of the
parameters starts with 1, not 0), “b1” is the first estimated parameter
after the intercept, and so on. If any terms in the model are exact linear
combinations of previous terms, they are skipped in assigning names to
parameters. For example, if you have predictors X1, X2, X3=X1+X2 and X4, and
you fit the model y~X1+X2+X3+X4
, a coefficient will not be estimated for
X3 because it is a linear combination of terms to its left in the model
statement. In this case, “b0” is the intercept, “b1” is the
coefficient for X1, “b2” the coefficient for X2, and “b3” the
coefficient for X4 (not for X3, as it is not estimable).
If the value of g
were
"(b2+b6*350)/(4*b4)"
, then the function delta.method would extract
the coefficient estimates from object
, and the covariance matrix from
object
, and pass them to compute.delta.method
.
For objects of class drc
, created using the drc
package, the
parameter names are given by “b1”,...,“bp”, from left to right.
The parameter names in the drc
object are not used.
For compute.delta.method, the length p parameter vector has estimated
covariance matrix V, a p by p matrix. g
is an expression of the form
"(b2+b6*350)/(4*b4)"
that gives the function of values to be evaluated.
The routine evaluates g
at the parameter values, and then computes g',
the derivative
of g with respect to the parameter names, also evaluated at the values,
and then computes the standard error,
(t(g') (Var) g')^(1/2)
delta.method
calls compute.delta.method
, which can be used directly by
providing the nonlinear function, its values, and its estimated covariance matrix.
Estimate |
estimate of g |
se |
Standard error of g |
func |
g |
Sanford Weisberg, sandy@stat.umn.edu
S. Weisberg (2005), Applied Linear Regression, third edition, Wiley, Section 6.1.2
# cakes is a data frame with response Y, predictors X1 X2 data(cakes) m1 <- lm(Y~ X2 + I(X2^2), data = cakes) # quadratic polynomial delta.method(m1, "-b1/(2*b2)") # X2 that maximizes the quadratic # second order polynomial in two predictors: m2 <- lm(Y ~ X1 + X2 + I(X1^2) + I(X2^2) + X1:X2, data=cakes) # Find X1 to maximize Y when X2=350: delta.method(m2,"(b1+b5*350)/(-2*b3)")