Skip to content

Commit 576566e

Browse files
Update README.md
1 parent bfb9e41 commit 576566e

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,36 @@ An R package providing one function varwci ("variance with confidence interval")
33

44
The validity of the confidence interval is confirmed by a coverage probability simulation study given in the examples in the documentation.
55

6+
# How does it work?
7+
It works by implementing an unbiased estimator of the variance of the sample variance, and then setting up the standard studentized confidence interval using the square of that unbiased estimator. So far, the strategy is the same as the one used to obtain the confidence interval for the mean, as it is implemented in the t.test function in R, for instance.
8+
9+
There exists a closed form for the variance of this estimator but it involves the square of the underlying distribution's variance.
10+
The difficulty is to estimate that square.
11+
12+
# Reference
13+
The underlying U-statistics variance estimator is a special case of the one underlying this publication [http://dx.doi.org/10.1080/15598608.2016.1158675](http://dx.doi.org/10.1080/15598608.2016.1158675), freely available [https://epub.ub.uni-muenchen.de/27656/7/TR.pdf](here).
14+
15+
# Validation
16+
One can easily verify the validity of the confidence interval by choosing a population aka distribution (for instance, a dice) computing the true variance either theoretically or by taking the sample variance of a very large sample (with n a few hundred millions), drawing many samples (all of the same size or not), and checking that the confidence interval covers the true value in about 95% of all cases. For instance, in the dice example, the true variance is 35 / 12 = 2.91666, and the following code confirms the validity:
17+
18+
```R
19+
N <- 1e4
20+
trueValueCovered <- rep(NA, N)
21+
for (i in 1:N) {
22+
if (i \%\% 1e3 == 0) print(i)
23+
# throw a dice 100 times
24+
x <- sample(6, 100, replace=TRUE)
25+
# compute our confidence interval
26+
ci <- varwci(x)
27+
# We know that the true variance of the dice is 35/12 = 2.916666...
28+
# Record the boolean whether the confidence interval contains the correct value
29+
trueValueCovered[i] <- (trueVarianceOfDice > ci[1] && trueVarianceOfDice < ci[2])
30+
}
31+
32+
# Result of simulation study: should be close to 0.95
33+
print(mean(trueValueCovered))
34+
```
35+
636
# Installation
737
Download the relase file ConfIntVariance_1.0.tar.gz from
838

0 commit comments

Comments
 (0)