Early warning signals of critical transitions in ecology and epidemiology