Many studies have estimated the effect of taxes on taxable income. To account for nonlinear taxes these studies either use instrumental variables approaches that are not fully consistent or impose strong functional form assumptions. None allow for general heterogeneity in preferences. In this paper we derive the expected value and distribution of taxable income conditional on a nonlinear budget set, allowing general heterogeneity and optimization error in taxable income. We find an important dimension reduction and use that to develop nonparametric estimation methods. We show how to nonparametrically estimate the expected value of taxable income imposing all the restrictions of utility maximization and allowing for measurement errors. We characterize what can be learned nonparametrically from kinks about compensated tax effects. We apply our results to Swedish data and estimate for prime age males a significant net of tax elasticity of 0.21 and a significant nonlabor income effect of about -1. The income effect is substantially larger in magnitude than it is found to be in other taxable income studies.