Skip to contents

Transforms entries of variance-covariance of the coefficients corresponding to the non-focal variables to zero.

Usage

zero_vcov(mod, focal_vars, complete)

Arguments

mod

fitted model object or a full variance-covariance matrix with terms appearing the same way they appear in the coefficients.

focal_vars

a character vector specifying the variable(s) appearing on the right side of the formula of the fitted model. The entries of this variable with be non-zero.

complete

logical indicating if the full variance-covariance matrix should be returned.

Value

a variance-covariance matrix of the estimated parameters with non-zero entry corresponding to the focal variable.

Examples

set.seed(4567)
x <- rnorm(100, 3, 5)
y <- 0.4 + 0.7*x + rnorm(100)
df <- data.frame(y = y, x = x)
m1 <- lm(y ~ x, df)
print(zero_vcov(m1, "x"))
#>             (Intercept)            x
#> (Intercept)           0 0.0000000000
#> x                     0 0.0004842308