1
$\begingroup$

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')
}

enter image description here

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?

$\endgroup$
6
  • $\begingroup$ No matter how I try to interpret it, I cannot make sense of "I want to find the minimum number of individuals that should be identified in each sample so that I can conclude that the proportion of individuals of each species remains the same for the rest of the sample." Would it be possible to phrase this in a different way? $\endgroup$
    – whuber
    Sep 8 '15 at 21:43
  • $\begingroup$ @whuber Tried to rephrase it. Hope it is clearer. Thanks $\endgroup$ Sep 8 '15 at 21:51
  • $\begingroup$ Thank you for trying, but I'm still totally lost. I don't understand the distinction between being "identified" and being counted in the table, which explicitly identifies two species. I don't understand what the "rest of the sample is." I'm pretty sure you can't guarantee anything will "remain the same" if it is based somehow on the sample. Do you think you could explain more fully what it is you are doing and what you hope the data will look like? $\endgroup$
    – whuber
    Sep 8 '15 at 22:14
  • $\begingroup$ @whuber I improved the question and asked someone that doesn't know the problem to read. I hope it is better now. Please take a look, your help is very important, even though I already have a nice answer. $\endgroup$ Sep 9 '15 at 12:44
  • $\begingroup$ Now I understand! Thank you for your efforts in clarifying the question. $\endgroup$
    – whuber
    Sep 9 '15 at 13:00
1
$\begingroup$

The statistical tests for proportion comparisons and the corresponding power calculations exist in order to spot statistically significant differences and not to ensure that a proportion is close enough to a given proportion. They might have the same philosophy and maybe sound similar, but they're not. This is because the philosophy behind the experiment/test (you design) is that you want to reject the null hypothesis because you know how confident you are in doing that.

The way I see you can adapt your case to that concept is the following:

For a given month you know from last year the true proportion of species B (I'll focus on species B as you deal with two species and the proportions sum to 1). Let's assume this is given by the table you provided. The first thing is to investigate the 95% CIs of the data to be able to see what kind of differences you can see as "similar":

 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)

# investigate CIs
prop.test(x=sum(df$speciesB), n=sum(df$speciesA)+sum(df$speciesB))

# 1-sample proportions test with continuity correction
# 
# data:  sum(df$speciesB) out of sum(df$speciesA) + sum(df$speciesB), null probability 0.5
# X-squared = 346.16, df = 1, p-value < 2.2e-16
# alternative hypothesis: true p is not equal to 0.5
# 95 percent confidence interval:
#   0.3225087 0.3549569
# sample estimates:
#   p 
# 0.3385448 

The above test compares with a 0.5 proportion by default, but you just care for the CIs, which are 32.3% and 35.5% and the mean which is 33.8%, let's say 34%. So, if your true proportion is 34% it is reasonable to try and investigate proportion smaller than 32.3% or higher than 35.5%, otherwise you'll need more observations than what you have here.

The next step is to start collecting new data to get an idea of your (baseline) proportion for species B. Let's assume you get 37 B and 63 A after 100 collections. You have:

# what you observe after 100 collections
prop.test(37,100,p=0.34)

# 1-sample proportions test with continuity correction
# 
# data:  37 out of 100, null probability 0.34
# X-squared = 0.27852, df = 1, p-value = 0.5977
# alternative hypothesis: true p is not equal to 0.34
# 95 percent confidence interval:
#   0.2772627 0.4728537
# sample estimates:
#   p 
# 0.37 

That 37% is not statistically different than 34% at the moment, but the CIs are very wide (reasonably). The question is "how many observation do I need in order to spot that my new proportion of B, if I keep collecting data, is statistically significantly different than the 34%?". You have to calculate that:

# how many observations do we need to spot that the sample proportion is different than the 34% of the population?
effect.size = ES.h(0.37, 0.34)

pwr.p.test(h = effect.size, 
           n = NULL, 
           sig.level = 0.05, 
           power = 0.80,
           alternative = "two.sided")

# proportion power calculation for binomial distribution (arcsine transformation) 
# 
# h = 0.06270728
# n = 1996.046
# sig.level = 0.05
# power = 0.8
# alternative = two.sided

You don't have evidence that after keep collecting data that initial 37% will remain above or below 34%, so you need a two-tailed test. It's up to you to decide about the a-level and the power. That says that you need 1997 observations in total. (You had 3326 in total for your last year's month).

Now, I'm not sure how you'll spread those 1997 observations into the 15 areas, but I think it should be proportionally to your last year's months dataset.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.