library("roxygen2")
library("devtools")
# I will start by creating some functions for different types of confidence intervals
#' A two-sided confidence interval with a known variance
#'
#' @param mu (what we believe to be) the true population mean
#' @param xbar the sample mean of the data
#' @param confidenceLevel the significance level for the CI, i.e., 1 - alpha
#' @param variance the *known* variance of the data
#' @param n the number of data entries
#' @return returns a test statistic, a p-value, and a confidence interval consisting of lower and upper bounds
z_ci_sigma <- function(mu, xbar, confidenceLevel, variance, n) {
testStatistic <- (xbar - mu) / sqrt(variance / n)
pValue <- 2 * pnorm(- abs(testStatistic) )
lowerBound <- xbar + qnorm( (1 - confidenceLevel) / 2) * sqrt(variance / n)
upperBound <- xbar - qnorm( (1 - confidenceLevel) / 2) * sqrt(variance / n)
cbind(testStatistic, pValue, lowerBound, upperBound)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.