Skip to content

Repository files navigation

R-CMD-check Coverage status CRAN_Status_Badge Download statistics

dfadjust

This package implements the small-sample degrees of freedom adjustments for robust and cluster-robust standard errors in linear regression described in Imbens and Kolesár (2016).

See vignette dfadjust for description of the package (available through vignette("dfadjust") once package is installed), and the package manual for documentation of the package functions.

Example

No clustering:

x <- sin(1:10)
y <- tan(1:10)
fm <- lm(y~x)
dfadjustSE(fm)

Clustering:

clustervar <- as.factor(c(rep(1, 6), rep(2, 2), rep(3, 2)))
dfadjustSE(fm, clustervar)

Here we defined the first six observations to be in cluster 1, the next two in cluster 2, and the last three in cluster three.

The package handles cluster fixed effects, and large clusters. Computing the adjustment with one million observations and 50 clusters takes about 5 seconds:

N <- 10^6
x <- sin(1:N)
y <- seq(N)
clustervar <- as.factor(rep(1:50, each=N/50))
fm <- lm(y~x+clustervar)
## Inference on x, i.e. second coefficient
dfadjustSE(fm, ell=2, clustervar=clustervar)

Installation

You can install the released version of dfadjust from CRAN with:

install.packages("dfadjust")

Alternatively, you can get the current development version from GitHub:

if (!requireNamespace("remotes")) {
  install.packages("remotes")
}
remotes::install_github("kolesarm/Robust-Small-Sample-Standard-Errors")

About

Degrees of freedom adjustments for robust standard errors described in Imbens and Kolesár (2016, Review of Economics and Statistics)

Resources

Stars

31 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages