A new study set out to answer this question. They looked at 150 children and determined that those who were trained between ages 24 and 32 months had the most success.
Of course, every child is different. Some are ready earlier, some later. But this is probably a good general rule to follow.
You can read more about the study here.