2
$\begingroup$

I have what I feel is a relatively simple question, but it seems to have no easily-accessible answer. I'm trying to find how to calculate the 95% confidence interval for data that is continuous, but constrained between 0 and 1. Full disclosure - my data are proportions and many of the values are 0s or 1s. This means I can't simply use quantiles, because the 2.5% quantile is always 0 and the 97.5% quantile is always 1.

I realize many functions in R calculate 95% CIs for proportions, but these functions all seem to rely on data relating to the number of successes. My data do not include "successes".

In my study, I compared the relative abundance of one species to another species in a given plot of land. I did this at multiple locations. So each row of my data frame (shown below) corresponds to a location at which I did this assessment. Column 1 is the proportion of species 1, and column 2 is the proportion of species 2 - these values sum to 1 for each row.

  prop.species.1        prop.species.2
1      1.0000000        0.0000000
2      1.0000000        0.0000000
3      1.0000000        0.0000000
4      0.0000000        1.0000000
5      0.6363636        0.3636364
6      1.0000000        0.0000000
7      1.0000000        0.0000000
8      1.0000000        0.0000000
9      0.5555556        0.4444444
10     1.0000000        0.0000000
..           ...              ...   

The data frame is 1000 rows long. Does anyone know how I can calculate the 95% CIs for each column?

$\endgroup$
3
  • $\begingroup$ I'm voting to close. This is a statistics question and isn't specific to programming. $\endgroup$
    – Dason
    Commented Nov 23, 2015 at 22:07
  • $\begingroup$ Do you know the actual counts at each location? Or is only the proportion available? $\endgroup$
    – AlaskaRon
    Commented Nov 23, 2015 at 23:20
  • $\begingroup$ You are trying to calculate the confidence interval of what statistic? The mean? $\endgroup$ Commented Nov 24, 2017 at 21:05

2 Answers 2

1
$\begingroup$

Determining confidence intervals by the bootstrap methods percentile and bca will respect the hard endpoints in the data.

Based on your sample data, calculating the mean proportion for each species is probably not very meaningful, since the data are very skewed. The following code in R calculates the confidence interval for the median of each of the two species using the percentile method.

It’s not clear to me that summarizing the data in this way makes a lot of sense, but it depends on your purposes. If some species were 100% of observation in one location, and 0% in another two locations, is it helpful to take the median or the mean of these? Would it be better to count up all the observations in all locations and divide by the grand total?

Data = read.table(header=TRUE, text =
"Obs   prop.species.1    prop.species.2
1      1.0000000        0.0000000
2      1.0000000        0.0000000
3      1.0000000        0.0000000
4      0.0000000        1.0000000
5      0.6363636        0.3636364
6      1.0000000        0.0000000
7      1.0000000        0.0000000
8      1.0000000        0.0000000
9      0.5555556        0.4444444
10     1.0000000        0.0000000
")

hist(Data$prop.species.1)
hist(Data$prop.species.2)

summary(Data$prop.species.1)
summary(Data$prop.species.2)

library(boot)

Mboot1 = boot(Data$prop.species.1,
             function(x,i) median(x[i]),
             R=10000)

Mboot2 = boot(Data$prop.species.2,
             function(x,i) median(x[i]),
             R=10000)             

boot.ci(Mboot1,
        conf = 0.95,
        type = c("perc"))

   ### median = 1

   ### Intervals : 
   ### Level     Percentile     
   ### 95%   ( 0.6364,  1.0000 ) 



boot.ci(Mboot2,
        conf = 0.95,
        type = c("perc")) 

   ### median = 0

   ### Intervals : 
   ### Level     Percentile     
   ### 95%   ( 0.0000,  0.3636 )
$\endgroup$
0
$\begingroup$

I don't think you can calculate a confidence interval using the data shown in your data frame, however you probably can calculate a CI using data not shown.

IF I understand you correctly, each row in your data frame corresponds to a single site where you took several measurements. Presumably you had to look at a number of subjects to calculate a proportion of one species over the other.

If my assumption is correct, you can calculate the confidence interval, but you will need the record of how many measurements you took at each site (N), and how many were species A vs. species B. Using these data points you can calculate the CI.

Have a look at this tutorial on the problem, it goes through the problem step by step, with accompanying R commands:

http://www.r-tutor.com/elementary-statistics/interval-estimation/interval-estimate-population-proportion

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.