vcov.std_selected {stdmod}R Documentation

The 'vcov' Method for a 'std_selected' Class Object

Description

Compute the variance-covariance matrix of estimates in the output of std_selected() or std_selected_boot().

Usage

## S3 method for class 'std_selected'
vcov(object, type, ...)

Arguments

object

The output of std_selected() or std_selected_boot().

type

The type of variance-covariance matrix. If set to "lm", returns the results of the stats::vcov() method for the output of lm(). If set to "boot", the variance-covariance matrix of the bootstrap estimates is returned. Default depends on object. If bootstrap estimates were stored, then the default is "boot". Otherwise, the default is "lm".

...

Arguments to be passed to stats::vcov().

Details

If bootstrapping was used to form the confidence intervals, users can request the variance-covariance matrix of the bootstrap estimates.

Value

A matrix of the variances and covariances of the parameter estimates.

Author(s)

Shu Fai Cheung https://orcid.org/0000-0002-9871-9448

Examples

# Load a sample data set

dat <- test_x_1_w_1_v_1_cat1_n_500
head(dat)

# Do a moderated regression by lm
lm_raw <- lm(dv ~ iv*mod + v1 + cat1, dat)

# Standardize all variables except for categorical variables.
# Interaction terms are formed after standardization.
lm_std <- std_selected(lm_raw, to_scale = ~ .,
                               to_center = ~ .)

# VCOV of lm output
vcov(lm_std)

# Standardize all variables as in std_selected above, and compute the
# nonparametric bootstrapping percentile confidence intervals.
lm_std_boot <- std_selected_boot(lm_raw,
                                 to_scale = ~ .,
                                 to_center = ~ .,
                                 conf = .95,
                                 nboot = 100)
# In real analysis, nboot should be at least 2000.

# VCOV of bootstrap estimates, default when bootstrap was conducted
vcov(lm_std_boot)

# For OLS VCOV
vcov(lm_std_boot, type = "lm")


[Package stdmod version 0.2.10 Index]