# CONF: Optimal Confidence Intervals for finite populations In stat.extend: Highest Density Regions and Other Functions of Distributions

## Description

These functions compute an optimised confidence interval for statistics based on a sample. The user may enter either a data vector x or the sample size n and the sample statistic. By default the confidence interval is computed for an infinite population. However, the user may enter a population size N and may use the logical value unsampled to specify when the confidence interval is for the variance only of the unsampled part of the population. This test accounts for the kurtosis, and so the user must either specify the data vector or specify an assumed kurtosis kurt; if no kurtosis value is specified then the test uses the sample kurtosis from the data.

## Usage

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 CONF.mean( alpha, x = NULL, sample.mean = mean(x), sample.variance = var(x), n = length(x), N = Inf, kurt = 3, unsampled = FALSE, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 ) CONF.var( alpha, x = NULL, sample.variance = var(x), n = length(x), N = Inf, kurt = NULL, unsampled = FALSE, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 ) CONF.prop( alpha, x = NULL, sample.prop = mean(x), n = length(x), N = Inf, unsampled = FALSE )

## Arguments

 alpha alpha Numeric (probability) The significance level determining the confidence level for the interval (the confidence level is 1-alpha). x Numeric (vector) The vector of sample data. In the CONF.prop function this must be binary data. Ignored if a sample statistic is provided. sample.mean Numeric (any) The sample mean of the data. sample.variance Numeric (non-neg) The sample variance of the data. n Integer (positive) The sample size N Integer (positive) The population size (must be at least as large as the sample size) kurt Numeric (positive) The assumed kurtosis of the underlying distribution (must be at least one) unsampled Logical (positive) Indicator of whether the user wants a confidence interval for the relevant parameter only for the unsampled part of the population (as opposed to the whole population) gradtol Parameter for the nlm optimisation - a positive scalar giving the tolerance at which the scaled gradient is considered close enough to zero to terminate the algorithm (see [nlm doccumentation](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nlm.html)). steptol Parameter for the nlm optimisation - a positive scalar providing the minimum allowable relative step length (see [nlm doccumentation](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nlm.html)). iterlim Parameter for the nlm optimisation - a positive integer specifying the maximum number of iterations to be performed before the program is terminated (see [nlm doccumentation](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nlm.html)). sample.prop Numeric (probability) The sample proportion of the data (only for binary data)

## Details

The mean interval is built on a symmetric pivotal quantity so it is symmetric around the sample mean.

The variance interval is built on a non-symmetric pivotal quantity, so it is optimised by taking the shortest possible confidence interval with the specified confidence level (see e.g., Tate and Klett 1959).

The proportion interval uses the Wilson score interval (see e.g., Agresti and Coull 1998).

## Value

an object of class 'ci' providing the confidence interval and related information.

## Examples

 1 2 3 4 5 6 7 8 9 DATA <- c(17.772, 16.359, 15.734, 15.698, 16.042, 15.527, 16.533, 15.385, 15.368, 18.603, 15.036, 13.873, 14.329, 15.837, 14.189, 15.398, 16.266, 12.970, 15.219, 16.444, 11.049, 14.262); KURT <- 4.37559247659433 # moments::kurtosis(DATA); CONF.mean(alpha = 0.1, x = DATA, N = 3200, kurt = KURT); CONF.var(alpha = 0.1, x = DATA, N = 3200, kurt = KURT); CONF.prop(alpha = 0.1, x = DATA > 15, N = 3200);

stat.extend documentation built on Nov. 23, 2021, 5:06 p.m.