Description Usage Arguments Details Value See Also Examples
The function model_vcov
computes a variance-covariance matrix for a linear regression model. The user can provide a cluster variable to cluster the variance-covariance matrix and can select to use bootstraping for clustering. The output can serve as input for the model_summary
and plot_interaction
functions.
1 | model_vcov(model, type, var_cluster)
|
model |
Linear regression model for which the variance-covariance matrix is to be computed, requires class "lm" or "glm" |
type |
Indicator which type of variance-covariance matrix is to be computed: 0 - no clustering, 1 - clustering using |
var_cluster |
Vector, matrix, or data.frame containing the variables that are used for clustering |
The option type == 0
uses vcov
from the base
package. When type == 1
is selected, the variance-covariance matrix is computed using the cluster.vcov
command from the multiwayvcov
package: multiwayvcov::cluster.vcov(model, var_cluster)
. For type == 2
, the variance-covariance matrix is computed using the cluster.boot
command from the multiwayvcov
package: multiwayvcov::cluster.boot(model, var_cluster, R = 1000, boot_type = "wild", wild_type = function() sample(c(-1, 1), 1))
.
A list of class ("mod_vcov" "list") containing two items:
model |
The linear regression model supplied as input |
vcov_mat |
A variance-covariance matrix for the linear regression model supplied in the function |
For output's attributes depend on the type
selected in the function call:
|
The attribute "type" is set to "standard" |
|
The attribute "type" is set to "robust", the attribute "var_cluster" takes the value supplied as variable |
|
The attribute "type" is set to "robust_boot", the attribute "var_cluster" takes the value supplied as variable |
1 2 3 4 5 6 7 8 | data <- supportR::create_data()
mod1 <- lm(firm_value ~ profit + cogs + rnd + competition * board_size, data = data)
model_vcov(model = mod1, type = 0, var_cluster = NULL)
model_vcov(model = mod1, type = 1, var_cluster = data$country)
mod2 <- glm(female_ceo ~ profit + cogs + rnd + ceo_age * board_size, data = data, family = "binomial")
model_vcov(model = mod2, type = 2, var_cluster = data$industry)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.