This paper introduces Stata commands [R] npivreg and [R] npivregcv, which implement nonparametric instrumental variable (NPIV) estimation methods without and with a cross-validated choice of tuning parameters, respectively. Both commands are able to impose monotonicity of the estimated function. The use of such a shape restriction may signicantly improve the performance of the NPIV estimator (Chetverikov and Wilhelm 2017). This is because the ill-posedness of the NPIV estimation problem leads to unconstrained estimators that suffer from particularly poor statistical properties such as very high variance. The constrained estimator that imposes the monotonicity, on the other hand, signicantly reduces variance by removing oscillations of the estimator that is nonmonotone.
We provide a small Monte Carlo experiment to study the estimators' finite sample properties and an application to the estimation of gasoline demand functions.