19.1: Jackknife sampling
- Page ID
- 45265
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)Introduction
edits: — under construction —
R packages
There are several R packages one could use. The package bootstrap
may be the the most general, and includes a jackknife routine suitable for any function. This page demonstrates jackknife estimate of correlation.
Example data set of cars, showing stopping distance by speed of car (scroll down or click here).
install package bootstrap
Jackknife estimates on linear models
These procedures can be done with the bootstrap package, but lmboot
is a specific package to solve the problem
install package lmboot
Example data set, Tadpoles from Chapter 14, copied to end of this page for your convenience (scroll down or click here).
R code
jackknife(VO2~Body.mass, data = Tadpoles)
R returns two values:
bootEstParam
, which are the jackknife parameter estimates. Each column in the matrix lists the values for a coefficient. For this model,bootEstParam$[,1]
is the intercept andbootEstParam$[,2]
is the slope.origEstParam
, a vector with the original parameter estimates for the model coefficients.
$bootEstParam (Intercept) Body.mass [1,] -660.8403 472.6841 [2,] -539.5951 430.3990 [3,] -612.8495 454.5188 [4,] -512.5914 423.0815 [5,] -543.1577 434.2789 [6,] -572.3895 442.9176 [7,] -613.7873 451.2656 [8,] -594.0366 446.2571 [9,] -582.1833 443.5404 [10,] -598.2244 456.0599 [11,] -531.3152 415.2467 [12,] -555.7287 430.5604 [13,] -726.8522 512.1268 $origEstParam [,1] (Intercept) -583.0454 Body.mass 444.9512
Get necessary statistics and plots
#95% CI slope quantile(jack.model.1$bootEstParam[,2], probs=c(.025, .975))
R returns
2.5% 97.5% 417.5971 500.2940
#95% CI intercept quantile(jack.model.1$bootEstParam[,1], probs=c(.025, .975))
R returns
2.5% 97.5% -707.0486 -518.2085
Coefficient estimates
Slope
#plot the sampling distribution of the slope coefficient par(mar=c(5,5,5,5)) #setting margins to my preferred values hist(jack.model.1$bootEstParam[,2], col="blue", main="Jackknife Sampling Distribution", xlab="Slope Estimate")
Intercept
#95% CI intercept quantile(jack.model.1$bootEstParam[,1], probs=c(.025, .975)) par(mar=c(5,5,5,5)) hist(jack.model.1$bootEstParam[,1], col="blue", main="Jackknife Sampling Distribution", xlab="Intercept Estimate")
Questions
edits: pending
Cars data set used in this page
speed | dist |
4 | 2 |
4 | 10 |
7 | 4 |
7 | 22 |
8 | 16 |
9 | 10 |
10 | 18 |
10 | 26 |
10 | 34 |
11 | 17 |
11 | 28 |
12 | 14 |
12 | 20 |
12 | 24 |
12 | 28 |
13 | 26 |
13 | 34 |
13 | 34 |
13 | 46 |
14 | 26 |
14 | 36 |
14 | 60 |
14 | 80 |
15 | 20 |
15 | 26 |
15 | 54 |
16 | 32 |
16 | 40 |
17 | 32 |
17 | 40 |
17 | 50 |
18 | 42 |
18 | 56 |
18 | 76 |
18 | 84 |
19 | 36 |
19 | 46 |
19 | 68 |
20 | 32 |
20 | 48 |
20 | 52 |
20 | 56 |
20 | 64 |
22 | 66 |
23 | 54 |
24 | 70 |
24 | 92 |
24 | 93 |
24 | 120 |
25 | 85 |
Tadpole data set used in this page (sorted)
Gosner | Body mass | VO2 |
I | 1.76 | 109.41 |
I | 1.88 | 329.06 |
I | 1.95 | 82.35 |
I | 2.13 | 198 |
I | 2.26 | 607.7 |
II | 2.28 | 362.71 |
II | 2.35 | 556.6 |
II | 2.62 | 612.93 |
II | 2.77 | 514.02 |
II | 2.97 | 961.01 |
II | 3.14 | 892.41 |
II | 3.79 | 976.97 |
NA | 1.46 | 170.91 |