Skip to content

Instantly share code, notes, and snippets.

@adamkucharski
Created November 28, 2023 11:01
Show Gist options
  • Save adamkucharski/ab36e8af075de8e61e2c8be542148d58 to your computer and use it in GitHub Desktop.
Save adamkucharski/ab36e8af075de8e61e2c8be542148d58 to your computer and use it in GitHub Desktop.
Basic final size plot
# Calculate final size using {finalsize}
library(finalsize)
xx <- seq(1,4,0.1) # range of R0 values
finalsize_calc <- sapply(xx,function(x){finalsize::final_size(r0=x,matrix(1),1,matrix(1),matrix(1))$p_infected}) # simple final size model
# Plot results
par(mfrow=c(1,1),mar=c(4,4,1,1),las=0)
plot(xx,finalsize_calc, ylim=c(0,1),lwd=2, col="dark blue",type="l", main="", yaxs="i",xaxs="i", yaxt="n",xlab=expression(R[0]), ylab="Percentage infected",bty="l")
axis(2, at=seq(0,1,0.1),labels = paste0(seq(0,100,10),"%"),col = "black")
dev.copy(png,"sus_1.png",units="cm",width=12,height=10,res=200)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment