clustSE: Cluster robust standard errors with degrees of freedom...

View source: R/clustSE.R

clustSER Documentation

Cluster robust standard errors with degrees of freedom adjustments (for lm and glm objects)

Description

Function to compute the CR0, CR1, CR2 cluster robust standard errors (SE) with Bell and McCaffrey (2002) degrees of freedom (df) adjustments. Useful when dealing with datasets with a few clusters. Shows output using different CR types and degrees of freedom choices (for comparative purposes only). For linear and logistic regression models (as well as other GLMs). Computes the BRL-S2 variant.

Usage

clustSE(mod, clust = NULL, digits = 3, ztest = FALSE)

Arguments

mod

The lm model object.

clust

The cluster variable (with quotes).

digits

Number of decimal places to display.

ztest

If a normal approximation should be used as the naive degrees of freedom. If FALSE, the between-within degrees of freedom will be used.

Value

A data frame with the CR adjustments with p-values.

estimate

The regression coefficient.

se.unadj

The model-based (regular, unadjusted) SE.

CR0

Cluster robust SE based on Liang & Zeger (1986).

CR1

Cluster robust SE (using an adjustment based on number of clusters).

CR2

Cluster robust SE based on Bell and McCaffrey (2002).

tCR2

t statistic based on CR2.

dfn

Degrees of freedom(naive): can be infinite (z) or between-within (default). User specified.

dfBM

Degrees of freedom based on Bell and McCaffrey (2002).

pv.unadj

p value based on model-based standard errors.

CR0pv

p value based on CR0 SE with dfBM.

CR0pv.n

p value based on CR0 SE with naive df.

CR1pv

p value based on CR1 SE with dfBM.

CR1pv.n

p value based on CR1 SE with naive df.

CR2pv

p value based on CR2 SE with dfBM.

CR2pv.n

p value based on CR2 SE with naive df.

References

Bell, R., & McCaffrey, D. (2002). Bias reduction in standard errors for linear regression with multi-stage samples. Survey Methodology, 28, 169-182. (link)

Liang, K.Y., & Zeger, S. L. (1986). Longitudinal data analysis using generalized linear models. Biometrika, 73(1), 13–22. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/biomet/73.1.13")}

Examples

clustSE(lm(mpg ~ am + wt, data = mtcars), 'cyl')
data(sch25)
clustSE(lm(math ~ ses + minority + mses + mhmwk, data = sch25), 'schid')


flh3/CR2 documentation built on March 11, 2024, 9:20 p.m.