General relationship for cation and anion doping effects on ferroelectric HfO2 formation