This R script does some simple calculations to determine what specificity is required to a given positive predictive value for a screening test across a range of supplied prevalences and sensitivities.

Define range of prevalences desired

prevalence <- seq(0.005,0.050,by=0.005)

Define positive predictive values desired

ppv <- seq(0.5,0.95,by=0.05)

Define sensitivity

sensitivity <- seq(0.85,1.0,by=0.05)

Find numbers of ppv and prevalences

dat <- data.frame(prevalence=rep(prevalence,length(ppv)*length(sensitivity)),
                  ppv=rep(ppv,length(sensitivity),each=length(prevalence)),
                  sensitivity=rep(sensitivity,each=length(prevalence)*length(ppv)))

Calculate specificities requried

dat$specificity <- 1 - ((dat$prevalence*dat$sensitivity)*(1-dat$ppv))/(dat$ppv*(1-dat$prevalence))

Make plot

ggplot(dat, aes(x=prevalence,y=specificity,colour=factor(ppv))) +
  geom_line() +
  scale_colour_discrete("Positive\nPredictive\nValue") +
  scale_x_continuous("Prevalence") +
  scale_y_continuous("Specificity") +
  facet_wrap(vars(sensitivity),ncol=2) +
  theme_bw() +
  theme(legend.position="bottom")