Essays on discrete multivalued treatments with endogeneity and heterogeneous counterfactual errors