# Jacknife Estimation

There are many ways of estimate parameters from a sample. Sometimes it’s difficult to calculate variance and bias estimation. Here I want to show one amazing technique which can solve this problem: Jacknife estimation. This method is one of the most common resampling techniques such as boostrap. The parameter of interest is estimated from the subsamples omitting the $i$-th observation and the variance of the full sample estimator from the variability between the subsample estimates.

We are going to use a default R dataset called precip to show a simple exampleData refers to the average amount of precipitation (rainfall) in inches for each of 70 United States and Puerto Rico cities. This is our population and imagine we only have access to 25 observations.


precip # Data
N <- length(precip) # Total Population
n <- 25 # Sample Size
s <- sample(precip, n) # Sample



$s=\{x_1,...,x_n\}$ would be our sample from which we want to estimate parameter $\theta=\bar{X}$. First we generate $k$ subsamples whithout the $i$-th element and compute the statistic, in this case the mean.

$\hat{\theta}_i(x_,...x,_{i-1}, x_{i+1}, ..., x_n)$

Then, we calculate the pseudovalues

$\theta_{J_i}=n\hat{\theta}-(n-1)\hat{\theta}_i$

and the jacknife estimator is the mean of the pseudovalues

$\hat{\theta}_J=\dfrac{1}{k}\sum_{i=1}^k \hat{\theta}_{Ji}$


k <- 25 # Number of subsamples
sJ <- matrix(nrow=n-1,ncol=k) # Subsamples Matrix
for(i in 1:k) sJ[,i] <- s[-i]
theta.i <- apply(sJ, 2, mean)
theta <- mean(s) # Global Estimator
theta.Ji <- n*theta - (n-1)*theta.i # Pseudovalues
theta.J <- mean(theta.Ji) # Jacknife Estimator



Where the jacknife estimator variance is the variance of global mean estimated.


var.J <- var(theta.Ji) # Var Jacknife Estimator
IC.up <- theta.J + qt(0.975, n-1)*sqrt(var.J/n)
IC.low <- theta.J - qt(0.975, n-1)*sqrt(var.J/n)
real.theta <- mean(precip) # Real mean
library(ggplot2)
dt <- data.frame(s, real.theta, theta.J, IC.up, IC.low)
ggplot(dt, aes(s)) +
geom_density(aes(y=..count..), col='grey', fill='grey') +
geom_vline(xintercept = c(real.theta, theta.J, IC.up, IC.low),
color=c('#e41a1c',rep('#377eb8',3)),
linetype=c(rep('dashed',2), rep('solid',2)),size=1) +
geom_text(aes(real.theta+2, 0.001, label = "Real Mean"),
size = 4, hjust = 0, angle=90, vjust = 0, color='#e41a1c') +
geom_text(aes(theta.J-2,0.001, label = "Jacknife Mean"),
size = 4, hjust = 0, angle=90, vjust = 0, color='#377eb8')