This function calculates CIs for the population variance.

ci_var(
  x,
  probs = c(0.025, 0.975),
  type = c("chi-squared", "bootstrap"),
  boot_type = c("bca", "perc", "stud", "norm", "basic"),
  R = 9999L,
  seed = NULL,
  ...
)

Arguments

x

A numeric vector.

probs

Lower and upper probabilities, by default c(0.025, 0.975).

type

Type of CI. One of "chi-squared" (default) or "bootstrap".

boot_type

Type of bootstrap CI. Only used for type = "bootstrap".

R

The number of bootstrap resamples. Only used for type = "bootstrap".

seed

An integer random seed. Only used for type = "bootstrap".

...

Further arguments passed to boot::boot().

Value

An object of class "cint", see ci_mean() for details.

Details

By default, classic CIs are calculated based on the chi-squared distribution, assuming normal distribution (see Smithson). Bootstrap CIs are also available (default: "bca"). We recommend them for the non-normal case.

The stud (bootstrap t) bootstrap uses the standard error of the sample variance given in Wilks.

References

  1. Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.

  2. S.S. Wilks (1962), Mathematical Statistics, Wiley & Sons.

See also

Examples

x <- 1:100
ci_var(x)
#> 
#> 	Two-sided 95% chi-squared confidence interval for the population
#> 	variance
#> 
#> Sample estimate: 841.6667 
#> Confidence interval:
#>      2.5%     97.5% 
#>  648.8375 1135.8202 
#> 
ci_var(x, type = "bootstrap", R = 999)  # Use larger R
#> 
#> 	Two-sided 95% bootstrap confidence interval for the population variance
#> 	based on 999 bootstrap replications and the bca method
#> 
#> Sample estimate: 841.6667 
#> Confidence interval:
#>      2.5%     97.5% 
#>  710.4344 1018.2535 
#>