|
486 | 486 | "id": "a3a920ae",
|
487 | 487 | "metadata": {},
|
488 | 488 | "source": [
|
489 |
| - "As in Figure~\\ref{Ch5:cvplot}, we see a sharp drop in the estimated test MSE between the linear and\n", |
| 489 | + "As in Figure 5.4, we see a sharp drop in the estimated test MSE between the linear and\n", |
490 | 490 | "quadratic fits, but then no clear improvement from using higher-degree polynomials.\n",
|
491 | 491 | "\n",
|
492 | 492 | "Above we introduced the `outer()` method of the `np.power()`\n",
|
|
589 | 589 | "Notice that the computation time is much shorter than that of LOOCV.\n",
|
590 | 590 | "(In principle, the computation time for LOOCV for a least squares\n",
|
591 | 591 | "linear model should be faster than for $k$-fold CV, due to the\n",
|
592 |
| - "availability of the formula~(\\ref{Ch5:eq:LOOCVform}) for LOOCV;\n", |
| 592 | + "availability of the formula~(5.2) for LOOCV;\n", |
593 | 593 | "however, the generic `cross_validate()` function does not make\n",
|
594 | 594 | "use of this formula.) We still see little evidence that using cubic\n",
|
595 | 595 | "or higher-degree polynomial terms leads to a lower test error than simply\n",
|
|
699 | 699 | "\n",
|
700 | 700 | "## The Bootstrap\n",
|
701 | 701 | "We illustrate the use of the bootstrap in the simple example\n",
|
702 |
| - " {of Section~\\ref{Ch5:sec:bootstrap},} as well as on an example involving\n", |
| 702 | + " {of Section 5.2,} as well as on an example involving\n", |
703 | 703 | "estimating the accuracy of the linear regression model on the `Auto`\n",
|
704 | 704 | "data set.\n",
|
705 | 705 | "### Estimating the Accuracy of a Statistic of Interest\n",
|
|
714 | 714 | "To illustrate the bootstrap, we\n",
|
715 | 715 | "start with a simple example.\n",
|
716 | 716 | "The `Portfolio` data set in the `ISLP` package is described\n",
|
717 |
| - "in Section~\\ref{Ch5:sec:bootstrap}. The goal is to estimate the\n", |
718 |
| - "sampling variance of the parameter $\\alpha$ given in formula~(\\ref{Ch5:min.var}). We will\n", |
| 717 | + "in Section 5.2. The goal is to estimate the\n", |
| 718 | + "sampling variance of the parameter $\\alpha$ given in formula~(5.7). We will\n", |
719 | 719 | "create a function\n",
|
720 | 720 | "`alpha_func()`, which takes as input a dataframe `D` assumed\n",
|
721 | 721 | "to have columns `X` and `Y`, as well as a\n",
|
|
754 | 754 | "source": [
|
755 | 755 | "This function returns an estimate for $\\alpha$\n",
|
756 | 756 | "based on applying the minimum\n",
|
757 |
| - " variance formula (\\ref{Ch5:min.var}) to the observations indexed by\n", |
| 757 | + " variance formula (5.7) to the observations indexed by\n", |
758 | 758 | "the argument `idx`. For instance, the following command\n",
|
759 | 759 | "estimates $\\alpha$ using all 100 observations."
|
760 | 760 | ]
|
|
934 | 934 | "`horsepower` to predict `mpg` in the `Auto` data set. We\n",
|
935 | 935 | "will compare the estimates obtained using the bootstrap to those\n",
|
936 | 936 | "obtained using the formulas for ${\\rm SE}(\\hat{\\beta}_0)$ and\n",
|
937 |
| - "${\\rm SE}(\\hat{\\beta}_1)$ described in Section~\\ref{Ch3:secoefsec}.\n", |
| 937 | + "${\\rm SE}(\\hat{\\beta}_1)$ described in Section 3.1.2.\n", |
938 | 938 | "\n",
|
939 | 939 | "To use our `boot_SE()` function, we must write a function (its\n",
|
940 | 940 | "first argument)\n",
|
|
1115 | 1115 | "0.85, and that the bootstrap\n",
|
1116 | 1116 | "estimate for ${\\rm SE}(\\hat{\\beta}_1)$ is\n",
|
1117 | 1117 | "0.0074. As discussed in\n",
|
1118 |
| - "Section~\\ref{Ch3:secoefsec}, standard formulas can be used to compute\n", |
| 1118 | + "Section 3.1.2, standard formulas can be used to compute\n", |
1119 | 1119 | "the standard errors for the regression coefficients in a linear\n",
|
1120 | 1120 | "model. These can be obtained using the `summarize()` function\n",
|
1121 | 1121 | "from `ISLP.sm`."
|
|
1160 | 1160 | "metadata": {},
|
1161 | 1161 | "source": [
|
1162 | 1162 | "The standard error estimates for $\\hat{\\beta}_0$ and $\\hat{\\beta}_1$\n",
|
1163 |
| - "obtained using the formulas from Section~\\ref{Ch3:secoefsec} are\n", |
| 1163 | + "obtained using the formulas from Section 3.1.2 are\n", |
1164 | 1164 | "0.717 for the\n",
|
1165 | 1165 | "intercept and\n",
|
1166 | 1166 | "0.006 for the\n",
|
1167 | 1167 | "slope. Interestingly, these are somewhat different from the estimates\n",
|
1168 | 1168 | "obtained using the bootstrap. Does this indicate a problem with the\n",
|
1169 | 1169 | "bootstrap? In fact, it suggests the opposite. Recall that the\n",
|
1170 | 1170 | "standard formulas given in\n",
|
1171 |
| - " {Equation~\\ref{Ch3:se.eqn} on page~\\pageref{Ch3:se.eqn}}\n", |
| 1171 | + " {Equation 3.8 on page~\\pageref{Ch3:se.eqn}}\n", |
1172 | 1172 | "rely on certain assumptions. For example,\n",
|
1173 | 1173 | "they depend on the unknown parameter $\\sigma^2$, the noise\n",
|
1174 | 1174 | "variance. We then estimate $\\sigma^2$ using the RSS. Now although the\n",
|
1175 | 1175 | "formulas for the standard errors do not rely on the linear model being\n",
|
1176 | 1176 | "correct, the estimate for $\\sigma^2$ does. We see\n",
|
1177 |
| - " {in Figure~\\ref{Ch3:polyplot} on page~\\pageref{Ch3:polyplot}} that there is\n", |
| 1177 | + " {in Figure 3.8 on page~\\pageref{Ch3:polyplot}} that there is\n", |
1178 | 1178 | "a non-linear relationship in the data, and so the residuals from a\n",
|
1179 | 1179 | "linear fit will be inflated, and so will $\\hat{\\sigma}^2$. Secondly,\n",
|
1180 | 1180 | "the standard formulas assume (somewhat unrealistically) that the $x_i$\n",
|
|
1187 | 1187 | "Below we compute the bootstrap standard error estimates and the\n",
|
1188 | 1188 | "standard linear regression estimates that result from fitting the\n",
|
1189 | 1189 | "quadratic model to the data. Since this model provides a good fit to\n",
|
1190 |
| - "the data (Figure~\\ref{Ch3:polyplot}), there is now a better\n", |
| 1190 | + "the data (Figure 3.8), there is now a better\n", |
1191 | 1191 | "correspondence between the bootstrap estimates and the standard\n",
|
1192 | 1192 | "estimates of ${\\rm SE}(\\hat{\\beta}_0)$, ${\\rm SE}(\\hat{\\beta}_1)$ and\n",
|
1193 | 1193 | "${\\rm SE}(\\hat{\\beta}_2)$."
|
|
0 commit comments