ConfIntVariance-package {ConfIntVariance}R Documentation

Confidence Interval for the Univariate Population Variance without Normality Assumption

Description

Surrounds the usual sample variance of a univariate numeric sample with a confidence interval for the population variance. This has been done so far only under the assumption that the underlying distribution is normal. Under the hood, this package implements the unique least-variance unbiased estimator of the variance of the sample variance, in a formula that is equivalent to estimating kurtosis and square of the population variance in an unbiased way and combining them according to the classical formula into an estimator of the variance of the sample variance. Both the sample variance and the estimator of its variance are U-statistics. By the theory of U-statistic, the resulting estimator is unique. See Fuchs, Krautenbacher (2016) <doi:10.1080/15598608.2016.1158675> and the references therein for an overview of unbiased estimation of variances of U-statistics.

Details

The DESCRIPTION file:

Package: ConfIntVariance
Type: Package
Title: Confidence Interval for the Univariate Population Variance without Normality Assumption
Version: 1.0.2
Date: 2019-03-06
Author: Mathias Fuchs
Maintainer: Mathias Fuchs<mathias@mathiasfuchs.de>
Description: Surrounds the usual sample variance of a univariate numeric sample with a confidence interval for the population variance. This has been done so far only under the assumption that the underlying distribution is normal. Under the hood, this package implements the unique least-variance unbiased estimator of the variance of the sample variance, in a formula that is equivalent to estimating kurtosis and square of the population variance in an unbiased way and combining them according to the classical formula into an estimator of the variance of the sample variance. Both the sample variance and the estimator of its variance are U-statistics. By the theory of U-statistic, the resulting estimator is unique. See Fuchs, Krautenbacher (2016) <doi:10.1080/15598608.2016.1158675> and the references therein for an overview of unbiased estimation of variances of U-statistics.
License: GPL-3

Index of help topics:

ConfIntVariance-package
                        Confidence Interval for the Univariate
                        Population Variance without Normality
                        Assumption
varwci                  varwci

A package providing one function varwci which is short for "variance with confidence interval."

Author(s)

Mathias Fuchs Maintainer: Mathias Fuchs<mathias@mathiasfuchs.de>

References

www.mathiasfuchs.de/b3.html

Examples


##
## Example: throwing a dice
## 

                                        # True quantities that do not depend on n
trueMeanOfDice <- mean(1:6)


                                        # The true variance of the dice
                                        # This is the quantity that we
                                        # want to estimate by embracing
                                        # with a confidence interval
                                        # instead of just estimating
                                        # with a point estimator as is
                                        # done in the function var
trueVarianceOfDice <- mean((1:6)^2) - trueMeanOfDice^2
trueFourthCentralMomentOfDice <- mean(((1:6)-trueMeanOfDice)^4)

                                        # this requires some scribbling with paper and pencil
                                        # (or a study of Hoeffding 1948)
trueVarianceOfSampleVarianceOfDice <- function(n) 
(trueFourthCentralMomentOfDice - trueVarianceOfDice^2 * (n-3)/(n-1))/n

##
## Simulation study: compute the coverage probability of
## the confidence interval by computing the probability
## that it contains the true value.
## We want that probability to be equal to the confidence level 0.95,
## not more and not less. (If it was higher, the test would be too conservative).
##

                                        # number of times we draw a
                                        # sample and compute a confidence interval
N <- 1e4
trueValueCovered <- sapply(
    1:N,
    function(i) {
                                        # throw a dice 100 times
        x <- sample(6, 100, replace=TRUE)
                                        # compute our confidence interval
        ci <- varwci(x)
                                        # We know that the true variance
                                        # of the dice is
                                        # 35/12 = 2.916666...
                                        # Record the boolean whether the
                                        # confidence interval contains
                                        # the true value.
        (35/12 > ci[1] && 35/12 < ci[2])
    }
)

                                        # Result of simulation study:
                                        # Will be close to 0.95.
print(mean(trueValueCovered))


[Package ConfIntVariance version 1.0.2 Index]