Stability of epidemic models with waning immunity