Please generalize ci95.t to ci.t so that we can calculate confidence interval at any confidence level given a sample using the KORGER.csv data The function prototype looks like, ci.t <- function(n, mu, sd_mu, conf) { ##your code goes here } The sample outputs need to be replicated are, setwd("…") kg <- read.csv("KORGER.csv") kd <- split(kg$Distance, kg$Team)$KOREA
- Please generalize ci95.t to ci.t so that we can calculate confidence interval at any confidence level given a sample using the KORGER.csv data
The function prototype looks like,
ci.t <- function(n, mu, sd_mu, conf)
{
##your code goes here
}
The sample outputs need to be replicated are,
setwd("…")
kg <- read.csv("KORGER.csv")
kd <- split(kg$Distance, kg$Team)$KOREA
n <- length(kd); m <- mean(kd); s <- sd(kd)/sqrt(n);
>ci.t(n, m, s, 0.95)
95%CILower 95%CIUpper
8448.693 11307.852
>ci.t(n,m,s,0.90)
90%CILower 90%CIUpper
8715.393 11041.152
>ci.t(n,m,s,0.99)
99%CILower 99%CIUpper
7844.859 11911.686
I've got this so far.....
kg <- read.csv("KORGER.csv")
kd <- split(kg$Distance, kg$Team)$KOREA
n <- length(kd); m <- mean(kd); s <- sd(kd)/sqrt(n);
ci.t <- function(n, mu, sd_mu)
{
lower <- round(mu - qt(0.975, n-1)*sd_mu, 3);
upper <- round(mu + qt(0.975, n-1)*sd_mu, 3);
ci <- c(1,lower,1,upper)
names(ci) <- c("%CILower ","%CIUpper")
ci
}
ci.t(n,m,s,0.95)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps