Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions _subfiles/_def-prediction-error.qmd
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
:::{#def-prediction-error}
#### Prediction error

A [prediction function](#def-prediction) $\predfnf{\Predvar}$ has as its [estimand](https://morrison-lab.github.io/sds/estimation.html#def-estimand)
A [prediction function](#def-prediction-function) $\predfn$ has as its [estimand](https://morrison-lab.github.io/sds/estimation.html#def-estimand)
the observed [outcome](#def-outcome) $\Outvar$ of a [new observation](#def-new-observation) with [input](#def-input) $\Predvar$,
not the [conditional mean](#def-cond-expectation-function) of that outcome.
The **prediction error** of $\predfn$ is the prediction minus that outcome:

$$\prederrf{\predfn} \eqdef \predfnf{\Predvar} - \Outvar$$

:::

{{< slidebreak >}}

:::{#exm-prediction-error}
#### Prediction error in the best-predictor exercise

In @exr-best-predictor,
consider the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$.
Its [prediction error](#def-prediction-error) is $\prederrf{\predfn_1} = 3 - \Outvar$.
This is $3$ when $\Outvar = 0$.
It is $-3$ when $\Outvar = 6$.

:::
7 changes: 7 additions & 0 deletions _subfiles/_def-prediction-function.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:::{#def-prediction-function}
#### Prediction function

A **prediction function** $\predfn$ is a [function](https://morrison-lab.github.io/mds/functions.html#def-function) that takes a value $\predvar$ of the [input](#def-input)
and returns a [prediction](#def-prediction) $\predfnf{\predvar}$ of the [outcome](#def-outcome).

:::
9 changes: 4 additions & 5 deletions _subfiles/_def-reducible-risk.qmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
:::{#def-reducible-risk}
#### Reducible risk

In the squared-error risk decomposition of @thm-risk-decomposition,
the excess risk from choosing the prediction function $\predfn$ instead of the conditional mean,
The **reducible risk** of a [prediction function](#def-prediction-function) $\predfn$
is the [expectation](#def-expectation) of the squared difference
between $\predfnf{\Predvar}$ and the [conditional mean](#def-cond-expectation-function) $\truemeanf{\Predvar}$ of the [outcome](#def-outcome):

$$\E{\sqf{\E{\Outvar \mid \Predvar} - \predfnf{\Predvar}}} \ge 0$$

is the **reducible risk**.
$$\E{\sqf{\predfnf{\Predvar} - \truemeanf{\Predvar}}}$$

:::
13 changes: 1 addition & 12 deletions _subfiles/_def-squared-error-risk.qmd
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
:::{#def-squared-error-risk}
#### Squared-error risk (expected prediction error)

The **squared-error risk** of a prediction function $\predfnf{\Predvar}$,
The **squared-error risk** of a [prediction function](#def-prediction-function) $\predfn$,
also called its **expected prediction error** [@hastie2009elements, p. 18],
is the expected square of its [prediction error](#def-prediction-error):

$$\popriskf{\predfn} \eqdef \E{\sqf{\prederrf{\predfn}}}$$

:::

{{< slidebreak >}}

:::{#exm-squared-error-risk}
#### Squared-error risk in the best-predictor exercise

In @exr-best-predictor,
consider the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$.
Its [squared-error risk](#def-squared-error-risk) is $\popriskf{\predfn_1} = 5$.

:::
11 changes: 11 additions & 0 deletions _subfiles/_exm-cross-term-zero.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:::{#exm-cross-term-zero}
#### The vanishing cross term in the best-predictor exercise

In @exr-best-predictor, take the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$.
When $\Predvar = 0$, $\truemeanf{0} = 1$, so $\predfn_1\paren{0} - \truemeanf{0} = 2$,
and $\prederrf{\truemean} = 1 - \Outvar$ is $1$ or $-1$ with equal [probability](#def-probability),
so the product has conditional mean $0$.
The same cancellation happens when $\Predvar = 1$,
so the expectation of the product is $0$.

:::
10 changes: 10 additions & 0 deletions _subfiles/_exm-prediction-error.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:::{#exm-prediction-error}
#### Prediction error in the best-predictor exercise

In @exr-best-predictor,
consider the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$.
Its [prediction error](#def-prediction-error) is $\prederrf{\predfn_1} = 3 - \Outvar$.
This is $3$ when $\Outvar = 0$.
It is $-3$ when $\Outvar = 6$.

:::
8 changes: 8 additions & 0 deletions _subfiles/_exm-prediction-function.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:::{#exm-prediction-function}

Check warning on line 1 in _subfiles/_exm-prediction-function.qmd

View workflow job for this annotation

GitHub Actions / check / check-exm-figures

Example #exm-prediction-function has no figure. Fix: add a figure of the example's data, model or results, or add <!-- no-figure: reason --> inside the div
#### A constant prediction function

In @exr-best-predictor,
the [function](https://morrison-lab.github.io/mds/functions.html#def-function) $\predfn_1\paren{\predvar} = 3$ is a [prediction function](#def-prediction-function):
it returns the [prediction](#def-prediction) $3$ for every value of the [input](#def-input).

:::
4 changes: 2 additions & 2 deletions _subfiles/_exm-reducible-risk.qmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:::{#exm-reducible-risk}

Check warning on line 1 in _subfiles/_exm-reducible-risk.qmd

View workflow job for this annotation

GitHub Actions / check / check-exm-figures

Example #exm-reducible-risk has no figure. Fix: add a figure of the example's data, model or results, or add <!-- no-figure: reason --> inside the div
#### Reducible risk in the best-predictor exercise

In @exr-best-predictor,
the constant prediction $\predfn_1\paren{\Predvar} = 3$ has reducible risk $5 - 1 = 4$,
and the prediction $\predfn_2\paren{\Predvar} = 4\Predvar$ has reducible risk $2 - 1 = 1$.
the constant [prediction function](#def-prediction-function) $\predfn_1$, with $\predfn_1\paren{\Predvar} = 3$, has [reducible risk](#def-reducible-risk) $5 - 1 = 4$,
and the prediction function $\predfn_2$, with $\predfn_2\paren{\Predvar} = 4\Predvar$, has reducible risk $2 - 1 = 1$.

:::
9 changes: 9 additions & 0 deletions _subfiles/_exm-risk-decomposition.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:::{#exm-risk-decomposition}
#### The risk decomposition in the best-predictor exercise

In @exr-best-predictor,
the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$ has [squared-error risk](#def-squared-error-risk) $\popriskf{\predfn_1} = 5$,
which @thm-risk-decomposition splits as $5 = 1 + 4$:
the risk $1$ of the [conditional expectation function](#def-cond-expectation-function) plus the excess $4$ from using $\predfn_1$.

:::
8 changes: 8 additions & 0 deletions _subfiles/_exm-squared-error-risk.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:::{#exm-squared-error-risk}
#### Squared-error risk in the best-predictor exercise

In @exr-best-predictor,
consider the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$.
Its [squared-error risk](#def-squared-error-risk) is $\popriskf{\predfn_1} = 5$.

:::
16 changes: 1 addition & 15 deletions _subfiles/_lem-cross-term-zero.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#### The conditional mean's error is uncorrelated with any function of the input

Let $\truemeanf{\Predvar} \eqdef \E{\Outvar \mid \Predvar}$ be the [conditional expectation function](#def-cond-expectation-function) of $\Outvar$ given $\Predvar$.
For any [prediction function](#def-prediction) $\predfnf{\Predvar}$ with $\E{\predfnf{\Predvar}^2} < \infty$:
For any [prediction function](#def-prediction-function) $\predfn$ with $\E{\predfnf{\Predvar}^2} < \infty$:

$$\E{\prederrf{\truemean} \cd \paren{\predfnf{\Predvar} - \truemeanf{\Predvar}}} = 0$$

Expand Down Expand Up @@ -44,17 +44,3 @@ $$
$$

:::

{{< slidebreak >}}

:::{#exm-cross-term-zero}
#### The vanishing cross term in the best-predictor exercise

In @exr-best-predictor, take the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$.
When $\Predvar = 0$, $\truemeanf{0} = 1$, so $\predfn_1\paren{0} - \truemeanf{0} = 2$,
and $\prederrf{\truemean} = 1 - \Outvar$ is $1$ or $-1$ with equal [probability](#def-probability),
so the product has conditional mean $0$.
The same cancellation happens when $\Predvar = 1$,
so the expectation of the product is $0$.

:::
1 change: 1 addition & 0 deletions _subfiles/_rem-reducible-risk-notes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ $$\E{\sqf{\Outvar - \predfnf{\Predvar}}} = \E{\sqf{\Outvar - \E{\Outvar \mid \Pr
shows that the total squared-error risk is the sum of the
residual risk (@def-irreducible-risk)
and the reducible risk (@def-reducible-risk).
@james2021islr2e [Section 2.1.1, p. 18] calls the squared difference between a [prediction function](#def-prediction-function) and the [conditional mean](#def-cond-expectation-function) the "reducible error".

:::
4 changes: 2 additions & 2 deletions _subfiles/_thm-best-predictor.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

Let $\Predvar$ and $\Outvar$ be [jointly distributed](random-variables.qmd#def-jointly-distributed) random variables with $\E{\Outvar^2} < \infty$.
Let $\truemeanf{\Predvar} \eqdef \E{\Outvar \mid \Predvar}$ be the [conditional expectation function](#def-cond-expectation-function) of $\Outvar$ given $\Predvar$.
Write $\bestpredfn \eqdef \truemean$ for the prediction function that uses it.
Then for any [prediction function](#def-prediction) $\predfnf{\Predvar}$ with $\E{\predfnf{\Predvar}^2} < \infty$:
Write $\bestpredfn \eqdef \truemean$ for the [prediction function](#def-prediction-function) that uses it.
Then for any prediction function $\predfn$ with $\E{\predfnf{\Predvar}^2} < \infty$:

$$\popriskf{\predfn} \ge \popriskf{\bestpredfn}$$

Expand Down
14 changes: 1 addition & 13 deletions _subfiles/_thm-risk-decomposition.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#### Squared-error risk decomposition

Let $\truemeanf{\Predvar} \eqdef \E{\Outvar \mid \Predvar}$ be the [conditional expectation function](#def-cond-expectation-function) of $\Outvar$ given $\Predvar$.
For any [prediction function](#def-prediction) $\predfnf{\Predvar}$ with $\E{\predfnf{\Predvar}^2} < \infty$:
For any [prediction function](#def-prediction-function) $\predfn$ with $\E{\predfnf{\Predvar}^2} < \infty$:

$$\popriskf{\predfn} = \popriskf{\truemean} + \E{\sqf{\predfnf{\Predvar} - \truemeanf{\Predvar}}}$$

Expand Down Expand Up @@ -38,15 +38,3 @@ $$
$$

:::

{{< slidebreak >}}

:::{#exm-risk-decomposition}
#### The risk decomposition in the best-predictor exercise

In @exr-best-predictor,
the constant [prediction](#def-prediction) $\predfn_1\paren{\Predvar} = 3$ has [squared-error risk](#def-squared-error-risk) $\popriskf{\predfn_1} = 5$,
which @thm-risk-decomposition splits as $5 = 1 + 4$:
the risk $1$ of the [conditional expectation function](#def-cond-expectation-function) plus the excess $4$ from using $\predfn_1$.

:::
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#### Conditional mean as the minimizer of squared-error risk

Let $\Predvar$ and $\Outvar$ be [jointly distributed](random-variables.qmd#def-jointly-distributed) random variables with $\E{\Outvar^2} < \infty$.
Among [prediction functions](#def-prediction) $\predfnf{\Predvar}$ with $\E{\predfnf{\Predvar}^2} < \infty$,
Among [prediction functions](#def-prediction-function) $\predfn$ with $\E{\predfnf{\Predvar}^2} < \infty$,
the [conditional expectation function](#def-cond-expectation-function) is a [minimizer](https://morrison-lab.github.io/mds/algebra-basics.html#def-global-minimizer) of the [squared-error risk](#def-squared-error-risk):

$$\E{\Outvar \mid \Predvar} \in \argmin_{\predfn} \E{\sqf{\Outvar - \predfnf{\Predvar}}},$$
Expand All @@ -13,7 +13,7 @@ where $\argmin$ is the [set of minimizers](https://morrison-lab.github.io/mds/al

::: proof

By @thm-best-predictor, $\bestpredfnf{\Predvar} = \E{\Outvar \mid \Predvar}$ has [risk](#def-risk) no larger than that of any [prediction function](#def-prediction) $\predfn$,
By @thm-best-predictor, $\bestpredfnf{\Predvar} = \E{\Outvar \mid \Predvar}$ has [risk](#def-risk) no larger than that of any [prediction function](#def-prediction-function) $\predfn$,
so it is a [minimizer](https://morrison-lab.github.io/mds/algebra-basics.html#def-global-minimizer).

:::
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:::{#exm-best-predictor-argmin}

Check warning on line 1 in _subfiles/cor-best-predictor-argmin/_exm-best-predictor-argmin.qmd

View workflow job for this annotation

GitHub Actions / check / check-exm-figures

Example #exm-best-predictor-argmin has no figure. Fix: add a figure of the example's data, model or results, or add <!-- no-figure: reason --> inside the div
#### The minimizer in the best-predictor exercise

In @exr-best-predictor, the [conditional expectation function](#def-cond-expectation-function) $\bestpredfnf{\Predvar}$ has [risk](#def-risk) $1$.
The constant prediction $\predfn_1\paren{\Predvar} = 3$ has risk $5$ and $\predfn_2\paren{\Predvar} = 4\Predvar$ has risk $2$, both larger than $1$.
The constant [prediction function](#def-prediction-function) $\predfn_1$, with $\predfn_1\paren{\Predvar} = 3$, has risk $5$ and $\predfn_2\paren{\Predvar} = 4\Predvar$ has risk $2$, both larger than $1$.
So $\bestpredfn$ is the [minimizer](https://morrison-lab.github.io/mds/algebra-basics.html#def-global-minimizer) among the three.

:::
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#### The minimizer of squared-error risk is unique up to probability-1 equality

Let $\Predvar$ and $\Outvar$ be [jointly distributed](random-variables.qmd#def-jointly-distributed) random variables with $\E{\Outvar^2} < \infty$.
Every [prediction function](#def-prediction) $\predfnf{\Predvar}$ with $\E{\predfnf{\Predvar}^2} < \infty$
Every [prediction function](#def-prediction-function) $\predfn$ with $\E{\predfnf{\Predvar}^2} < \infty$
that is a [minimizer](https://morrison-lab.github.io/mds/algebra-basics.html#def-global-minimizer) of the [squared-error risk](#def-squared-error-risk)
(see @cor-best-predictor-argmin)
satisfies:
Expand Down
24 changes: 24 additions & 0 deletions expectation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ format:

{{< slidebreak >}}

{{< include pds/_subfiles/_def-prediction-function.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_exm-prediction-function.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_def-new-observation.qmd >}}

{{< slidebreak >}}
Expand All @@ -111,10 +119,18 @@ format:

{{< slidebreak >}}

{{< include pds/_subfiles/_exm-prediction-error.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_def-squared-error-risk.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_exm-squared-error-risk.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_rem-squared-error-risk-is-risk.qmd >}}

{{< slidebreak >}}
Expand All @@ -127,10 +143,18 @@ format:

{{< slidebreak >}}

{{< include pds/_subfiles/_exm-cross-term-zero.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_thm-risk-decomposition.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_exm-risk-decomposition.qmd >}}

{{< slidebreak >}}

{{< include pds/_subfiles/_thm-best-predictor.qmd >}}

{{< slidebreak >}}
Expand Down
Loading