Skip to contents

Sandwich variance summed over clusters with the G/(G-1) correction and a t(G-1) reference. Mirrors morie.fn.clstcr.

Usage

morie_cluster_robust_effect(y, d, cluster)

Arguments

y

Outcome.

d

Binary 0/1 treatment.

cluster

Cluster identifier.

Value

List with estimate, se_cluster, se_naive, p_value, n_clusters, n.

References

Cameron AC, Miller DL (2015). Journal of Human Resources 50(2), 317-372.

Examples

set.seed(1)
n <- 3000
x <- stats::rnorm(n)
e <- pmin(pmax(1/(1 + exp(-x)), 0.05), 0.95)
tr <- as.numeric(stats::runif(n) < e)
y <- x + stats::rnorm(n) + 3 * tr
L <- stats::rnorm(n)
a <- as.numeric(stats::runif(n) < 1/(1 + exp(-1.5 * L)))
morie_g_formula(y, a, L)
#> $EY1
#> [1] 1.46452
#> 
#> $EY0
#> [1] 1.413564
#> 
#> $ate
#> [1] 0.05095646
#> 
#> $n
#> [1] 3000
#> 
morie_cluster_robust_effect(y = y, d = a, cluster = e)
#> $estimate
#> [1] 0.06747841
#> 
#> $se_cluster
#> [1] 0.08617385
#> 
#> $se_naive
#> [1] 0.08574931
#> 
#> $p_value
#> [1] 0.4336599
#> 
#> $n_clusters
#> [1] 2990
#> 
#> $n
#> [1] 3000
#>