Learn R Programming

stat.extend (version 0.1.1)

CONF.mean: Optimal Confidence Intervals for finite populations

Description

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

Usage

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 = 3, 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)

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 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).

Examples

Run this code
# NOT RUN {
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);
# }

Run the code above in your browser using DataLab