  Many recently developed Bayesian methods have focused on sparse signal
detection. However, much less work has been done addressing the natural
follow-up question: how to make valid inferences for the magnitude of those
signals after selection. Ordinary Bayesian credible intervals suffer from
selection bias, owing to the fact that the target of inference is chosen
adaptively. Existing Bayesian approaches for correcting this bias produce
credible intervals with poor frequentist properties, while existing frequentist
approaches require sacrificing the benefits of shrinkage typical in Bayesian
methods, resulting in confidence intervals that are needlessly wide. We address
this gap by proposing a nonparametric empirical-Bayes approach for constructing
optimal selection-adjusted confidence sets. Our method produces confidence sets
that are as short as possible on average, while both adjusting for selection
and maintaining exact frequentist coverage uniformly over the parameter space.
Our main theoretical result establishes an important consistency property of
our procedure: that under mild conditions, it asymptotically converges to the
results of an oracle-Bayes analysis in which the prior distribution of signal
sizes is known exactly. Across a series of examples, the method outperforms
existing frequentist techniques for post-selection inference, producing
confidence sets that are notably shorter but with the same coverage guarantee.
