Impact of Sample Size on Precision

Prelims

## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.4-0
size1 <- 5
size2 <- 20

#sample(1:50, size = size1,replace = F)
i1 <- c( 1,27,31,35,46) 

#sample(1:50, size = size2,replace = F)

i2 <- c(46,11,43,48,7,
        18,19,38,23,16,2,
        15,34,32,8,3,5,29,
        44,6)  

#Species of interest
i.TEJO <- which(BCI[,"Tetrathylacium.johansenii"] > 0)



#Set up data
dat <- c(apply(BCI[i1,],1,sum),
         apply(BCI[i2,],1,sum),
         apply(BCI[i.TEJO,],1, sum),
         sum(apply(BCI[,],1,sum))/50)

reps <- c(rep(paste("Rand",size1,sep="-"), size1),
          rep(paste("Rand",size2,sep="-"), size2),
          rep(paste("Bias",length(i.TEJO),sep = "-"),
              length(i.TEJO)), "Real")

#function to plot confidence itnerval
ci <- function(x) c(mean(x, na.rm = T)-2*se(x), mean(x, na.rm = T)+2*se(x))

#Make plot
lineplot.CI(x.factor = reps, 
            response = dat,
            lty = 0,
            lwd = 3,
            xlab = "",
            ylab = "",
            fun = function(x) mean(x, na.rm=TRUE),
            ci.fun= ci,
            col = 1:4,
            cex = 3,
            ylim = c(350,550))


legend("topleft", legend = c("Biased, n = 5",
                             "Random, n  = 20",
                             "Random, n = 5",
                             "Real value"),
       col = 1:4,ncol = 2, fill = 1:4)
mtext(text = "Sample Size", side = 1,line = 2.25,cex = 2)
mtext(text = "Trees per ha", side = 2,line = 2.2,cex = 2)
mtext(text = "Tree denisty on Barro Colorado Island, Panama", side = 3,line = 1.2)