Estimating panel data models with endogeneity and selection