Parametric simultaneous (1 - alpha) confidence intervals over a family of treatment effects
Source:R/simultaneous_cis.R
simultaneousCIs.RdComputes simultaneous (family-wise) confidence intervals for a user-
specified family of treatment effects from a fitted FETWFE / ETWFE /
BETWFE / twfeCovs object. The simultaneous critical value c_{1 - alpha}
is the (1 - alpha) quantile of max_k |Z_k| where Z follows a
multivariate normal with correlation matrix cov2cor(Sigma); it is
computed deterministically via mvtnorm::qmvnorm(). Under Faletto (2025)
Theorem 6.4(c') tight Gaussianity and Assumption (Psi-IF), the family of
psi-linear effects is asymptotically multivariate normal with a covariance
that is estimable from the package's existing variance machinery; under the
paper's fixed-dim framing no high-dimensional correction is needed.
The pointwise critical value qnorm(1 - alpha/2) (per-effect coverage) and
the Bonferroni-conservative critical value qnorm(1 - alpha/(2K)) (family-
wise coverage with no correlation assumption) are returned for side-by-side
comparison. Under method = "analytic", the simultaneous critical value
always lies between them (typically smaller than Bonferroni when K > 1 and
effects are correlated, as in difference-in-differences, where effects share
the regression-coefficient variance piece).
Under method = "bootstrap", $critical_value is floored at the pointwise
value but is not capped above at the Gaussian Bonferroni value because
finite-sample multiplier distributions are non-Gaussian and subject to
Monte-Carlo error.
Usage
simultaneousCIs(
result,
family = c("event_study", "cohort", "all_post_treatment", "custom"),
alpha = NULL,
contrasts = NULL,
method = c("analytic", "bootstrap"),
B = 1000L,
seed = NULL,
multiplier = c("rademacher", "mammen", "webb"),
lambda_c = 1,
riesz_max_iter = 5000L,
riesz_tol = 1e-09,
cv_time_budget = Inf
)Arguments
- result
A fitted object of class
"fetwfe","fetwfe_etwfe","betwfe", or"twfeCovs".- family
Character; one of
"event_study","cohort","all_post_treatment", or"custom". See Details for each family's resolution.- alpha
Numeric in
(0, 1); significance level. DefaultNULL, which inherits the fit's ownalpha(the level itscatt_df/ displayed simultaneous bands were built at), sosimultaneousCIs(fit)reproduces the fit's shown simultaneous bounds. Pass an explicit value to override.- contrasts
For
family = "custom", aK x num_treatsmatrix whose rows give theKlinear combinations of the underlying per-(g, t)treatment-effect vector (themultcomp::glht()convention;num_treatsis the number of estimated effects, equal toGfortwfeCovs). Ignored for the other families. Note that the"custom"family omits the cohort-probability variance term (Sigma_2 = 0), so a custom contrast that pools across cohorts in a probability-weighted way is anti-conservative (its band can under-cover). Onlyfamily = "event_study"carries that term, for event-time effects pooled across cohorts; no family adds it to a custom contrast.- method
Character; how the simultaneous critical value is computed.
"analytic"(default) uses the exact multivariate-normal sup-t quantile viamvtnorm::qmvnorm()."bootstrap"uses the multiplier bootstrap of Chernozhukov, Chetverikov & Kato (2013): it perturbs the per-unit influence functions and reads the sup-t critical value off the bootstrap distribution. The two are asymptotically equivalent; the bootstrap scales better to large effect families and is heteroskedasticity/cluster-robust by construction (it always reports cluster-robust per-unit standard errors, regardless of the fit'sse_type).method = "bootstrap"supports all four families. Forfamily = "event_study"the bootstrap additionally perturbs the per-unit cohort-probability (propensity) influence function with its own independent multiplier stream – a two-channel bootstrap matching the analytic varianceSigma = Sigma_1 + Sigma_2(the event-study family is the one whoseSigma_2is non-zero, because each event-time effect pools across cohorts weighted by the estimated cohort probabilities). When the (full) design is high-dimensional (p >= NT) – where the analytic Gram inverse need not exist – the bootstrap uses the full-design desparsified construction, with per-effect nodewise directions. This desparsifiedp >= NTband path (fetwfe()fits only) generalizes the paper's scalar debiased construction — whose overall-ATT coverage is validated near-nominally in simulation (Theoremdebiased.highdim.thm, Faletto 2025) — to a family of functionals. Its family-wise coverage is likewise validated near-nominally (Theoremdebiased.highdim.joint.thm): ~0.92 over the event-study family (K = 7) at thep >= NTanchor of Faletto (2025), the band sibling of the scalar result (~0.94); the cohort and all-post-treatment families are covered by the same theorem but were not separately simulated. As with the scalar, validity rests on the sparsity / restricted-eigenvalue primitives (assumed, not proved), so inspect the returnedfeasibility/convergeddiagnostics. The desparsified path covers all four families (a high-dimensionalfamily = "event_study"fit additionally carries the propensity channelF_pi). In the high-dimensional regime the band is centered on the debiased estimate (the high-dimensional FETWFE theory correction), not the post-selection bridge estimate; fixed-p bands center on the (unbiased) bridge estimate as before. Because this desparsified bootstrap band is built from the empirical per-unit influence function – needing neither GLS whitening norsig_eps_sq– it also accepts a high-dimensionalgls = FALSEfetwfe fit (calc_ses = FALSE).method = "analytic"still requires valid analytic SEs (aq < 1,gls = TRUE, rank-satisfied fit). Which method is valid atp >= NTis a property of the function rather than of this argument alone; see the "High-dimensional (p >= NT) bands" paragraph of Details, which also documents the warning such a call emits.- B
Integer; number of multiplier-bootstrap replicates (
method = "bootstrap"only). Must be a positive integer no greater than.Machine$integer.max. Default1000.- seed
Optional integer within
+/- .Machine$integer.max. If supplied, the bootstrap draws are reproducible (the ambient random-number stream is saved and restored around them). IfNULL(default), the draws come from the ambient generator, so results vary run to run. Ignored whenmethod = "analytic".- multiplier
Character; the multiplier-weight distribution for the bootstrap:
"rademacher"(default,+/-1),"mammen"(the Mammen 1993 two-point distribution), or"webb"(the Webb 2013 six-point distribution, preferred with very few clusters). Ignored whenmethod = "analytic".- lambda_c, riesz_max_iter, riesz_tol
Controls for the high-dimensional (
p >= NT) bootstrap, where each effect's debiasing direction is a nodewise (desparsified-lasso)riesz_lasso()solve.lambda_cis the leading constant of the penaltylambda_node = lambda_c * max(|a|) * sqrt(log p / N): either a single positive number (the default1.0= theory scale) or the string"cv", which selects the constant per fit by cross-validation (on the overall-ATT direction, so one constant serves every band effect; #295). Smaller fixed values can leave directions infeasible (a warning fires and those bands are unreliable). Ignored whenp < NTormethod = "analytic". The default stays the fixed1.0; the family-wise coverage validated in Faletto (2025) used the"cv"selector (lambda_c~ 0.54, feasibility 1.0).- cv_time_budget
Numeric; a wall-clock backstop (in seconds) for the
lambda_c = "cv"cross-validation.Inf(the default) leaves selection fully deterministic / reproducible; a finite value stops the CV early and falls back to the theory scale (lambda_c = 1.0) with a warning, so an adversarial high-dimensional draw cannot spin indefinitely. Whether a finite budget fires depends on machine speed, so the result can too. Ignored unlesslambda_c = "cv"andp >= NT.
Value
An object of S3 class "simultaneous_cis": a list with
- ci
A data frame with columns
effect,estimate,simultaneous_ci_low,simultaneous_ci_high,pointwise_ci_low,pointwise_ci_high(one row per effect in the family).- adjusted_p_values
Numeric vector of length
K: the single-step max-T multiplicity-adjusted (family-wise) p-value for each effect, the exact dual of the simultaneous band (a coefficient lies outside the(1 - alpha)band iff its adjusted p-value is< alpha). Computed viamvtnorm::pmvnorm()over the same correlation matrix the band uses (or, in the conservative fallback described in Details, the Bonferroni adjustmentmin(1, K * pointwise_p)).NAfor degenerate effects. (#200)- critical_value
The simultaneous critical value
c_{1 - alpha}(or, in the conservative fallback described in Details, the Bonferroni critical valueqnorm(1 - alpha/(2K))).- pointwise_critical_value
qnorm(1 - alpha/2), for reference.- bonferroni_critical_value
qnorm(1 - alpha/(2K)), for reference.- family
The requested family (character).
- alpha
The significance level used.
- K
The number of effects in the family (integer).
For method = "bootstrap" the list additionally carries method, B,
seed, multiplier, and regime ("fixed-p" or "high-dimensional"); the
critical_value is the bootstrap sup-t quantile and the standard errors
backing ci are the cluster-robust per-unit ones (so for a non-cluster fit
the bootstrap band may differ from the analytic homoskedastic band). A
"high-dimensional" fit additionally carries per-effect feasibility,
converged, and lambda_node (the nodewise-direction diagnostics), plus
lambda_c (the leading constant used) and lambda_c_selection ("fixed"
or "cv"). When lambda_c = "cv" it also carries lambda_cv, the
cross-validation diagnostics (the grid, the per-grid feasibility flags and CV
losses, and whether the theory-scale fallback fired).
Details
Family resolution and K. "event_study" resolves to one effect per
post-treatment event time e from 0 to T - 2 that at least one cohort
reaches (K <= T - 1); "cohort" to one effect per treated cohort
(K = G); "all_post_treatment" to one effect per (g, t) cell
(K = num_treats); "custom" to the K = nrow(contrasts) user-supplied
contrasts.
Joint covariance. The K x K covariance Sigma = Sigma_1 + Sigma_2 is
reconstructed at call time from the fit's stored slots (design matrix,
selected support, theta_hat / beta_hat, cohort_probs_overall,
sig_eps_sq). Sigma_1 is the regression-coefficient piece and Sigma_2
the cohort-probability piece, generalizing the package's per-point variance
machinery (the same machinery eventStudy() uses). By construction
sqrt(diag(Sigma)) equals the package's existing per-point standard errors
for the corresponding effects. The Sigma blocks are not persisted on the
fit; re-derivation is sub-second.
Degenerate effects. On every band built from the selected support, which
is every band but the desparsified one a high-dimensional fetwfe() fit gets
under method = "bootstrap", an effect whose entire contribution to that
support is zeroed by the bridge penalty has a standard error of exactly 0 by
construction, so its simultaneous and pointwise CIs collapse to a point at
the estimate and it is excluded from the joint correlation matrix. A signed
"custom" contrast whose weights cancel on that support is degenerate too:
its estimate and standard error are exactly 0 or rounding error, so which
side of zero its point-sized interval falls on carries no information, and
its NA adjusted p-value is the signal.
High-dimensional (p >= NT) bands. One route out of the four is
uniformly valid: a fetwfe() fit under
method = "bootstrap". That is the full-design desparsified band of
Theorem debiased.highdim.joint.thm (Faletto 2025), whose family-wise
coverage is validated near-nominally in simulation.
Every other p >= NT combination returns the fixed-p post-selection
band on the selected support instead, and that band is not valid there: a
#308 coverage study measures it at roughly 0.09 against 0.95 nominal, even
when the selected support is low-dimensional, because the bridge shrinks
the band center toward zero and the post-selection standard error understates
variability. Sparsity does not rescue it; only debiasing does. Concretely
this covers a non-fetwfe() fit (e.g. betwfe()) on either method –
the desparsified construction is fetwfe()-only, so no valid
high-dimensional band exists for those estimators – and a fetwfe() fit on
the method = "analytic" default, where the remedy is simply to pass
method = "bootstrap".
The band is still returned rather than replaced by an error, but every such
call emits a warning naming the applicable remedy. The warning is a
classed condition, "fetwfe_highdim_postselection_band", so it can be caught
or muffled precisely:
withCallingHandlers(
simultaneousCIs(fit),
fetwfe_highdim_postselection_band = function(w) invokeRestart("muffleWarning")
)eventStudy() signals the same condition, for the same reason. It does
not fire at fit time (a ci_type = "simultaneous" fit is silent), nor
inside print(), summary(), or plot(), all three of which muffle it; of
those, print() and summary() render a two-line caveat under their CATT
preview instead, and plot() renders none. It also does not fire on the
p >= NT all-zero-support path, which returns a degenerate band and carries
its own (#304) condition already.
A gls = FALSE (calc_ses = FALSE) high-dimensional fetwfe() fit has no
analytic standard errors at all, so method = "analytic" errors there rather
than warning; method = "bootstrap" still works, because the desparsified
band is built from the empirical per-unit influence function.
Paper grounding. Theorem 6.4(c') tight Gaussianity (Faletto 2025) guarantees the joint asymptotic normality; Assumption (Psi-IF) is the influence-function condition the package's default cohort-sample-proportions estimator satisfies.
Conservative fallback. The function falls back to Bonferroni-corrected
pointwise CIs only when the fit was made with se_type = "conservative"
and without indep_counts, under the default method = "analytic": the
Cauchy-Schwarz upper bound used for the conservative scalar SE does not
generalize to a K x K covariance matrix. It then emits a brief
message(), and $critical_value is the Bonferroni value. Two cases are
handled before this branch: a fit without standard errors stops, and an
all-zeroed support returns the degenerate band.
Numerical integration. The critical value is computed via
mvtnorm::qmvnorm(..., algorithm = mvtnorm::GenzBretz()) (mvtnorm's default
quasi-Monte Carlo integrator). That critical value, and the adjusted p-values
mvtnorm::pmvnorm() computes alongside it, are then kept within their exact
bounds: [qnorm(1 - alpha/2), qnorm(1 - alpha/(2m))] for the critical value,
and [p, min(1, m * p)] for each effect's adjusted p-value, where p is the
effect's pointwise p-value and m the number of non-degenerate effects.
mvtnorm is an
Imports dependency (as of version 1.16.0, when simultaneous bands became
the default reported confidence interval; see the ci_type argument of
fetwfe()). The function uses it only when K > 1 and the conservative
fallback does not apply (the K = 1 and fallback paths bypass the
dependency), and retains a defensive stop() with an actionable message if
it is somehow unavailable (e.g., a corrupted install).
Determinism contract. The function is deterministic in its inputs: the
same fit plus the same family, alpha, and contrasts always produces
the same critical value across calls. This is achieved by wrapping the
internal mvtnorm::qmvnorm() call with a save/restore of the caller's
.Random.seed and a fixed internal set.seed(1L) immediately before the
call. The function does NOT mutate the caller's .Random.seed (the
save/restore via on.exit() leaves the caller's RNG state identical pre- and
post-call), matching the convention adopted by
R/fetwfe_core.R::getBetaCV() in PR #181 / v1.13.5. Users do not need to
call set.seed() before simultaneousCIs() to get reproducible results,
and downstream RNG-using code observes no perturbation.
References
Chernozhukov, V., Chetverikov, D., & Kato, K. (2013). Gaussian Approximations and Multiplier Bootstrap for Maxima of Sums of High-Dimensional Random Vectors. The Annals of Statistics 41(6), 2786-2819.
Faletto, G. (2025). Fused Extended Two-Way Fixed Effects for Difference-in-Differences with Staggered Adoptions. arXiv:2312.05985.
Hothorn, T., Bretz, F., & Westfall, P. (2008). Simultaneous Inference in General Parametric Models. Biometrical Journal 50(3), 346-363.
See also
eventStudy() for the per-point event-study estimates and Wald
intervals that family = "event_study" provides simultaneous bands over.
Examples
# \donttest{
coefs <- genCoefs(G = 3, T = 6, d = 2, density = 0.5, eff_size = 2)
sim <- simulateData(coefs, N = 120, sig_eps_sq = 1, sig_eps_c_sq = 0.5, seed = 123)
fit <- fetwfeWithSimulatedData(sim)
sci <- simultaneousCIs(fit, family = "event_study", alpha = 0.05)
print(sci)
#> Parametric simultaneous (1 - alpha) confidence intervals
#> Family: event_study, K = 5, alpha = 0.05
#> Simultaneous critical value: 2.4451 (pointwise 1.9600, Bonferroni 2.5758)
#>
#> effect estimate simultaneous_ci_low simultaneous_ci_high pointwise_ci_low
#> e0 0.000000 0.0000000 0.000000 0.000000
#> e1 1.359442 0.9980238 1.720860 1.069735
#> e2 3.241190 2.8536131 3.628768 2.930514
#> e3 3.701220 2.9973870 4.405053 3.137038
#> e4 5.754599 5.3142530 6.194944 5.401624
#> pointwise_ci_high
#> 0.000000
#> 1.649149
#> 3.551867
#> 4.265403
#> 6.107573
# }