# Confusion about coronavirus testing and the role of testing capacity

2020 March 30

Here’s some code to simulate a process whereby we saturate testing capacity… First the graphs:

```
library(ggplot2)
t = seq(1,40)
realcases = 100*exp(t/4)
realincrement = diff(c(0,realcases))
testseekers = rnorm(NROW(realincrement),4,.25)*realincrement
maxtests = 20000
## now assume that you test *up to* 20k people. if more people are
## seeking tests, you test a random subset of the seekers
## getting a binomial count of positives for the given frequency
ntests = rep(0,NROW(t));
ntests[1] = 100;
confinc = rep(0,NROW(t));
confinc[1] = 100;
for(i in 2:(NROW(t)-1)){
if(testseekers[i] < maxtests){
confinc[i] = realincrement[i]
ntests[i] = testseekers[i]
}
else if(testseekers[i] > maxtests){
confinc[i] = min(realincrement[i],rbinom(1,maxtests,realincrement/testseekers))
ntests[i] = maxtests
}
}
cumconf = cumsum(confinc)
cumtests = cumsum(ntests)
ggplot(data.frame(t=t,conf=cumconf,nt=cumtests,real=realcases))+geom_line(aes(t,cumconf),color="blue") + geom_line(aes(t,nt),color="green")+ geom_line(aes(t,real),color="red") +coord_cartesian(xlim=c(0,35),ylim=c(0,400000));
ggplot(data.frame(t=t,conf=cumconf,nt=cumtests,real=realcases))+geom_line(aes(t,log(cumconf)),color="blue") + geom_line(aes(t,log(nt)),color="green")+ geom_line(aes(t,log(real)),color="red") +coord_cartesian(xlim=c(0,30),ylim=c(0,log(400000)));
```

No comments yet