Title
commarobust(fit, clust_var = NULL, type = "HC2", alpha = 0.05)
fit | A model object, typically created by lm, glm, or many other model fitting functions. |
---|---|
clust_var | An optional numeric vector of length N that describes the clusters that units are in. May not include NAs. Is NULL by default. If specified, cluster-robust standard errors will be estimated. |
type | A string indicating the type of heterskedasticty-robust standard errors to be estimated. Is ignored if clust_var is specificed. Is "HC2" by default, because these are equivalent to Neyman standard errors (See Aronow and Samii). |
alpha | Used for construction of (1 - alpha) confidence intervals. Defaults to 0.05. |
A matrix of coefficients, standard errors, t-statistics, and p-values
library(randomizr)#> Warning: package ‘randomizr’ was built under R version 3.3.2Y <- rnorm(100) Z <- complete_ra(100) fit <- lm(Y ~ Z) commarobust(fit)#> Estimate Std. Error t value Pr(>|t|) #> (Intercept) 0.1996898 0.1444663 1.382259 0.1700345 #> Z -0.2375446 0.2079651 -1.142233 0.2561403# Clustered Y <- rnorm(100) clust_var <- rep(letters[1:10], 10) Z <- cluster_ra(clust_var = clust_var) fit <- lm(Y ~ Z) commarobust(fit, clust_var = clust_var)#> Estimate Std. Error t value Pr(>|t|) #> (Intercept) -0.04796144 0.1234366 -0.38855121 0.6984510 #> Z -0.00546281 0.1671615 -0.03267983 0.9739964