Learn R Programming

exams.forge (version 1.0.10)

CImu_data: Confidence Intervals

Description

The CImu_data function is designed for the generation of confidence intervals pertaining to a population mean mu. The function accommodates scenarios in which a dataset x is either provided or generated through a random sampling process from a normal distribution, with user-specified parameters such as a mean mu and a standard deviation sigma. Subsequently, the function computes essential statistical measures, including the sample mean xbar and the standard deviation sd. Confidence intervals for the population mean are then calculated at user-defined confidence levels (conf.level). The output is a structured list containing pertinent statistics, encompassing the mean, sample standard deviation, confidence intervals, and other relevant details.

Usage

CImu_data(
  x = NULL,
  n = length(x),
  xbar = NULL,
  sd = NULL,
  conf.level = c(0.9, 0.95, 0.99),
  mu = NULL,
  sigma = NULL
)

dcimu( x = NULL, n = length(x), xbar = NULL, sd = NULL, conf.level = c(0.9, 0.95, 0.99), mu = NULL, sigma = NULL )

Value

a list with

  • a with 1-(1-conf.level)/2

  • n number observations if given

  • xbar mean of observations if not given

  • mu theoretical mean if given

  • sd standard deviation of observations

  • sigma theoretical standard deviation if given

  • df degrees of freedom if a t distribution is used

  • q if sigma=NULL

  • ss either sd or sigma

  • e margin of error (half of the length of the confidence interval(s))

  • l length of the confidence interval(s)

  • v endpoints of the confidence interval(s)

Arguments

x

numeric: vector of data values

n

numeric: length of the vector x (if n<1 then n=5 is used)

xbar

numeric: sample mean

sd

numeric: sample standard deviation

conf.level

numeric: vector of confidence levels of the interval (default: c(0.9, 0.95, 0.99))

mu

numeric: true value of the mean

sigma

numeric: vector of possible variance

Examples

Run this code
# with data
x <- rnorm(100)
CImu_data(x, conf.level=0.95)
# simulate data internally
CImu_data(n=100, conf.level=0.95, mu=0, sigma=1)

Run the code above in your browser using DataLab