This function uses the Delta method to calculate standard errors of linear
functions of variables (similar to
lincom in Stata). Generally, users will not need to
call this function directly.
a character vector with the names of the columns to be of interest in the covariance matrix for a which a standard error will be calculated (e.g. same as expnms in qgcomp fit)
covariance matrix for parameters, e.g. from a model or bootstrap procedure
the "weight" vector for calculating the contribution of each variable in expnms to the final standard error. For a linear combination, this is equal to a vector of ones (and is set automatically). Or can be calculated via the grad.poly procedure, in the case of coming up with proper weights when the combination of expnms derives from a polynomial function (as in qgcomp.boot with degree>1).
This function takes inputs of a set of exposure names (character vector)
and a covariance matrix (with colnames/rownames that contain the full set
of exposure names), as well as a possible
grad parameter to calculate
the variance of a weighted combination of the exposures in
expnms, where the
weights are based off of
grad (which defaults to 1, so that this function
yields the variance of a sum of all variables in
Here is simple version of the delta method for a linear combination of three model coefficients:
f(β) = β_1 + β_2 + β_3 given gradient vector
G = [d(f(β))/dβ_1 = 1, d(f(β))/dβ_2 = 1, d(f(β))/dβ_3 = 1]
t(G) Cov(β) G = delta method variance, where t() is the transpose operator
1 2 3 4 5 6 7
vcov = rbind(c(1.2, .9),c(.9, 2.0)) colnames(vcov) <- rownames(vcov) <- expnms <- c("x1", "x2") qgcomp:::se_comb(expnms, vcov, c(1, 0))^2 # returns the given variance qgcomp:::se_comb(expnms, vcov, c(1, 1)) # default linear MSM fit: all exposures # have equal weight qgcomp:::se_comb(expnms, vcov, c(.3, .1)) # used when one exposure contributes # to the overall fit more than others = d(msmeffect)/dx
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.