Generation

generate functionFri, 24 Feb 2023

Create a 95% confidence interval for the mean number of hours spent sleeping per day. Interpret the interval in the context of the problem.

# Make a function for confidence interval ci95 <- function(x) { xbar <- mean(x) s <- sd(x) n <- length(x) se <- s/sqrt(n) a <- 0.95 l <- xbar - qt(a,df=n-1)*se u <- xbar + qt(a,df=n-1)*se c(lower=l, upper=u) } # sleep data sleep <- c(6.1,6.2,6.7,6.2,6.0,6.1,6.1,6.2,6.0,6.4,6.4,6.4,6.4,6.3,6.3,6.3,6.3,6.2,6.2,6.2,6.2,6.3,6.3,6.3,6.3,6.2,6.2,6.2,6.2,6.2,6.2,6.2

Questions about programming?Chat with your personal AI assistant