I study insects and I'm collecting insects in 15 areas. There are 2 species that are very hard to identify. I've finished data collection, now I have to identify every individual.
Sample data for August 2014 (each line represents an area):
df <- read.table(text = "
speciesA speciesB
100 25
132 36
66 45
320 95
186 95
120 82
234 111
178 123
277 210
154 103
158 63
53 13
76 39
46 9
100 77
", h = T)
Imagine that this year I have collected in all areas but, this year, I didn't identify any individual from neither species. So, I have the following example data for August 2015:
df2 <- read.table(text = "
speciesAandB
100
150
90
400
255
200
300
350
500
250
180
70
100
50
200
", h = T)
I want to find the minimum number of individuals that should be identified in each sample/area in August 2015.
I don't want to identify all of them, since this means a lot of work. The goal is to minimize the identification work.
So I want to identify only some individuals from August 2015 and assume that the proportion keeps the same in the whole sample. For example, in the first area, I have 100 individuals in August 2015. Suppose I identify 40, 30 are from species A and 10 from species B. The proportion for species A is 75% and for species B is 25%. I would like to assume that the rest of the sample keeps the proportion. Therefore I would say that the 75 individuals from this sample are from this sample are from species A and 25 individuals from species B.
This would be done based on the species proportions from last year samples, that were totally identified. The question is: what is the minimum number of individuals for each sample that should be identified so that I can assume this?
I am trying 2 approaches:
Approach 1 - Simulation
I am randomly sampling (with replacement) from 2 to 100 individuals from each area. Each of these samplings is done 1000 times. Then I compare the random to the original samples and use a t test to check if there is a significant difference. The results are in the next figure (each line represents an area):
simular <- function(speciesA, speciesB, prob, n){
contador <- rep(0, n-1)
for (x in 2:n)
for (i in 1:1000){
propOriginal <- c(rep(1, speciesA), rep(0, speciesB))
propAmostra <- sample(c(0,1), x, replace = T, prob = prob)
teste <- t.test(propOriginal, propAmostra)
if (teste$p.value < 0.05)
contador[x-1] <- contador[x-1] + 1
}
return(contador)
}
propDf <- df$speciesB/(df$speciesA+df$speciesB)
x <-matrix(nrow = 99, ncol = 15)
for (a in 1:15){
x[,a] <- simular(df$speciesA[a], df$speciesB[a], c(propDf[a], 1-propDf[a]), 100)
}
x <- data.frame(x)
plot(2:100, x[, 1], type = 'n', xlab = 'Number of individuals identified per sample', ylab = 'Number of significant t tests')
for (i in 1:15){
lines(2:100, x[, i],type = 'l')
}
I would conclude from this figure that about 40 individuals per sample is enough to get a reasonable certainty that the proportion of individuals will remain the same if I keep identifying. My question: is this approach valid?
Approach 2 - Power analysis
I don't see here a classical power analysis problem. How I would run a power analysis with this kind of problem?