### Plots - new cases model.au.fit.fn <- splinefun(all_days, model.au$fit) model.au.fit.deriv <- model.au.fit.fn(all_days, deriv = 1) model.au.upr.deriv <- model.au.fit.deriv + (model.au$upr - model.au$fit) model.au.lwr.deriv <- model.au.fit.deriv - (model.au$fit - model.au$lwr) model.au.lwr.deriv[model.au.lwr.deriv < 0] <- 0 # scaling factor for fixed elements on chart sf = 800 / 1800 alphaPI = 0.1 p1 <- ggplot(data=au_covid, aes(x=day, y=new)) + xlab("") + ylab("Confirmed COVID-19 cases (Australia)") + geom_vline(xintercept=today, color = "grey") + geom_hline(yintercept=-150*sf) + annotate("text", x=1, y=-200*sf, label="Jun 1") + annotate("text", x=15, y=-200*sf, label="Jun 15") + annotate("text", x=30+1, y=-200*sf, label="Jul 1") + annotate("text", x=30+15, y=-200*sf, label="Jul 15") + annotate("text", x=30+31+1, y=-200*sf, label="Aug 1") + annotate("text", x=30+31+15, y=-200*sf, label="Aug 15") + annotate("text", x=30+31+31+1, y=-200*sf, label="Sep 1") + annotate("text", x=30+31+31+15, y=-200*sf, label="Sep 15") + annotate("text", x=30+31+31+30+1, y=-200*sf, label="Oct 1") + annotate("label", x=5, y=1800*sf, label="Simple moving average (7 days)", size=5.5, hjust=0) + annotate("text", x=5, y=1600*sf, label= paste(au_covid$date[today], "@", time, "GMT+10"), hjust=0) + geom_point(colour="white", size = 3.2) + geom_point(colour="grey20", size = 2.8) + # geom_ma(n=7, ma_fun=EMA, colour="dark green", linetype=1, size = 1) + geom_ma(n=7, colour="orange", linetype=1, size = 1) + # geom_smooth(colour="red3", fill="NA", method="gam") + # geom_line(aes(y=model.au.fit.deriv), colour="blue", size = 1, linetype=2) + annotate("label", x=(today), y=-85*sf, label=au_covid$date[today], size=3) + coord_cartesian(ylim = c(-250*sf, 1800*sf), xlim = c(1,today+2)) p2 <- ggplot(data=au_covid, aes(x=day, y=new)) + xlab("") + ylab("") + geom_vline(xintercept=today, color = "grey") + geom_hline(yintercept=-150*sf) + annotate("text", x=1, y=-200*sf, label="Jun 1") + annotate("text", x=15, y=-200*sf, label="Jun 15") + annotate("text", x=30+1, y=-200*sf, label="Jul 1") + annotate("text", x=30+15, y=-200*sf, label="Jul 15") + annotate("text", x=30+31+1, y=-200*sf, label="Aug 1") + annotate("text", x=30+31+15, y=-200*sf, label="Aug 15") + annotate("text", x=30+31+31+1, y=-200*sf, label="Sep 1") + annotate("text", x=30+31+31+15, y=-200*sf, label="Sep 15") + annotate("text", x=30+31+31+30+1, y=-200*sf, label="Oct 1") + annotate("label", x=5, y=1800*sf, label="Exponential moving average (7 days)", size=5.5, hjust=0) + # annotate("text", x=5, y=1700*sf, label= paste(au_covid$date[today], "@", time, "GMT+10"), hjust=0) + geom_point(colour="white", size = 3.2) + geom_point(colour="grey20", size = 2.8) + geom_ma(n=7, ma_fun=EMA, colour="dark green", linetype=1, size = 1) + # geom_ma(n=7, colour="orange", linetype=1, size = 1) + # geom_smooth(colour="red3", fill="NA", method="gam") + # geom_line(aes(y=model.au.fit.deriv), colour="blue", size = 1, linetype=2) + annotate("label", x=(today), y=-85*sf, label=au_covid$date[today], size=3) + coord_cartesian(ylim = c(-250*sf, 1800*sf), xlim = c(1,today+2)) p3 <- ggplot(data=au_covid, aes(x=day, y=new)) + xlab("Days from Jun 1") + ylab("Confirmed COVID-19 cases (Australia)") + geom_vline(xintercept=today, color = "grey") + geom_hline(yintercept=-150*sf) + annotate("text", x=1, y=-200*sf, label="Jun 1") + annotate("text", x=15, y=-200*sf, label="Jun 15") + annotate("text", x=30+1, y=-200*sf, label="Jul 1") + annotate("text", x=30+15, y=-200*sf, label="Jul 15") + annotate("text", x=30+31+1, y=-200*sf, label="Aug 1") + annotate("text", x=30+31+15, y=-200*sf, label="Aug 15") + annotate("text", x=30+31+31+1, y=-200*sf, label="Sep 1") + annotate("text", x=30+31+31+15, y=-200*sf, label="Sep 15") + annotate("text", x=30+31+31+30+1, y=-200*sf, label="Oct 1") + annotate("label", x=5, y=1800*sf, label="Generalised additive model", size=5.5, hjust=0) + # annotate("text", x=5, y=1700*sf, label= paste(au_covid$date[today], "@", time, "GMT+10"), hjust=0) + geom_point(colour="white", size = 3.2) + geom_point(colour="grey20", size = 2.8) + # geom_ma(n=7, ma_fun=EMA, colour="dark green", linetype=1, size = 1) + # geom_ma(n=7, colour="orange", linetype=1, size = 1) + geom_smooth(colour="red3", fill="NA", method="gam") + # geom_line(aes(y=model.au.fit.deriv), colour="blue", size = 1, linetype=2) + annotate("label", x=(today), y=-85*sf, label=au_covid$date[today], size=3) + coord_cartesian(ylim = c(-250*sf, 1800*sf), xlim = c(1,today+2)) p4 <- ggplot(data=au_covid, aes(x=day, y=new)) + xlab("Days from Jun 1") + ylab("") + geom_vline(xintercept=today, color = "grey") + geom_hline(yintercept=-150*sf) + annotate("text", x=1, y=-200*sf, label="Jun 1") + annotate("text", x=15, y=-200*sf, label="Jun 15") + annotate("text", x=30+1, y=-200*sf, label="Jul 1") + annotate("text", x=30+15, y=-200*sf, label="Jul 15") + annotate("text", x=30+31+1, y=-200*sf, label="Aug 1") + annotate("text", x=30+31+15, y=-200*sf, label="Aug 15") + annotate("text", x=30+31+31+1, y=-200*sf, label="Sep 1") + annotate("text", x=30+31+31+15, y=-200*sf, label="Sep 15") + annotate("text", x=30+31+31+30+1, y=-200*sf, label="Oct 1") + annotate("label", x=5, y=1800*sf, label="Gompertz model projections", size=5.5, hjust=0) + # annotate("text", x=5, y=1700*sf, label= paste(au_covid$date[today], "@", time, "GMT+10"), hjust=0) + geom_point(colour="white", size = 3.2) + geom_point(colour="grey20", size = 2.8) + # geom_ma(n=7, ma_fun=EMA, colour="dark green", linetype=1, size = 1) + # geom_ma(n=7, colour="orange", linetype=1, size = 1) + # geom_smooth(colour="red3", fill="NA", method="gam") + geom_line(aes(y=model.au.fit.deriv), colour="blue", size = 1, linetype=1) + annotate("label", x=(today), y=-85*sf, label=au_covid$date[today], size=3) + coord_cartesian(ylim = c(-250*sf, 1800*sf), xlim = c(1,today+2)) grid.arrange(p1, p2, p3, p4, nrow = 2)