Four Training Sets

Fitting a simple model with just an intercept

This simulation generates 1000 training sets each with 40 observations which are subsequently fit with a simple model that includes only an intercept. The black line is the true function, the red line is the average of the 1000 fitted simple models consisting of only an intercept. The dashed pink lines are each of the 1000 fitted models.

\(\widehat{\text{Bias}}(f_{\hat{\beta}}(x_0 = 8)) = f(x_0=8) - f_{\bar{\beta}}(x_0 = 8) = 0.9893582 - 0.3024128 = 0.6869454\).

\(\widehat{\text{Var}}(f_{\hat{\beta}}(x_0 = 8)) = \text{Var}(\hat{f}) = 0.0165838.\)

\(\widehat{\text{MSE}} = \widehat{\text{Bias}}^2 + \widehat{\text{Var}} = 0.471894 + 0.0165838 = 0.4884779\)

The average training MSE for this model is 0.6568826, and the average testing MSE for this model is 0.667975.

Fitting a straight line model

This simulation generates 1000 training sets each with 40 observations which are subsequently fit with a simple straight line model. The black line is the true function, the red line is the average of the 1000 fitted models. The dashed pink lines are the each of the 1000 fitted models.

\(\widehat{\text{Bias}}(f_{\hat{\beta}}(x_0 = 8)) = f(x_0=8) - f_{\bar{\beta}}(x_0 = 8) = 0.9893582 - 0.7985961 = 0.1907621\).

\(\widehat{\text{Var}}(f_{\hat{\beta}}(x_0 = 8)) = \text{Var}(\hat{f}) = 0.0190716.\)

\(\widehat{\text{MSE}} = \widehat{\text{Bias}}^2 + \widehat{\text{Var}} = 0.0363902 + 0.0190716 = 0.0554618\)

The average training MSE for this model is 0.3339655, and the average testing MSE for this model is 0.360184.

Fitting a second order polynomial model

This simulation generates 1000 training sets each with 40 observations which are subsequently fit with a second order polynomial model. The black line is the true function, the red line is the average of the 1000 fitted models. The dashed pink lines are the each of the 1000 fitted models.

\(\widehat{\text{Bias}}(f_{\hat{\beta}}(x_0 = 8)) = f(x_0=8) - f_{\bar{\beta}}(x_0 = 8) = 0.9893582 - 0.8798073 = 0.109551\).

\(\widehat{\text{Var}}(f_{\hat{\beta}}(x_0 = 8)) = \text{Var}(\hat{f}) = 0.0122917.\)

\(\widehat{\text{MSE}} = \widehat{\text{Bias}}^2 + \widehat{\text{Var}} = 0.0120014 + 0.0122917 = 0.0242931\)

The average training MSE for this model is 0.2432373, and the average testing MSE for this model is 0.2855654.

Fitting a third order polynomial model

This simulation generates 1000 training sets each with 40 observations which are subsequently fit with third order polynomial model. The black line is the true function, the red line is the average of the 1000 fitted models. The dashed pink lines are the each of the 1000 fitted models.

\(\widehat{\text{Bias}}(f_{\hat{\beta}}(x_0 = 8)) = f(x_0=8) - f_{\bar{\beta}}(x_0 = 8) = 0.9893582 - 1.0196625 = -0.0303043\).

\(\widehat{\text{Var}}(f_{\hat{\beta}}(x_0 = 8)) = \text{Var}(\hat{f}) = 0.0205521.\)

\(\widehat{\text{MSE}} = \widehat{\text{Bias}}^2 + \widehat{\text{Var}} = 9.1834824\times 10^{-4} + 0.0205521 = 0.0214705\)

The average training MSE for this model is 0.2285058, and the average testing MSE for this model is 0.2759346.

Fitting a fifth order polynomial model

This simulation generates 1000 training sets each with 40 observations which are subsequently fit with a fifth order polynomial model. The black line is the true function, the red line is the average of the 1000 fitted models. The dashed pink lines are the each of the 1000 fitted models.

\(\widehat{\text{Bias}}(f_{\hat{\beta}}(x_0 = 8)) = f(x_0=8) - f_{\bar{\beta}}(x_0 = 8) = 0.9893582 - 0.9855351 = 0.0038231\).

\(\widehat{\text{Var}}(f_{\hat{\beta}}(x_0 = 8)) = \text{Var}(\hat{f}) = 0.0297977.\)

\(\widehat{\text{MSE}} = \widehat{\text{Bias}}^2 + \widehat{\text{Var}} = 1.4616242\times 10^{-5} + 0.0297977 = 0.0298123\)

The average training MSE for this model is 0.2109398, and the average testing MSE for this model is 0.2877764.

Fitting a tenth order polynomial model

This simulation generates 1000 training sets each with 40 observations which are subsequently fit with a tenth order polynomial model. The black line is the true function, the red line is the average of the 1000 fitted models. The dashed pink lines are the each of the 1000 fitted models.

\(\widehat{\text{Bias}}(f_{\hat{\beta}}(x_0 = 8)) = f(x_0=8) - f_{\bar{\beta}}(x_0 = 8) = 0.9893582 - 0.9894886 = -1.3037524\times 10^{-4}\).

\(\widehat{\text{Var}}(f_{\hat{\beta}}(x_0 = 8)) = \text{Var}(\hat{f}) = 0.0734763.\)

\(\widehat{\text{MSE}} = \widehat{\text{Bias}}^2 + \widehat{\text{Var}} = 1.6997702\times 10^{-8} + 0.0734763 = 0.0734763\)

The average training MSE for this model is 0.1805673, and the average testing MSE for this model is 0.3166574.