Package 'ebci'

Title: Robust Empirical Bayes Confidence Intervals
Description: Computes empirical Bayes confidence estimators and confidence intervals in a normal means model. The intervals are robust in the sense that they achieve correct coverage regardless of the distribution of the means. If the means are treated as fixed, the intervals have an average coverage guarantee. The implementation is based on Armstrong, Kolesár and Plagborg-Møller (2022) <doi:10.3982/ECTA18597>.
Authors: Michal Kolesár [aut, cre] , Tim Armstrong [ctb], Mikkel Plagborg-Møller [ctb]
Maintainer: Michal Kolesár <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0.9000
Built: 2025-02-15 02:53:50 UTC
Source: https://github.com/kolesarm/ebci

Help Index


Compute average coverage critical value under moment constraints.

Description

Computes the critical value cvaα(m2,κ)cva_{\alpha}(m_{2}, \kappa) from Armstrong, Kolesár, and Plagborg-Møller (2022).

Usage

cva(m2, kappa = Inf, alpha = 0.05, check = TRUE)

Arguments

m2

Bound on second moment of the normalized bias, m2m_{2}

kappa

Bound on the kurtosis of the normalized bias, κ\kappa

alpha

Determines confidence level, 1α1-\alpha.

check

If TRUE, verify accuracy of the solution by checking that the implied least favorable distribution satisfies the m2 and kappa constraints and yields the same non-coverage rate. If this fails (perhaps due to numerical accuracy issues), solve a finite-grid approximation (by discretizing the support of the normalized bias) to the primal linear programming problem, and check that it agrees with the dual solution.

Value

Returns a list with 4 components:

cv

Critical value for constructing two-sided confidence intervals.

alpha

The argument alpha.

x

Support points for the least favorable distribution for the squared normalized bias, b2b^2.

p

Probabilities associated with the support points.

References

Tim Armstrong, Michal Kolesár, and Mikkel Plagborg-Møller. Robust empirical Bayes confidence intervals. Econometrica, 90(6):2567–2602, November 2022. doi:10.3982/ECTA18597.

Examples

# Usual critical value
cva(m2=0, kappa=Inf, alpha=0.05)
# Larger critical value that takes bias into account. Only uses second moment
# constraint on normalized bias.
cva(m2=4, kappa=Inf, alpha=0.05)
# Add a constraint on kurtosis. This tightens the critical value.
cva(m2=4, kappa=3, alpha=0.05)

Neighborhood effects data from Chetty and Hendren (2018)

Description

This dataset contains a subset of the publicly available data from Chetty and Hendren (2018). It contains raw estimates and standard errors of neighborhood effects at the commuting zone level

Usage

cz

Format

A data frame with 741 rows corresponding to commuting zones (CZ) and 10 columns corresponding to the variables:

cz

Commuting zone ID

czname

Name of CZ

state

2-digit state code

pop

Population according to the year 2000 Census

theta25

Fixed-effect estimate of the causal effect of living in the CZ for one year on children's percentile rank in the national distribution of household earnings at age 26 relative to others in the same birth cohort for children growing up with parents at the 25th percentile of national income distribution

theta75

Fixed-effect estimate of the causal effect of living in the CZ for one year on children's percentile rank in the national distribution of household earnings at age 26 relative to others in the same birth cohort for children growing up with parents at the 75th percentile of national income distribution

se25

Standard error of theta25

se75

Standard error of theta75

stayer25

Average percentile rank in the national distribution of household earnings at age 26 relative to others in the same birth cohort for stayers (children who grew up in the CZ and did not move) with parents at the 25th percentile of national income distribution.

stayer75

Average percentile rank in the national distribution of household earnings at age 26 relative to others in the same birth cohort for stayers (children who grew up in the CZ and did not move) with parents at the 75th percentile of national income distribution.

Source

https://opportunityinsights.org/data/?paper_id=599

References

Chetty, R., & Hendren, N. (2018). The Impacts of Neighborhoods on Intergenerational Mobility II: County-Level Estimates. The Quarterly Journal of Economics, 133(3), 1163–1228. doi:10.1093/qje/qjy006


Compute empirical Bayes confidence intervals by shrinking toward regression

Description

Computes empirical Bayes estimators based on shrinking towards a regression, and associated robust empirical Bayes confidence intervals (EBCIs), as well as length-optimal robust EBCIs.

Usage

ebci(
  formula,
  data,
  se,
  weights = NULL,
  alpha = 0.1,
  kappa = NULL,
  wopt = FALSE,
  fs_correction = "PMT"
)

Arguments

formula

object of class "formula" (or one that can be coerced to that class) of the form Y ~ predictors, where Y is a preliminary unbiased estimator, and predictors are predictors XX that guide the direction of shrinkage. For shrinking toward the grand mean, use Y ~ 1, and for shrinking toward 0 use Y ~ 0

data

optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the preliminary estimator Y and the predictors. If not found in data, these variables are taken from environment(formula), typically the environment from which the function is called.

se

Standard errors σ\sigma associated with the preliminary estimates Y

weights

An optional vector of weights to be used in the fitting process in computing δ\delta, μ2\mu_2 and κ\kappa. Should be NULL or a numeric vector.

alpha

Determines confidence level, 1α1-\alpha.

kappa

If non-NULL, use pre-specified value for the kurtosis κ\kappa of θXδ\theta-X'\delta (such as Inf), instead of computing it.

wopt

If TRUE, also compute length-optimal robust EBCIs. These are robust EBCIs centered at estimates with the shrinkage factor wiw_i chosen to minimize the length of the resulting EBCI.

fs_correction

Finite-sample correction method used to compute μ2\mu_2 and κ\kappa. These corrections ensure that we do not shrink the preliminary estimates Y all the way to zero. If "PMT", use posterior mean truncation, if "FPLIB" use limited information Bayesian approach with a flat prior, and if "none", truncate the estimates at 0 for μ2\mu_2 and 1 for κ\kappa.

Value

Returns a list with the following components:

mu2

Estimated second moment of θXδ\theta-X'\delta, μ2\mu_2. Vector of length 2, the first element corresponds to the estimate after the finite-sample correction as specified by fs_correction, the second element is the uncorrected estimate.

kappa

Estimated kurtosis κ\kappa of θXδ\theta-X'\delta. Vector of length 2 with the same structure as mu2.

delta

Estimated regression coefficients δ\delta

X

Matrix of regressors

alpha

Determines confidence level 1α1-\alpha used.

df

Data frame with components described below.

df has the following components:

w_eb

EB shrinkage factors, μ2/(μ2+σi2)\mu_{2}/(\mu_{2}+\sigma^2_i)

w_opt

Length-optimal shrinkage factors

ncov_pa

Maximal non-coverage of parametric EBCIs

len_eb

Half-length of robust EBCIs based on EB shrinkage, so that the intervals take the form cbind(th_eb-len_eb, th_eb+len_eb)

len_op

Half-length of robust EBCIs based on length-optimal shrinkage, so that the intervals take the form cbind(th_op-len_op, th_op+len_op)

len_pa

Half-length of parametric EBCIs, which take the form cbind(th_eb-len_pa, th_eb+len_a)

len_us

Half-length of unshrunk CIs, which take the form cbind(th_us-len_us, th_us+len_us)

th_us

Unshrunk estimate YY

th_eb

EB estimate.

th_op

Estimate based on length-optimal shrinkage.

se

Standard error σ\sigma, as supplied by the argument se

weights

Weights used

residuals

The residuals YiXiδY_i-X_i\delta

References

Tim Armstrong, Michal Kolesár, and Mikkel Plagborg-Møller. Robust empirical Bayes confidence intervals. Econometrica, 90(6):2567–2602, November 2022. doi:10.3982/ECTA18597.

Examples

## Same specification as in empirical example in Armstrong, Kolesár
## and Plagborg-Møller (2022), but only use data on NY commuting zones
r <- ebci(theta25 ~ stayer25, data=cz[cz$state=="NY", ],
          se=se25, weights=1/se25^2)