Learn R Programming

statBasics (version 0.2.3)

ci_1pop_norm: Confidence interval for the normal distribution parameters

Description

Confidence interval for the normal distribution parameters

Usage

ci_1pop_norm(
  x,
  sd_pop = NULL,
  parameter = "mean",
  conf_level = 0.95,
  type = "two.sided",
  na.rm = F
)

Value

A 1 x 3 tibble with 'lower_ci', 'upper_ci', and 'conf_level' columns. Values correspond to the lower and upper bounds of the confidence interval, and the confidence level, respectivel.

Arguments

x

a (non-empty) numeric vector.

sd_pop

a number specifying the known standard deviation of the population.

parameter

a character string specifying the parameter in the normal distribution. Must be one of "mean" or "variance".

conf_level

confidence level of the returned confidence interval. Must be a single number between 0 and 1.

type

a character string specifying the type of confidence interval. Must be one of "two.sided" (default), "right" or "left".

na.rm

a logical value indicating whether NA values should be removed before the computation proceeds.

Details

type specifies the type of confidence interval. If type is "two.sided", the returned confidence interval is (lower_ci, upper_ci) when parameter is "mean" or "variance". If type is "left", the returned confidence interval is (lower_ci, Inf) when parameter is "mean" or "variance". And, finally, is type is "right", the returned confidence interval is (-Inf, upper_ci)) when parameter is "mean", and the returned confidence interval is (0, upper_ci) when parameter is "variance".

Examples

Run this code
x <- rnorm(1000)
ci_1pop_norm(x) # confidence interval for the mean, unknown variance

x <- rnorm(1000, sd = 2)
ci_1pop_norm(x, sd_pop = 2) # confidence interval for mean, known variance

x <- rnorm(1000, sd = 5)
ci_1pop_norm(x, parameter = "variance") # confidence interval for the variance

Run the code above in your browser using DataLab