  A major challenge in instrumental variables (IV) analysis is to find
instruments that are valid, or have no direct effect on the outcome and are
ignorable. Typically one is unsure whether all of the putative IVs are in fact
valid. We propose a general inference procedure in the presence of invalid IVs,
called Two-Stage Hard Thresholding (TSHT) with voting. TSHT uses two hard
thresholding steps to select strong instruments and generate candidate sets of
valid IVs. Voting takes the candidate sets and uses majority and plurality
rules to determine the true set of valid IVs. In low dimensions, if the
sufficient and necessary identification condition under invalid instruments is
met, which is more general than the so-called 50% rule or the majority rule,
our proposal (i) correctly selects valid IVs, (ii) consistently estimates the
causal effect, (iii) produces valid confidence intervals for the causal effect,
and (iv) has oracle-optimal width. In high dimensions, we establish nearly
identical results without oracle-optimality. In simulations, our proposal
outperforms traditional and recent methods in the invalid IV literature. We
also apply our method to re-analyze the causal effect of education on earnings.
