March 7, 2017 - Pre-Class

 mean.jackknife <- function(a_vector) {
  vec<-rep(0,length(a_vector))
  for (i in 1:length(a_vector)){
    vec[i]<-mean(a_vector[-i])
  }
  jackknife.variance<-((length(a_vector) - 1)/length(a_vector)) * sum((vec - mean(vec))^2)
  jackknife.stderr<-sqrt(jackknife.variance)
  return(jackknife.stderr)
}
some_normals <- rnorm(100,mean=7,sd=5)
mean(some_normals)
## [1] 7.35254
(formula_se_of_mean <- sd(some_normals)/sqrt(length(some_normals)))
## [1] 0.5227524
all.equal(formula_se_of_mean,mean.jackknife(some_normals))
## [1] TRUE
comments powered by Disqus