get_CI: Compute confidence interval

Description Usage Arguments Value Examples

View source: R/misc.R

Description

Computes the confidence interval based on Student's t-distribution or the standard normal distribution. Also reports descriptive statistics (such as the mean). Missings are ignored.

Usage

1
2
3
get_CI(x, conf.level = 0.95, dist = "t", incl_n = TRUE,
  incl_mean = TRUE, incl_SD = TRUE, incl_SE = TRUE,
  incl_error = TRUE)

Arguments

x

A numeric (or logical) vector (such as a variable)

conf.level

Confidence level of the interval. Defaults to 0.95.

dist

Distribution the confidence interval should be based on. "t" or "student" (default) for Student's t-distribution, "z" or "normal" for standard normal distribution.

incl_n

A locigal indicating whether the number of observations should be included in the returned results. Defaults to TRUE.

incl_mean

A locigal indicating whether the mean should be included in the returned results. Defaults to TRUE.

incl_SD

A locigal indicating whether the standard deviation should be included in the returned results. Defaults to TRUE.

incl_SE

A locigal indicating whether the standard error should be included in the returned results. Defaults to TRUE.

incl_error

A locigal indicating whether the error based on the confidence level (i.e., the number that is substracted or added to the mean lower and upper bounds of the confidence interval) should be included in the returned results. Defaults to TRUE.

Value

A numeric vector with at least the lower and upper bounds of the confidence interval.

Examples

1
2
3
4
5
6
7
## The height of ten people in cm
heights <- c(160, 163, 168, 169, 174, 176, 177, 178, 182, 190)

get_CI(heights) # Defaults
get_CI(heights, dist = "normal") # Using standard normal distribution
get_CI(heights, conf.level = 0.9) # 90%-CI
get_CI(heights, incl_SD = FALSE) # Do not include standard deviation

jogrue/jogRu documentation built on Sept. 26, 2018, 6:58 a.m.