confidence_int = function(dataset, test) {
testdata = dataset %>%
select(test) %>% na.omit
n = nrow(testdata) # find the sample number
testdata = pull(testdata,test) # convert column to vector to use sd function
mean_pop = mean(testdata) # find the mean
sd_pop = sd(testdata) # find the standard deviation for each population
var_pop = var(testdata) # find the variance of each population
upper_limit = mean_pop + (1.96 * sd_pop)
lower_limit = mean_pop - (1.96 * sd_pop)
# find the 90% confidence interval for upper and lower
low = lower_limit + 1.64 * sqrt(var_pop * (1/n + 2/(n-1)))
high = upper_limit + 1.64 * sqrt(var_pop * (1/n + 2/(n-1)))
if (low<0) low=0 #not possible to be less than zero level
return(c(low,high))}
The range for AST for Healthy Adult Males is 14.47, 43.9
The range for AST for Healthy Adult Females is 9.679, 40.75