Selection and educational attainment : why some children are left behind? Evidence from a middle-income country