Skip to content

Instantly share code, notes, and snippets.

@SwampThingPaul
Last active March 27, 2020 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SwampThingPaul/60718d3daa2ddc23e632c1c4c00509cd to your computer and use it in GitHub Desktop.
Save SwampThingPaul/60718d3daa2ddc23e632c1c4c00509cd to your computer and use it in GitHub Desktop.
Strobl and Robillard (2008) samples per year
# From
## Strobl, R.O., Robillard, P.D., 2008. Network design for water
## quality monitoring of surface freshwaters: A review. Journal
## of Environmental Management, Microbial and Nutrient Contaminants
## of Fresh and Coastal Waters 87, 639–648.
## https://doi.org/10.1016/j.jenvman.2007.03.001
#devtools::install_github("SwampThingPaul/AnalystHelper")
library(AnalystHelper)
alpha=0.1/2
sd.val=seq(2,0.125,length.out=100)
ci.val= seq(0.5,0.90,0.05)
col.rmp=colorRampPalette(c("indianred1","dodgerblue1"))(length(ci.val))
par(family="serif",mar=c(0.75,2.75,0.25,0.1),oma=c(3,2,0.5,3.75));
layout(matrix(1:2,1,2,byrow=F),widths=c(1,0.25))
ylim.val=c(0.1,2);ymaj=log.scale.fun(ylim.val,"major");ymin=log.scale.fun(ylim.val,"minor")
xlim.val=c(1,65);xmaj=log.scale.fun(xlim.val,"major");xmin=log.scale.fun(xlim.val,"minor")
plot(ylim.val~xlim.val,axes=F,type="n",las=1,ylab=NA,xlab=NA,log="xy",xlim=xlim.val,ylim=ylim.val)
for(i in 1:length(ci.val)){
N.samplei=round(((t.val/sd.val)/((1-ci.val[i])/2))^2,0)
lines(N.samplei[N.samplei>=1],sd.val[N.samplei>=1],col=col.rmp[i],lwd=4)
}
axis_fun(1,xmaj,xmin,xmaj)
axis_fun(2,ymaj,ymin,format(ymaj));box(lwd=1)
mtext(side=2,line=2,"Parameter Standard Deviation")
mtext(side=1,line=2,"Sample Size per year")
plot(0:1,0:1,axes=F,ylab=NA,xlab=NA,type="n")
legend(0.5,0.75,legend=format(ci.val,digits=2),col=col.rmp,
lty=1,lwd=2,pt.cex=1.5,ncol=1,cex=0.8,bty="n",y.intersp=1,x.intersp=0.75,xpd=NA,xjust=0.5,title.adj=0,title="\u03B1-value = 0.10\nConfidence Interval")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment