From 0fc71b7a7fba63816cfbfec62e7738811eeb9076 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 11 Sep 2023 06:08:52 +0200 Subject: [PATCH] update --- doc/pub/week37/html/._week37-bs000.html | 115 +++--- doc/pub/week37/html/._week37-bs001.html | 122 +++--- doc/pub/week37/html/._week37-bs002.html | 157 +++----- doc/pub/week37/html/._week37-bs003.html | 159 +++++--- doc/pub/week37/html/._week37-bs004.html | 148 ++++--- doc/pub/week37/html/._week37-bs005.html | 201 ++++------ doc/pub/week37/html/._week37-bs006.html | 190 ++++++--- doc/pub/week37/html/._week37-bs007.html | 133 +++---- doc/pub/week37/html/._week37-bs008.html | 150 ++++--- doc/pub/week37/html/._week37-bs009.html | 157 ++++---- doc/pub/week37/html/._week37-bs010.html | 154 ++++---- doc/pub/week37/html/._week37-bs011.html | 157 ++++---- doc/pub/week37/html/._week37-bs012.html | 140 ++++--- doc/pub/week37/html/._week37-bs013.html | 117 +++--- doc/pub/week37/html/._week37-bs014.html | 129 +++--- doc/pub/week37/html/._week37-bs015.html | 130 ++++--- doc/pub/week37/html/._week37-bs016.html | 135 ++++--- doc/pub/week37/html/._week37-bs017.html | 138 +++---- doc/pub/week37/html/._week37-bs018.html | 143 +++---- doc/pub/week37/html/._week37-bs019.html | 142 ++++--- doc/pub/week37/html/._week37-bs020.html | 137 ++++--- doc/pub/week37/html/._week37-bs021.html | 225 ++++------- doc/pub/week37/html/._week37-bs022.html | 184 +++++---- doc/pub/week37/html/._week37-bs023.html | 202 +++++++--- doc/pub/week37/html/._week37-bs024.html | 143 ++++--- doc/pub/week37/html/._week37-bs025.html | 146 +++---- doc/pub/week37/html/._week37-bs026.html | 136 ++++--- doc/pub/week37/html/._week37-bs027.html | 123 +++--- doc/pub/week37/html/._week37-bs028.html | 150 ++++--- doc/pub/week37/html/._week37-bs029.html | 151 +++---- doc/pub/week37/html/._week37-bs030.html | 144 +++---- doc/pub/week37/html/._week37-bs031.html | 135 +++---- doc/pub/week37/html/._week37-bs032.html | 144 ++++--- doc/pub/week37/html/._week37-bs033.html | 147 +++---- doc/pub/week37/html/._week37-bs034.html | 165 ++++---- doc/pub/week37/html/._week37-bs035.html | 153 +++++--- doc/pub/week37/html/._week37-bs036.html | 140 ++++--- doc/pub/week37/html/._week37-bs037.html | 144 ++++--- doc/pub/week37/html/._week37-bs038.html | 136 +++---- doc/pub/week37/html/._week37-bs039.html | 136 ++++--- doc/pub/week37/html/._week37-bs040.html | 139 ++++--- doc/pub/week37/html/._week37-bs041.html | 192 ++++----- doc/pub/week37/html/._week37-bs042.html | 164 +++++--- doc/pub/week37/html/._week37-bs043.html | 197 +++++----- doc/pub/week37/html/._week37-bs044.html | 174 ++++++--- doc/pub/week37/html/._week37-bs045.html | 192 +++------ doc/pub/week37/html/._week37-bs046.html | 174 +++++---- doc/pub/week37/html/._week37-bs047.html | 205 ++++++---- doc/pub/week37/html/._week37-bs048.html | 230 +++++------ doc/pub/week37/html/._week37-bs049.html | 221 +++++++---- doc/pub/week37/html/week37-bs.html | 115 +++--- doc/pub/week37/html/week37-reveal.html | 25 +- doc/pub/week37/html/week37-solarized.html | 24 +- doc/pub/week37/html/week37.html | 24 +- doc/pub/week37/ipynb/ipynb-week37-src.tar.gz | Bin 1022692 -> 1022692 bytes doc/pub/week37/ipynb/week37.ipynb | 390 ++++++++++--------- doc/src/week37/exercisesweek37.do.txt | 2 +- doc/src/week37/week37.do.txt | 10 +- 58 files changed, 4374 insertions(+), 4062 deletions(-) diff --git a/doc/pub/week37/html/._week37-bs000.html b/doc/pub/week37/html/._week37-bs000.html index eb476f9f4..d3cd07a53 100644 --- a/doc/pub/week37/html/._week37-bs000.html +++ b/doc/pub/week37/html/._week37-bs000.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -303,10 +308,12 @@ MathJax.Hub.Config({
    -

    Sep 10, 2023

    +

    Sep 11, 2023


    + +

    Read »

    @@ -328,7 +335,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs001.html b/doc/pub/week37/html/._week37-bs001.html index ab1d9f685..b38df33f2 100644 --- a/doc/pub/week37/html/._week37-bs001.html +++ b/doc/pub/week37/html/._week37-bs001.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -295,6 +300,7 @@ MathJax.Hub.Config({
  • Exercise for week 37
  • Work on project 1
  • See also additional note on scaling (jupyter-notebook) sent separately. This will be discussed during the first hour of each session.
  • +
  • For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.
  • @@ -304,12 +310,14 @@ MathJax.Hub.Config({ @@ -332,7 +340,7 @@ MathJax.Hub.Config({
  • 10
  • 11
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs002.html b/doc/pub/week37/html/._week37-bs002.html index ec38c2210..e1a4c4742 100644 --- a/doc/pub/week37/html/._week37-bs002.html +++ b/doc/pub/week37/html/._week37-bs002.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -284,50 +289,8 @@ MathJax.Hub.Config({

     

     

     

    - -

    Linking the regression analysis with a statistical interpretation

    - -

    We will now couple the discussions of ordinary least squares, Ridge -and Lasso regression with a statistical interpretation, that is we -move from a linear algebra analysis to a statistical analysis. In -particular, we will focus on what the regularization terms can result -in. We will amongst other things show that the regularization -parameter can reduce considerably the variance of the parameters -\( \beta \). -

    - -

    The -advantage of doing linear regression is that we actually end up with -analytical expressions for several statistical quantities. -Standard least squares and Ridge regression allow us to -derive quantities like the variance and other expectation values in a -rather straightforward way. -

    - -

    It is assumed that \( \varepsilon_i -\sim \mathcal{N}(0, \sigma^2) \) and the \( \varepsilon_{i} \) are -independent, i.e.: -

    -$$ -\begin{align*} -\mbox{Cov}(\varepsilon_{i_1}, -\varepsilon_{i_2}) & = \left\{ \begin{array}{lcc} \sigma^2 & \mbox{if} -& i_1 = i_2, \\ 0 & \mbox{if} & i_1 \not= i_2. \end{array} \right. -\end{align*} -$$ - -

    The randomness of \( \varepsilon_i \) implies that -\( \mathbf{y}_i \) is also a random variable. In particular, -\( \mathbf{y}_i \) is normally distributed, because \( \varepsilon_i \sim -\mathcal{N}(0, \sigma^2) \) and \( \mathbf{X}_{i,\ast} \, \boldsymbol{\beta} \) is a -non-random scalar. To specify the parameters of the distribution of -\( \mathbf{y}_i \) we need to calculate its first two moments. -

    - -

    Recall that \( \boldsymbol{X} \) is a matrix of dimensionality \( n\times p \). The -notation above \( \mathbf{X}_{i,\ast} \) means that we are looking at the -row number \( i \) and perform a sum over all values \( p \). -

    + +

    Material from last week and relevant for the weekly exercises

    @@ -346,7 +309,7 @@ row number \( i \) and perform a sum over all values \( p \).

  • 11
  • 12
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs003.html b/doc/pub/week37/html/._week37-bs003.html index 2963cb2c6..87c59672a 100644 --- a/doc/pub/week37/html/._week37-bs003.html +++ b/doc/pub/week37/html/._week37-bs003.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -284,24 +289,50 @@ MathJax.Hub.Config({

     

     

     

    - -

    Assumptions made

    + +

    Linking the regression analysis with a statistical interpretation

    -

    The assumption we have made here can be summarized as (and this is going to be useful when we discuss the bias-variance trade off) -that there exists a function \( f(\boldsymbol{x}) \) and a normal distributed error \( \boldsymbol{\varepsilon}\sim \mathcal{N}(0, \sigma^2) \) -which describe our data +

    We will now couple the discussions of ordinary least squares, Ridge +and Lasso regression with a statistical interpretation, that is we +move from a linear algebra analysis to a statistical analysis. In +particular, we will focus on what the regularization terms can result +in. We will amongst other things show that the regularization +parameter can reduce considerably the variance of the parameters +\( \beta \). +

    + +

    The +advantage of doing linear regression is that we actually end up with +analytical expressions for several statistical quantities. +Standard least squares and Ridge regression allow us to +derive quantities like the variance and other expectation values in a +rather straightforward way. +

    + +

    It is assumed that \( \varepsilon_i +\sim \mathcal{N}(0, \sigma^2) \) and the \( \varepsilon_{i} \) are +independent, i.e.:

    $$ -\boldsymbol{y} = f(\boldsymbol{x})+\boldsymbol{\varepsilon} +\begin{align*} +\mbox{Cov}(\varepsilon_{i_1}, +\varepsilon_{i_2}) & = \left\{ \begin{array}{lcc} \sigma^2 & \mbox{if} +& i_1 = i_2, \\ 0 & \mbox{if} & i_1 \not= i_2. \end{array} \right. +\end{align*} $$ -

    We approximate this function with our model from the solution of the linear regression equations, that is our -function \( f \) is approximated by \( \boldsymbol{\tilde{y}} \) where we want to minimize \( (\boldsymbol{y}-\boldsymbol{\tilde{y}})^2 \), our MSE, with +

    The randomness of \( \varepsilon_i \) implies that +\( \mathbf{y}_i \) is also a random variable. In particular, +\( \mathbf{y}_i \) is normally distributed, because \( \varepsilon_i \sim +\mathcal{N}(0, \sigma^2) \) and \( \mathbf{X}_{i,\ast} \, \boldsymbol{\beta} \) is a +non-random scalar. To specify the parameters of the distribution of +\( \mathbf{y}_i \) we need to calculate its first two moments.

    -$$ -\boldsymbol{\tilde{y}} = \boldsymbol{X}\boldsymbol{\beta}. -$$ +

    Recall that \( \boldsymbol{X} \) is a matrix of dimensionality \( n\times p \). The +notation above \( \mathbf{X}_{i,\ast} \) means that we are looking at the +row number \( i \) and perform a sum over all values \( p \). +

    @@ -321,7 +352,7 @@ $$

  • 12
  • 13
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs004.html b/doc/pub/week37/html/._week37-bs004.html index cfb1c406c..700516db2 100644 --- a/doc/pub/week37/html/._week37-bs004.html +++ b/doc/pub/week37/html/._week37-bs004.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,38 +290,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Expectation value and variance

    +

    Assumptions made

    -

    We can calculate the expectation value of \( \boldsymbol{y} \) for a given element \( i \)

    -$$ -\begin{align*} -\mathbb{E}(y_i) & = -\mathbb{E}(\mathbf{X}_{i, \ast} \, \boldsymbol{\beta}) + \mathbb{E}(\varepsilon_i) -\, \, \, = \, \, \, \mathbf{X}_{i, \ast} \, \beta, -\end{align*} -$$ - -

    while -its variance is +

    The assumption we have made here can be summarized as (and this is going to be useful when we discuss the bias-variance trade off) +that there exists a function \( f(\boldsymbol{x}) \) and a normal distributed error \( \boldsymbol{\varepsilon}\sim \mathcal{N}(0, \sigma^2) \) +which describe our data

    $$ -\begin{align*} \mbox{Var}(y_i) & = \mathbb{E} \{ [y_i -- \mathbb{E}(y_i)]^2 \} \, \, \, = \, \, \, \mathbb{E} ( y_i^2 ) - -[\mathbb{E}(y_i)]^2 \\ & = \mathbb{E} [ ( \mathbf{X}_{i, \ast} \, -\beta + \varepsilon_i )^2] - ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 \\ & -= \mathbb{E} [ ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 + 2 \varepsilon_i -\mathbf{X}_{i, \ast} \, \boldsymbol{\beta} + \varepsilon_i^2 ] - ( \mathbf{X}_{i, -\ast} \, \beta)^2 \\ & = ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 + 2 -\mathbb{E}(\varepsilon_i) \mathbf{X}_{i, \ast} \, \boldsymbol{\beta} + -\mathbb{E}(\varepsilon_i^2 ) - ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 -\\ & = \mathbb{E}(\varepsilon_i^2 ) \, \, \, = \, \, \, -\mbox{Var}(\varepsilon_i) \, \, \, = \, \, \, \sigma^2. -\end{align*} +\boldsymbol{y} = f(\boldsymbol{x})+\boldsymbol{\varepsilon} $$ -

    Hence, \( y_i \sim \mathcal{N}( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta}, \sigma^2) \), that is \( \boldsymbol{y} \) follows a normal distribution with -mean value \( \boldsymbol{X}\boldsymbol{\beta} \) and variance \( \sigma^2 \) (not be confused with the singular values of the SVD). +

    We approximate this function with our model from the solution of the linear regression equations, that is our +function \( f \) is approximated by \( \boldsymbol{\tilde{y}} \) where we want to minimize \( (\boldsymbol{y}-\boldsymbol{\tilde{y}})^2 \), our MSE, with

    +$$ +\boldsymbol{\tilde{y}} = \boldsymbol{X}\boldsymbol{\beta}. +$$ +

    @@ -337,7 +327,7 @@ mean value \( \boldsymbol{X}\boldsymbol{\beta} \) and variance \( \sigma^2 \) (n

  • 13
  • 14
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs005.html b/doc/pub/week37/html/._week37-bs005.html index 2c7e335e0..0d9960f8c 100644 --- a/doc/pub/week37/html/._week37-bs005.html +++ b/doc/pub/week37/html/._week37-bs005.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,81 +290,37 @@ MathJax.Hub.Config({

     

     

     

    -

    Expectation value and variance for \( \boldsymbol{\beta} \)

    +

    Expectation value and variance

    -

    With the OLS expressions for the optimal parameters \( \boldsymbol{\hat{\beta}} \) we can evaluate the expectation value

    +

    We can calculate the expectation value of \( \boldsymbol{y} \) for a given element \( i \)

    $$ -\mathbb{E}(\boldsymbol{\hat{\beta}}) = \mathbb{E}[ (\mathbf{X}^{\top} \mathbf{X})^{-1}\mathbf{X}^{T} \mathbf{Y}]=(\mathbf{X}^{T} \mathbf{X})^{-1}\mathbf{X}^{T} \mathbb{E}[ \mathbf{Y}]=(\mathbf{X}^{T} \mathbf{X})^{-1} \mathbf{X}^{T}\mathbf{X}\boldsymbol{\beta}=\boldsymbol{\beta}. +\begin{align*} +\mathbb{E}(y_i) & = +\mathbb{E}(\mathbf{X}_{i, \ast} \, \boldsymbol{\beta}) + \mathbb{E}(\varepsilon_i) +\, \, \, = \, \, \, \mathbf{X}_{i, \ast} \, \beta, +\end{align*} $$ -

    This means that the estimator of the regression parameters is unbiased.

    - -

    We can also calculate the variance

    - -

    The variance of the optimal value \( \boldsymbol{\hat{\beta}} \) is

    -$$ -\begin{eqnarray*} -\mbox{Var}(\boldsymbol{\hat{\beta}}) & = & \mathbb{E} \{ [\boldsymbol{\beta} - \mathbb{E}(\boldsymbol{\beta})] [\boldsymbol{\beta} - \mathbb{E}(\boldsymbol{\beta})]^{T} \} -\\ -& = & \mathbb{E} \{ [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y} - \boldsymbol{\beta}] \, [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y} - \boldsymbol{\beta}]^{T} \} -\\ -% & = & \mathbb{E} \{ [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y}] \, [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y}]^{T} \} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} -% \\ -% & = & \mathbb{E} \{ (\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y} \, \mathbf{Y}^{T} \, \mathbf{X} \, (\mathbf{X}^{T} \mathbf{X})^{-1} \} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} -% \\ -& = & (\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \, \mathbb{E} \{ \mathbf{Y} \, \mathbf{Y}^{T} \} \, \mathbf{X} \, (\mathbf{X}^{T} \mathbf{X})^{-1} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} -\\ -& = & (\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \, \{ \mathbf{X} \, \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} \, \mathbf{X}^{T} + \sigma^2 \} \, \mathbf{X} \, (\mathbf{X}^{T} \mathbf{X})^{-1} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} -% \\ -% & = & (\mathbf{X}^T \mathbf{X})^{-1} \, \mathbf{X}^T \, \mathbf{X} \, \boldsymbol{\beta} \, \boldsymbol{\beta}^T \, \mathbf{X}^T \, \mathbf{X} \, (\mathbf{X}^T % \mathbf{X})^{-1} -% \\ -% & & + \, \, \sigma^2 \, (\mathbf{X}^T \mathbf{X})^{-1} \, \mathbf{X}^T \, \mathbf{X} \, (\mathbf{X}^T \mathbf{X})^{-1} - \boldsymbol{\beta} \boldsymbol{\beta}^T -\\ -& = & \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} + \sigma^2 \, (\mathbf{X}^{T} \mathbf{X})^{-1} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} -\, \, \, = \, \, \, \sigma^2 \, (\mathbf{X}^{T} \mathbf{X})^{-1}, -\end{eqnarray*} -$$ - -

    where we have used that \( \mathbb{E} (\mathbf{Y} \mathbf{Y}^{T}) = -\mathbf{X} \, \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} \, \mathbf{X}^{T} + -\sigma^2 \, \mathbf{I}_{nn} \). From \( \mbox{Var}(\boldsymbol{\beta}) = \sigma^2 -\, (\mathbf{X}^{T} \mathbf{X})^{-1} \), one obtains an estimate of the -variance of the estimate of the \( j \)-th regression coefficient: -\( \boldsymbol{\sigma}^2 (\boldsymbol{\beta}_j ) = \boldsymbol{\sigma}^2 [(\mathbf{X}^{T} \mathbf{X})^{-1}]_{jj} \). This may be used to -construct a confidence interval for the estimates. +

    while +its variance is

    - -

    In a similar way, we can obtain analytical expressions for say the -expectation values of the parameters \( \boldsymbol{\beta} \) and their variance -when we employ Ridge regression, allowing us again to define a confidence interval. -

    - -

    It is rather straightforward to show that

    $$ -\mathbb{E} \big[ \boldsymbol{\beta}^{\mathrm{Ridge}} \big]=(\mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I}_{pp})^{-1} (\mathbf{X}^{\top} \mathbf{X})\boldsymbol{\beta}^{\mathrm{OLS}}. +\begin{align*} \mbox{Var}(y_i) & = \mathbb{E} \{ [y_i +- \mathbb{E}(y_i)]^2 \} \, \, \, = \, \, \, \mathbb{E} ( y_i^2 ) - +[\mathbb{E}(y_i)]^2 \\ & = \mathbb{E} [ ( \mathbf{X}_{i, \ast} \, +\beta + \varepsilon_i )^2] - ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 \\ & += \mathbb{E} [ ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 + 2 \varepsilon_i +\mathbf{X}_{i, \ast} \, \boldsymbol{\beta} + \varepsilon_i^2 ] - ( \mathbf{X}_{i, +\ast} \, \beta)^2 \\ & = ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 + 2 +\mathbb{E}(\varepsilon_i) \mathbf{X}_{i, \ast} \, \boldsymbol{\beta} + +\mathbb{E}(\varepsilon_i^2 ) - ( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta})^2 +\\ & = \mathbb{E}(\varepsilon_i^2 ) \, \, \, = \, \, \, +\mbox{Var}(\varepsilon_i) \, \, \, = \, \, \, \sigma^2. +\end{align*} $$ -

    We see clearly that -\( \mathbb{E} \big[ \boldsymbol{\beta}^{\mathrm{Ridge}} \big] \not= \boldsymbol{\beta}^{\mathrm{OLS}} \) for any \( \lambda > 0 \). We say then that the ridge estimator is biased. -

    - -

    We can also compute the variance as

    - -$$ -\mbox{Var}[\boldsymbol{\beta}^{\mathrm{Ridge}}]=\sigma^2[ \mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I} ]^{-1} \mathbf{X}^{T} \mathbf{X} \{ [ \mathbf{X}^{\top} \mathbf{X} + \lambda \mathbf{I} ]^{-1}\}^{T}, -$$ - -

    and it is easy to see that if the parameter \( \lambda \) goes to infinity then the variance of Ridge parameters \( \boldsymbol{\beta} \) goes to zero.

    - -

    With this, we can compute the difference

    - -$$ -\mbox{Var}[\boldsymbol{\beta}^{\mathrm{OLS}}]-\mbox{Var}(\boldsymbol{\beta}^{\mathrm{Ridge}})=\sigma^2 [ \mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I} ]^{-1}[ 2\lambda\mathbf{I} + \lambda^2 (\mathbf{X}^{T} \mathbf{X})^{-1} ] \{ [ \mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I} ]^{-1}\}^{T}. -$$ - -

    The difference is non-negative definite since each component of the -matrix product is non-negative definite. -This means the variance we obtain with the standard OLS will always for \( \lambda > 0 \) be larger than the variance of \( \boldsymbol{\beta} \) obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below. +

    Hence, \( y_i \sim \mathcal{N}( \mathbf{X}_{i, \ast} \, \boldsymbol{\beta}, \sigma^2) \), that is \( \boldsymbol{y} \) follows a normal distribution with +mean value \( \boldsymbol{X}\boldsymbol{\beta} \) and variance \( \sigma^2 \) (not be confused with the singular values of the SVD).

    @@ -382,7 +343,7 @@ This means the variance we obtain with the standard OLS will always for \( \lamb

  • 14
  • 15
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs006.html b/doc/pub/week37/html/._week37-bs006.html index 66f326002..0b97b865f 100644 --- a/doc/pub/week37/html/._week37-bs006.html +++ b/doc/pub/week37/html/._week37-bs006.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,7 +290,84 @@ MathJax.Hub.Config({

     

     

     

    -

    Material for lecture Thursday September 14

    +

    Expectation value and variance for \( \boldsymbol{\beta} \)

    + +

    With the OLS expressions for the optimal parameters \( \boldsymbol{\hat{\beta}} \) we can evaluate the expectation value

    +$$ +\mathbb{E}(\boldsymbol{\hat{\beta}}) = \mathbb{E}[ (\mathbf{X}^{\top} \mathbf{X})^{-1}\mathbf{X}^{T} \mathbf{Y}]=(\mathbf{X}^{T} \mathbf{X})^{-1}\mathbf{X}^{T} \mathbb{E}[ \mathbf{Y}]=(\mathbf{X}^{T} \mathbf{X})^{-1} \mathbf{X}^{T}\mathbf{X}\boldsymbol{\beta}=\boldsymbol{\beta}. +$$ + +

    This means that the estimator of the regression parameters is unbiased.

    + +

    We can also calculate the variance

    + +

    The variance of the optimal value \( \boldsymbol{\hat{\beta}} \) is

    +$$ +\begin{eqnarray*} +\mbox{Var}(\boldsymbol{\hat{\beta}}) & = & \mathbb{E} \{ [\boldsymbol{\beta} - \mathbb{E}(\boldsymbol{\beta})] [\boldsymbol{\beta} - \mathbb{E}(\boldsymbol{\beta})]^{T} \} +\\ +& = & \mathbb{E} \{ [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y} - \boldsymbol{\beta}] \, [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y} - \boldsymbol{\beta}]^{T} \} +\\ +% & = & \mathbb{E} \{ [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y}] \, [(\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y}]^{T} \} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} +% \\ +% & = & \mathbb{E} \{ (\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \mathbf{Y} \, \mathbf{Y}^{T} \, \mathbf{X} \, (\mathbf{X}^{T} \mathbf{X})^{-1} \} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} +% \\ +& = & (\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \, \mathbb{E} \{ \mathbf{Y} \, \mathbf{Y}^{T} \} \, \mathbf{X} \, (\mathbf{X}^{T} \mathbf{X})^{-1} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} +\\ +& = & (\mathbf{X}^{T} \mathbf{X})^{-1} \, \mathbf{X}^{T} \, \{ \mathbf{X} \, \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} \, \mathbf{X}^{T} + \sigma^2 \} \, \mathbf{X} \, (\mathbf{X}^{T} \mathbf{X})^{-1} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} +% \\ +% & = & (\mathbf{X}^T \mathbf{X})^{-1} \, \mathbf{X}^T \, \mathbf{X} \, \boldsymbol{\beta} \, \boldsymbol{\beta}^T \, \mathbf{X}^T \, \mathbf{X} \, (\mathbf{X}^T % \mathbf{X})^{-1} +% \\ +% & & + \, \, \sigma^2 \, (\mathbf{X}^T \mathbf{X})^{-1} \, \mathbf{X}^T \, \mathbf{X} \, (\mathbf{X}^T \mathbf{X})^{-1} - \boldsymbol{\beta} \boldsymbol{\beta}^T +\\ +& = & \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} + \sigma^2 \, (\mathbf{X}^{T} \mathbf{X})^{-1} - \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} +\, \, \, = \, \, \, \sigma^2 \, (\mathbf{X}^{T} \mathbf{X})^{-1}, +\end{eqnarray*} +$$ + +

    where we have used that \( \mathbb{E} (\mathbf{Y} \mathbf{Y}^{T}) = +\mathbf{X} \, \boldsymbol{\beta} \, \boldsymbol{\beta}^{T} \, \mathbf{X}^{T} + +\sigma^2 \, \mathbf{I}_{nn} \). From \( \mbox{Var}(\boldsymbol{\beta}) = \sigma^2 +\, (\mathbf{X}^{T} \mathbf{X})^{-1} \), one obtains an estimate of the +variance of the estimate of the \( j \)-th regression coefficient: +\( \boldsymbol{\sigma}^2 (\boldsymbol{\beta}_j ) = \boldsymbol{\sigma}^2 [(\mathbf{X}^{T} \mathbf{X})^{-1}]_{jj} \). This may be used to +construct a confidence interval for the estimates. +

    + +

    In a similar way, we can obtain analytical expressions for say the +expectation values of the parameters \( \boldsymbol{\beta} \) and their variance +when we employ Ridge regression, allowing us again to define a confidence interval. +

    + +

    It is rather straightforward to show that

    +$$ +\mathbb{E} \big[ \boldsymbol{\beta}^{\mathrm{Ridge}} \big]=(\mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I}_{pp})^{-1} (\mathbf{X}^{\top} \mathbf{X})\boldsymbol{\beta}^{\mathrm{OLS}}. +$$ + +

    We see clearly that +\( \mathbb{E} \big[ \boldsymbol{\beta}^{\mathrm{Ridge}} \big] \not= \boldsymbol{\beta}^{\mathrm{OLS}} \) for any \( \lambda > 0 \). We say then that the ridge estimator is biased. +

    + +

    We can also compute the variance as

    + +$$ +\mbox{Var}[\boldsymbol{\beta}^{\mathrm{Ridge}}]=\sigma^2[ \mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I} ]^{-1} \mathbf{X}^{T} \mathbf{X} \{ [ \mathbf{X}^{\top} \mathbf{X} + \lambda \mathbf{I} ]^{-1}\}^{T}, +$$ + +

    and it is easy to see that if the parameter \( \lambda \) goes to infinity then the variance of Ridge parameters \( \boldsymbol{\beta} \) goes to zero.

    + +

    With this, we can compute the difference

    + +$$ +\mbox{Var}[\boldsymbol{\beta}^{\mathrm{OLS}}]-\mbox{Var}(\boldsymbol{\beta}^{\mathrm{Ridge}})=\sigma^2 [ \mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I} ]^{-1}[ 2\lambda\mathbf{I} + \lambda^2 (\mathbf{X}^{T} \mathbf{X})^{-1} ] \{ [ \mathbf{X}^{T} \mathbf{X} + \lambda \mathbf{I} ]^{-1}\}^{T}. +$$ + +

    The difference is non-negative definite since each component of the +matrix product is non-negative definite. +This means the variance we obtain with the standard OLS will always for \( \lambda > 0 \) be larger than the variance of \( \boldsymbol{\beta} \) obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below. +

    + +

    For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.

    @@ -308,7 +390,7 @@ MathJax.Hub.Config({

  • 15
  • 16
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs007.html b/doc/pub/week37/html/._week37-bs007.html index a9df19e26..9c3bbd5cc 100644 --- a/doc/pub/week37/html/._week37-bs007.html +++ b/doc/pub/week37/html/._week37-bs007.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,27 +290,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Deriving OLS from a probability distribution

    - -

    Our basic assumption when we derived the OLS equations was to assume -that our output is determined by a given continuous function -\( f(\boldsymbol{x}) \) and a random noise \( \boldsymbol{\epsilon} \) given by the normal -distribution with zero mean value and an undetermined variance -\( \sigma^2 \). -

    - -

    We found above that the outputs \( \boldsymbol{y} \) have a mean value given by -\( \boldsymbol{X}\hat{\boldsymbol{\beta}} \) and variance \( \sigma^2 \). Since the entries to -the design matrix are not stochastic variables, we can assume that the -probability distribution of our targets is also a normal distribution -but now with mean value \( \boldsymbol{X}\hat{\boldsymbol{\beta}} \). This means that a -single output \( y_i \) is given by the Gaussian distribution -

    - -$$ -y_i\sim \mathcal{N}(\boldsymbol{X}_{i,*}\boldsymbol{\beta}, \sigma^2)=\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}. -$$ - +

    Material for lecture Thursday September 14

    @@ -329,7 +314,7 @@ $$

  • 16
  • 17
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs008.html b/doc/pub/week37/html/._week37-bs008.html index 62c05ddd7..be9516864 100644 --- a/doc/pub/week37/html/._week37-bs008.html +++ b/doc/pub/week37/html/._week37-bs008.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,38 +290,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Independent and Identically Distrubuted (iid)

    +

    Deriving OLS from a probability distribution

    -

    We assume now that the various \( y_i \) values are stochastically distributed according to the above Gaussian distribution. -We define this distribution as +

    Our basic assumption when we derived the OLS equations was to assume +that our output is determined by a given continuous function +\( f(\boldsymbol{x}) \) and a random noise \( \boldsymbol{\epsilon} \) given by the normal +distribution with zero mean value and an undetermined variance +\( \sigma^2 \).

    -$$ -p(y_i, \boldsymbol{X}\vert\boldsymbol{\beta})=\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}, -$$ -

    which reads as finding the likelihood of an event \( y_i \) with the input variables \( \boldsymbol{X} \) given the parameters (to be determined) \( \boldsymbol{\beta} \).

    - -

    Since these events are assumed to be independent and identicall distributed we can build the probability distribution function (PDF) for all possible event \( \boldsymbol{y} \) as the product of the single events, that is we have

    - -$$ -p(\boldsymbol{y},\boldsymbol{X}\vert\boldsymbol{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}=\prod_{i=0}^{n-1}p(y_i,\boldsymbol{X}\vert\boldsymbol{\beta}). -$$ - -

    We will write this in a more compact form reserving \( \boldsymbol{D} \) for the domain of events, including the ouputs (targets) and the inputs. That is -in case we have a simple one-dimensional input and output case +

    We found above that the outputs \( \boldsymbol{y} \) have a mean value given by +\( \boldsymbol{X}\hat{\boldsymbol{\beta}} \) and variance \( \sigma^2 \). Since the entries to +the design matrix are not stochastic variables, we can assume that the +probability distribution of our targets is also a normal distribution +but now with mean value \( \boldsymbol{X}\hat{\boldsymbol{\beta}} \). This means that a +single output \( y_i \) is given by the Gaussian distribution

    + $$ -\boldsymbol{D}=[(x_0,y_0), (x_1,y_1),\dots, (x_{n-1},y_{n-1})]. +y_i\sim \mathcal{N}(\boldsymbol{X}_{i,*}\boldsymbol{\beta}, \sigma^2)=\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}. $$ -

    In the more general case the various inputs should be replaced by the possible features represented by the input data set \( \boldsymbol{X} \). -We can now rewrite the above probability as -

    -$$ -p(\boldsymbol{D}\vert\boldsymbol{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}. -$$ - -

    It is a conditional probability (see below) and reads as the likelihood of a domain of events \( \boldsymbol{D} \) given a set of parameters \( \boldsymbol{\beta} \).

    @@ -341,7 +335,7 @@ $$

  • 17
  • 18
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs009.html b/doc/pub/week37/html/._week37-bs009.html index f336672cb..f1f99c14f 100644 --- a/doc/pub/week37/html/._week37-bs009.html +++ b/doc/pub/week37/html/._week37-bs009.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,32 +290,38 @@ MathJax.Hub.Config({

     

     

     

    -

    Maximum Likelihood Estimation (MLE)

    +

    Independent and Identically Distrubuted (iid)

    -

    In statistics, maximum likelihood estimation (MLE) is a method of -estimating the parameters of an assumed probability distribution, -given some observed data. This is achieved by maximizing a likelihood -function so that, under the assumed statistical model, the observed -data is the most probable. +

    We assume now that the various \( y_i \) values are stochastically distributed according to the above Gaussian distribution. +We define this distribution as

    +$$ +p(y_i, \boldsymbol{X}\vert\boldsymbol{\beta})=\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}, +$$ -

    We will assume here that our events are given by the above Gaussian -distribution and we will determine the optimal parameters \( \beta \) by -maximizing the above PDF. However, computing the derivatives of a -product function is cumbersome and can easily lead to overflow and/or -underflowproblems, with potentials for loss of numerical precision. -

    +

    which reads as finding the likelihood of an event \( y_i \) with the input variables \( \boldsymbol{X} \) given the parameters (to be determined) \( \boldsymbol{\beta} \).

    -

    In practice, it is more convenient to maximize the logarithm of the -PDF because it is a monotonically increasing function of the argument. -Alternatively, and this will be our option, we will minimize the -negative of the logarithm since this is a monotonically decreasing -function. -

    +

    Since these events are assumed to be independent and identicall distributed we can build the probability distribution function (PDF) for all possible event \( \boldsymbol{y} \) as the product of the single events, that is we have

    -

    Note also that maximization/minimization of the logarithm of the PDF -is equivalent to the maximization/minimization of the function itself. +$$ +p(\boldsymbol{y},\boldsymbol{X}\vert\boldsymbol{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}=\prod_{i=0}^{n-1}p(y_i,\boldsymbol{X}\vert\boldsymbol{\beta}). +$$ + +

    We will write this in a more compact form reserving \( \boldsymbol{D} \) for the domain of events, including the ouputs (targets) and the inputs. That is +in case we have a simple one-dimensional input and output case

    +$$ +\boldsymbol{D}=[(x_0,y_0), (x_1,y_1),\dots, (x_{n-1},y_{n-1})]. +$$ + +

    In the more general case the various inputs should be replaced by the possible features represented by the input data set \( \boldsymbol{X} \). +We can now rewrite the above probability as +

    +$$ +p(\boldsymbol{D}\vert\boldsymbol{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}. +$$ + +

    It is a conditional probability (see below) and reads as the likelihood of a domain of events \( \boldsymbol{D} \) given a set of parameters \( \boldsymbol{\beta} \).

    @@ -336,7 +347,7 @@ is equivalent to the maximization/minimization of the function itself.

  • 18
  • 19
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs010.html b/doc/pub/week37/html/._week37-bs010.html index 592eb936c..c7b7097a6 100644 --- a/doc/pub/week37/html/._week37-bs010.html +++ b/doc/pub/week37/html/._week37-bs010.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,31 +290,32 @@ MathJax.Hub.Config({

     

     

     

    -

    A new Cost Function

    +

    Maximum Likelihood Estimation (MLE)

    -

    We could now define a new cost function to minimize, namely the negative logarithm of the above PDF

    +

    In statistics, maximum likelihood estimation (MLE) is a method of +estimating the parameters of an assumed probability distribution, +given some observed data. This is achieved by maximizing a likelihood +function so that, under the assumed statistical model, the observed +data is the most probable. +

    -$$ -C(\boldsymbol{\beta}=-\log{\prod_{i=0}^{n-1}p(y_i,\boldsymbol{X}\vert\boldsymbol{\beta})}=-\sum_{i=0}^{n-1}\log{p(y_i,\boldsymbol{X}\vert\boldsymbol{\beta})}, -$$ +

    We will assume here that our events are given by the above Gaussian +distribution and we will determine the optimal parameters \( \beta \) by +maximizing the above PDF. However, computing the derivatives of a +product function is cumbersome and can easily lead to overflow and/or +underflowproblems, with potentials for loss of numerical precision. +

    -

    which becomes

    -$$ -C(\boldsymbol{\beta}=\frac{n}{2}\log{2\pi\sigma^2}+\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}. -$$ +

    In practice, it is more convenient to maximize the logarithm of the +PDF because it is a monotonically increasing function of the argument. +Alternatively, and this will be our option, we will minimize the +negative of the logarithm since this is a monotonically decreasing +function. +

    -

    Taking the derivative of the new cost function with respect to the parameters \( \beta \) we recognize our familiar OLS equation, namely

    - -$$ -\boldsymbol{X}^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right) =0, -$$ - -

    which leads to the well-known OLS equation for the optimal paramters \( \beta \)

    -$$ -\hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}! -$$ - -

    Before we make a similar analysis for Ridge and Lasso regression, we need a short reminder on statistics.

    +

    Note also that maximization/minimization of the logarithm of the PDF +is equivalent to the maximization/minimization of the function itself. +

    @@ -336,7 +342,7 @@ $$

  • 19
  • 20
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs011.html b/doc/pub/week37/html/._week37-bs011.html index 617863eaa..483376afb 100644 --- a/doc/pub/week37/html/._week37-bs011.html +++ b/doc/pub/week37/html/._week37-bs011.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,41 +290,31 @@ MathJax.Hub.Config({

     

     

     

    -

    More basic Statistics and Bayes' theorem

    +

    A new Cost Function

    -

    A central theorem in statistics is Bayes' theorem. This theorem plays a similar role as the good old Pythagoras' theorem in geometry. -Bayes' theorem is extremely simple to derive. But to do so we need some basic axioms from statistics. -

    +

    We could now define a new cost function to minimize, namely the negative logarithm of the above PDF

    -

    Assume we have two domains of events \( X=[x_0,x_1,\dots,x_{n-1}] \) and \( Y=[y_0,y_1,\dots,y_{n-1}] \).

    - -

    We define also the likelihood for \( X \) and \( Y \) as \( p(X) \) and \( p(Y) \) respectively. -The likelihood of a specific event \( x_i \) (or \( y_i \)) is then written as \( p(X=x_i) \) or just \( p(x_i)=p_i \). -

    - -
    -
    - $$ -p(X \cup Y)= p(X)+p(Y)-p(X \cap Y). -$$ -
    -
    - - -
    -
    - -$$ -p(X \cup Y)= p(X,Y)= p(X\vert Y)p(Y)=p(Y\vert X)p(X), +C(\boldsymbol{\beta}=-\log{\prod_{i=0}^{n-1}p(y_i,\boldsymbol{X}\vert\boldsymbol{\beta})}=-\sum_{i=0}^{n-1}\log{p(y_i,\boldsymbol{X}\vert\boldsymbol{\beta})}, $$ -

    where we read \( p(X\vert Y) \) as the likelihood of obtaining \( X \) given \( Y \).

    -
    -
    +

    which becomes

    +$$ +C(\boldsymbol{\beta}=\frac{n}{2}\log{2\pi\sigma^2}+\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}. +$$ +

    Taking the derivative of the new cost function with respect to the parameters \( \beta \) we recognize our familiar OLS equation, namely

    -

    If we have independent events then \( p(X,Y)=p(X)p(Y) \).

    +$$ +\boldsymbol{X}^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right) =0, +$$ + +

    which leads to the well-known OLS equation for the optimal paramters \( \beta \)

    +$$ +\hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}! +$$ + +

    Before we make a similar analysis for Ridge and Lasso regression, we need a short reminder on statistics.

    @@ -346,7 +341,7 @@ $$

  • 20
  • 21
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs012.html b/doc/pub/week37/html/._week37-bs012.html index 1dd783fed..a71c57633 100644 --- a/doc/pub/week37/html/._week37-bs012.html +++ b/doc/pub/week37/html/._week37-bs012.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,19 +290,42 @@ MathJax.Hub.Config({

     

     

     

    -

    Marginal Probability

    +

    More basic Statistics and Bayes' theorem

    + +

    A central theorem in statistics is Bayes' theorem. This theorem plays a similar role as the good old Pythagoras' theorem in geometry. +Bayes' theorem is extremely simple to derive. But to do so we need some basic axioms from statistics. +

    + +

    Assume we have two domains of events \( X=[x_0,x_1,\dots,x_{n-1}] \) and \( Y=[y_0,y_1,\dots,y_{n-1}] \).

    + +

    We define also the likelihood for \( X \) and \( Y \) as \( p(X) \) and \( p(Y) \) respectively. +The likelihood of a specific event \( x_i \) (or \( y_i \)) is then written as \( p(X=x_i) \) or just \( p(x_i)=p_i \). +

    -

    The marginal probability is defined in terms of only one of the set of variables \( X,Y \). For a discrete probability we have

    $$ -p(X)=\sum_{i=0}^{n-1}p(X,Y=y_i)=\sum_{i=0}^{n-1}p(X\vert Y=y_i)p(Y=y_i)=\sum_{i=0}^{n-1}p(X\vert y_i)p(y_i). +p(X \cup Y)= p(X)+p(Y)-p(X \cap Y). $$
    +
    +
    + +$$ +p(X \cup Y)= p(X,Y)= p(X\vert Y)p(Y)=p(Y\vert X)p(X), +$$ + +

    where we read \( p(X\vert Y) \) as the likelihood of obtaining \( X \) given \( Y \).

    +
    +
    + + +

    If we have independent events then \( p(X,Y)=p(X)p(Y) \).

    +

    diff --git a/doc/pub/week37/html/._week37-bs013.html b/doc/pub/week37/html/._week37-bs013.html index 3df2205ab..cd1a20a82 100644 --- a/doc/pub/week37/html/._week37-bs013.html +++ b/doc/pub/week37/html/._week37-bs013.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,14 +290,14 @@ MathJax.Hub.Config({

     

     

     

    -

    Conditional Probability

    +

    Marginal Probability

    -

    The conditional probability, if \( p(Y) > 0 \), is

    +

    The marginal probability is defined in terms of only one of the set of variables \( X,Y \). For a discrete probability we have

    $$ -p(X\vert Y)= \frac{p(X,Y)}{p(Y)}=\frac{p(X,Y)}{\sum_{i=0}^{n-1}p(Y\vert X=x_i)p(x_i)}. +p(X)=\sum_{i=0}^{n-1}p(X,Y=y_i)=\sum_{i=0}^{n-1}p(X\vert Y=y_i)p(Y=y_i)=\sum_{i=0}^{n-1}p(X\vert y_i)p(y_i). $$
    @@ -323,7 +328,7 @@ $$
  • 22
  • 23
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs014.html b/doc/pub/week37/html/._week37-bs014.html index e83d8fb4f..6a5857096 100644 --- a/doc/pub/week37/html/._week37-bs014.html +++ b/doc/pub/week37/html/._week37-bs014.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,20 +290,18 @@ MathJax.Hub.Config({

     

     

     

    -

    Bayes' Theorem

    +

    Conditional Probability

    -

    If we combine the conditional probability with the marginal probability and the standard product rule, we have

    +

    The conditional probability, if \( p(Y) > 0 \), is

    +
    +
    + $$ -p(X\vert Y)= \frac{p(X,Y)}{p(Y)}, +p(X\vert Y)= \frac{p(X,Y)}{p(Y)}=\frac{p(X,Y)}{\sum_{i=0}^{n-1}p(Y\vert X=x_i)p(x_i)}. $$ +
    +
    -

    which we can rewrite as

    - -$$ -p(X\vert Y)= \frac{p(X,Y)}{\sum_{i=0}^{n-1}p(Y\vert X=x_i)p(x_i)}=\frac{p(Y\vert X)p(X)}{\sum_{i=0}^{n-1}p(Y\vert X=x_i)p(x_i)}, -$$ - -

    which is Bayes' theorem. It allows us to evaluate the uncertainty in in \( X \) after we have observed \( Y \). We can easily interchange \( X \) with \( Y \).

    @@ -325,7 +328,7 @@ $$

  • 23
  • 24
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs015.html b/doc/pub/week37/html/._week37-bs015.html index 404ed6ac8..6c5bfd64b 100644 --- a/doc/pub/week37/html/._week37-bs015.html +++ b/doc/pub/week37/html/._week37-bs015.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,17 +290,20 @@ MathJax.Hub.Config({

     

     

     

    -

    Interpretations of Bayes' Theorem

    +

    Bayes' Theorem

    -

    The quantity \( p(Y\vert X) \) on the right-hand side of the theorem is -evaluated for the observed data \( Y \) and can be viewed as a function of -the parameter space represented by \( X \). This function is not -necesseraly normalized and is normally called the likelihood function. -

    +

    If we combine the conditional probability with the marginal probability and the standard product rule, we have

    +$$ +p(X\vert Y)= \frac{p(X,Y)}{p(Y)}, +$$ -

    The function \( p(X) \) on the right hand side is called the prior while the function on the left hand side is the called the posterior probability. The denominator on the right hand side serves as a normalization factor for the posterior distribution.

    +

    which we can rewrite as

    -

    Let us try to illustrate Bayes' theorem through an example.

    +$$ +p(X\vert Y)= \frac{p(X,Y)}{\sum_{i=0}^{n-1}p(Y\vert X=x_i)p(x_i)}=\frac{p(Y\vert X)p(X)}{\sum_{i=0}^{n-1}p(Y\vert X=x_i)p(x_i)}, +$$ + +

    which is Bayes' theorem. It allows us to evaluate the uncertainty in in \( X \) after we have observed \( Y \). We can easily interchange \( X \) with \( Y \).

    @@ -322,7 +330,7 @@ necesseraly normalized and is normally called the likelihood function.

  • 24
  • 25
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs016.html b/doc/pub/week37/html/._week37-bs016.html index 27c55f737..64a76fc7f 100644 --- a/doc/pub/week37/html/._week37-bs016.html +++ b/doc/pub/week37/html/._week37-bs016.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,27 +290,17 @@ MathJax.Hub.Config({

     

     

     

    -

    Example of Usage of Bayes' theorem

    +

    Interpretations of Bayes' Theorem

    -

    Let us suppose that you are undergoing a series of mammography scans in -order to rule out possible breast cancer cases. We define the -sensitivity for a positive event by the variable \( X \). It takes binary -values with \( X=1 \) representing a positive event and \( X=0 \) being a -negative event. We reserve \( Y \) as a classification parameter for -either a negative or a positive breast cancer confirmation. (Short note on wordings: positive here means having breast cancer, although none of us would consider this being a positive thing). +

    The quantity \( p(Y\vert X) \) on the right-hand side of the theorem is +evaluated for the observed data \( Y \) and can be viewed as a function of +the parameter space represented by \( X \). This function is not +necesseraly normalized and is normally called the likelihood function.

    -

    We let \( Y=1 \) represent the the case of having breast cancer and \( Y=0 \) as not.

    +

    The function \( p(X) \) on the right hand side is called the prior while the function on the left hand side is the called the posterior probability. The denominator on the right hand side serves as a normalization factor for the posterior distribution.

    -

    Let us assume that if you have breast cancer, the test will be positive with a probability of \( 0.8 \), that is we have

    - -$$ -p(X=1\vert Y=1) =0.8. -$$ - -

    This obviously sounds scary since many would conclude that if the test is positive, there is a likelihood of \( 80\% \) for having cancer. -It is however not correct, as the following Bayesian analysis shows. -

    +

    Let us try to illustrate Bayes' theorem through an example.

    @@ -332,7 +327,7 @@ It is however not correct, as the following Bayesian analysis shows.

  • 25
  • 26
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs017.html b/doc/pub/week37/html/._week37-bs017.html index 369116b7c..d2074ad95 100644 --- a/doc/pub/week37/html/._week37-bs017.html +++ b/doc/pub/week37/html/._week37-bs017.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,28 +290,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Doing it correctly

    +

    Example of Usage of Bayes' theorem

    -

    If we look at various national surveys on breast cancer, the general likelihood of developing breast cancer is a very small number. -Let us assume that the prior probability in the population as a whole is +

    Let us suppose that you are undergoing a series of mammography scans in +order to rule out possible breast cancer cases. We define the +sensitivity for a positive event by the variable \( X \). It takes binary +values with \( X=1 \) representing a positive event and \( X=0 \) being a +negative event. We reserve \( Y \) as a classification parameter for +either a negative or a positive breast cancer confirmation. (Short note on wordings: positive here means having breast cancer, although none of us would consider this being a positive thing).

    -$$ -p(Y=1) =0.004. -$$ +

    We let \( Y=1 \) represent the the case of having breast cancer and \( Y=0 \) as not.

    -

    We need also to account for the fact that the test may produce a false positive result (false alarm). Let us here assume that we have

    -$$ -p(X=1\vert Y=0) =0.1. -$$ - -

    Using Bayes' theorem we can then find the posterior probability that the person has breast cancer in case of a positive test, that is we can compute

    +

    Let us assume that if you have breast cancer, the test will be positive with a probability of \( 0.8 \), that is we have

    $$ -p(Y=1\vert X=1)=\frac{p(X=1\vert Y=1)p(Y=1)}{p(X=1\vert Y=1)p(Y=1)+p(X=1\vert Y=0)p(Y=0)}=\frac{0.8\times 0.004}{0.8\times 0.004+0.1\times 0.996}=0.031. +p(X=1\vert Y=1) =0.8. $$ -

    That is, in case of a positive test, there is only a \( 3\% \) chance of having breast cancer!

    +

    This obviously sounds scary since many would conclude that if the test is positive, there is a likelihood of \( 80\% \) for having cancer. +It is however not correct, as the following Bayesian analysis shows. +

    @@ -333,7 +337,7 @@ $$

  • 26
  • 27
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs018.html b/doc/pub/week37/html/._week37-bs018.html index 35d37be40..532959cc6 100644 --- a/doc/pub/week37/html/._week37-bs018.html +++ b/doc/pub/week37/html/._week37-bs018.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,32 +290,28 @@ MathJax.Hub.Config({

     

     

     

    -

    Bayes' Theorem and Ridge and Lasso Regression

    +

    Doing it correctly

    -

    Using Bayes' theorem we can gain a better intuition about Ridge and Lasso regression.

    - -

    For ordinary least squares we postulated that the maximum likelihood for the doamin of events \( \boldsymbol{D} \) (one-dimensional case)

    -$$ -\boldsymbol{D}=[(x_0,y_0), (x_1,y_1),\dots, (x_{n-1},y_{n-1})], -$$ - -

    is given by

    -$$ -p(\boldsymbol{D}\vert\boldsymbol{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}. -$$ - -

    In Bayes' theorem this function plays the role of the so-called likelihood. We could now ask the question what is the posterior probability of a parameter set \( \boldsymbol{\beta} \) given a domain of events \( \boldsymbol{D} \)? That is, how can we define the posterior probability

    +

    If we look at various national surveys on breast cancer, the general likelihood of developing breast cancer is a very small number. +Let us assume that the prior probability in the population as a whole is +

    $$ -p(\boldsymbol{\beta}\vert\boldsymbol{D}). +p(Y=1) =0.004. $$ -

    Bayes' theorem comes to our rescue here since (omitting the normalization constant)

    +

    We need also to account for the fact that the test may produce a false positive result (false alarm). Let us here assume that we have

    $$ -p(\boldsymbol{\beta}\vert\boldsymbol{D})\propto p(\boldsymbol{D}\vert\boldsymbol{\beta})p(\boldsymbol{\beta}). +p(X=1\vert Y=0) =0.1. $$ -

    We have a model for \( p(\boldsymbol{D}\vert\boldsymbol{\beta}) \) but need one for the prior \( p(\boldsymbol{\beta} \)!

    +

    Using Bayes' theorem we can then find the posterior probability that the person has breast cancer in case of a positive test, that is we can compute

    + +$$ +p(Y=1\vert X=1)=\frac{p(X=1\vert Y=1)p(Y=1)}{p(X=1\vert Y=1)p(Y=1)+p(X=1\vert Y=0)p(Y=0)}=\frac{0.8\times 0.004}{0.8\times 0.004+0.1\times 0.996}=0.031. +$$ + +

    That is, in case of a positive test, there is only a \( 3\% \) chance of having breast cancer!

    @@ -337,7 +338,7 @@ $$

  • 27
  • 28
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs019.html b/doc/pub/week37/html/._week37-bs019.html index 47935379e..394cb786e 100644 --- a/doc/pub/week37/html/._week37-bs019.html +++ b/doc/pub/week37/html/._week37-bs019.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,41 +290,32 @@ MathJax.Hub.Config({

     

     

     

    -

    Ridge and Bayes

    +

    Bayes' Theorem and Ridge and Lasso Regression

    -

    With the posterior probability defined by a likelihood which we have -already modeled and an unknown prior, we are now ready to make -additional models for the prior. -

    - -

    We can, based on our discussions of the variance of \( \boldsymbol{\beta} \) and the mean value, assume that the prior for the values \( \boldsymbol{\beta} \) is given by a Gaussian with mean value zero and variance \( \tau^2 \), that is

    +

    Using Bayes' theorem we can gain a better intuition about Ridge and Lasso regression.

    +

    For ordinary least squares we postulated that the maximum likelihood for the doamin of events \( \boldsymbol{D} \) (one-dimensional case)

    $$ -p(\boldsymbol{\beta})=\prod_{j=0}^{p-1}\exp{\left(-\frac{\beta_j^2}{2\tau^2}\right)}. +\boldsymbol{D}=[(x_0,y_0), (x_1,y_1),\dots, (x_{n-1},y_{n-1})], $$ -

    Our posterior probability becomes then (omitting the normalization factor which is just a constant)

    +

    is given by

    $$ -p(\boldsymbol{\beta\vert\boldsymbol{D})}=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}\prod_{j=0}^{p-1}\exp{\left(-\frac{\beta_j^2}{2\tau^2}\right)}. +p(\boldsymbol{D}\vert\boldsymbol{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}. $$ -

    We can now optimize this quantity with respect to \( \boldsymbol{\beta} \). As we -did for OLS, this is most conveniently done by taking the negative -logarithm of the posterior probability. Doing so and leaving out the -constants terms that do not depend on \( \beta \), we have -

    +

    In Bayes' theorem this function plays the role of the so-called likelihood. We could now ask the question what is the posterior probability of a parameter set \( \boldsymbol{\beta} \) given a domain of events \( \boldsymbol{D} \)? That is, how can we define the posterior probability

    $$ -C(\boldsymbol{\beta})=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\frac{1}{2\tau^2}\vert\vert\boldsymbol{\beta}\vert\vert_2^2, +p(\boldsymbol{\beta}\vert\boldsymbol{D}). $$ -

    and replacing \( 1/2\tau^2 \) with \( \lambda \) we have

    - +

    Bayes' theorem comes to our rescue here since (omitting the normalization constant)

    $$ -C(\boldsymbol{\beta})=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_2^2, +p(\boldsymbol{\beta}\vert\boldsymbol{D})\propto p(\boldsymbol{D}\vert\boldsymbol{\beta})p(\boldsymbol{\beta}). $$ -

    which is our Ridge cost function! Nice, isn't it?

    +

    We have a model for \( p(\boldsymbol{D}\vert\boldsymbol{\beta}) \) but need one for the prior \( p(\boldsymbol{\beta} \)!

    @@ -346,7 +342,7 @@ $$

  • 28
  • 29
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs020.html b/doc/pub/week37/html/._week37-bs020.html index 7dca1a806..22175cf12 100644 --- a/doc/pub/week37/html/._week37-bs020.html +++ b/doc/pub/week37/html/._week37-bs020.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,35 +290,41 @@ MathJax.Hub.Config({

     

     

     

    -

    Lasso and Bayes

    +

    Ridge and Bayes

    -

    To derive the Lasso cost function, we simply replace the Gaussian prior with an exponential distribution (Laplace in this case) with zero mean value, that is

    +

    With the posterior probability defined by a likelihood which we have +already modeled and an unknown prior, we are now ready to make +additional models for the prior. +

    + +

    We can, based on our discussions of the variance of \( \boldsymbol{\beta} \) and the mean value, assume that the prior for the values \( \boldsymbol{\beta} \) is given by a Gaussian with mean value zero and variance \( \tau^2 \), that is

    $$ -p(\boldsymbol{\beta})=\prod_{j=0}^{p-1}\exp{\left(-\frac{\vert\beta_j\vert}{\tau}\right)}. +p(\boldsymbol{\beta})=\prod_{j=0}^{p-1}\exp{\left(-\frac{\beta_j^2}{2\tau^2}\right)}. $$

    Our posterior probability becomes then (omitting the normalization factor which is just a constant)

    $$ -p(\boldsymbol{\beta}\vert\boldsymbol{D})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}\prod_{j=0}^{p-1}\exp{\left(-\frac{\vert\beta_j\vert}{\tau}\right)}. +p(\boldsymbol{\beta\vert\boldsymbol{D})}=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}\prod_{j=0}^{p-1}\exp{\left(-\frac{\beta_j^2}{2\tau^2}\right)}. $$ -

    Taking the negative -logarithm of the posterior probability and leaving out the +

    We can now optimize this quantity with respect to \( \boldsymbol{\beta} \). As we +did for OLS, this is most conveniently done by taking the negative +logarithm of the posterior probability. Doing so and leaving out the constants terms that do not depend on \( \beta \), we have

    $$ -C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\frac{1}{\tau}\vert\vert\boldsymbol{\beta}\vert\vert_1, +C(\boldsymbol{\beta})=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\frac{1}{2\tau^2}\vert\vert\boldsymbol{\beta}\vert\vert_2^2, $$ -

    and replacing \( 1/\tau \) with \( \lambda \) we have

    +

    and replacing \( 1/2\tau^2 \) with \( \lambda \) we have

    $$ -C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1, +C(\boldsymbol{\beta})=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_2^2, $$ -

    which is our Lasso cost function!

    +

    which is our Ridge cost function! Nice, isn't it?

    @@ -340,7 +351,7 @@ $$

  • 29
  • 30
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs021.html b/doc/pub/week37/html/._week37-bs021.html index 31f63d24b..7dc25c318 100644 --- a/doc/pub/week37/html/._week37-bs021.html +++ b/doc/pub/week37/html/._week37-bs021.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,103 +290,35 @@ MathJax.Hub.Config({

     

     

     

    -

    Test Function for what happens with OLS, Ridge and Lasso

    +

    Lasso and Bayes

    -

    We will play around with a study of the values for the optimal -parameters \( \boldsymbol{\beta} \) using OLS, Ridge and Lasso regression. For -OLS, you will notice as function of the noise and polynomial degree, -that the parameters \( \beta \) will fluctuate from order to order in the -polynomial fit and that for larger and larger polynomial degrees of freedom, the parameters will tend to increase in value for OLS. +

    To derive the Lasso cost function, we simply replace the Gaussian prior with an exponential distribution (Laplace in this case) with zero mean value, that is

    + +$$ +p(\boldsymbol{\beta})=\prod_{j=0}^{p-1}\exp{\left(-\frac{\vert\beta_j\vert}{\tau}\right)}. +$$ + +

    Our posterior probability becomes then (omitting the normalization factor which is just a constant)

    +$$ +p(\boldsymbol{\beta}\vert\boldsymbol{D})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\boldsymbol{X}_{i,*}\boldsymbol{\beta})^2}{2\sigma^2}\right]}\prod_{j=0}^{p-1}\exp{\left(-\frac{\vert\beta_j\vert}{\tau}\right)}. +$$ + +

    Taking the negative +logarithm of the posterior probability and leaving out the +constants terms that do not depend on \( \beta \), we have

    -

    For Ridge and Lasso regression, the higher order parameters will typically be reduced, providing thereby less fluctuations from one order to another one.

    +$$ +C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\frac{1}{\tau}\vert\vert\boldsymbol{\beta}\vert\vert_1, +$$ +

    and replacing \( 1/\tau \) with \( \lambda \) we have

    - -
    -
    -
    -
    -
    -
    import numpy as np
    -import matplotlib.pyplot as plt
    -from sklearn.model_selection import train_test_split
    -from sklearn import linear_model
    +$$
    +C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
    +$$
     
    -def R2(y_data, y_model):
    -    return 1 - np.sum((y_data - y_model) ** 2) / np.sum((y_data - np.mean(y_data)) ** 2)
    -def MSE(y_data,y_model):
    -    n = np.size(y_model)
    -    return np.sum((y_data-y_model)**2)/n
    -
    -# Make data set.
    -n = 10000
    -x = np.random.rand(n)
    -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.randn(n)
    -
    -Maxpolydegree = 5
    -X = np.zeros((len(x),Maxpolydegree))
    -X[:,0] = 1.0
    -
    -for polydegree in range(1, Maxpolydegree+1):
    -    for degree in range(polydegree):
    -        X[:,degree] = x**(degree)
    -
    -
    -# We split the data in test and training data
    -X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
    -
    -# matrix inversion to find beta
    -OLSbeta = np.linalg.pinv(X_train.T @ X_train) @ X_train.T @ y_train
    -print(OLSbeta)
    -ypredictOLS = X_test @ OLSbeta
    -print("Test MSE OLS")
    -print(MSE(y_test,ypredictOLS))
    -# Repeat now for Lasso and Ridge regression and various values of the regularization parameter using Scikit-Learn
    -# Decide which values of lambda to use
    -nlambdas = 4
    -MSERidgePredict = np.zeros(nlambdas)
    -MSELassoPredict = np.zeros(nlambdas)
    -lambdas = np.logspace(-3, 1, nlambdas)
    -for i in range(nlambdas):
    -    lmb = lambdas[i]
    -    # Make the fit using Ridge and Lasso
    -    RegRidge = linear_model.Ridge(lmb,fit_intercept=False)
    -    RegRidge.fit(X_train,y_train)
    -    RegLasso = linear_model.Lasso(lmb,fit_intercept=False)
    -    RegLasso.fit(X_train,y_train)
    -    # and then make the prediction
    -    ypredictRidge = RegRidge.predict(X_test)
    -    ypredictLasso = RegLasso.predict(X_test)
    -    # Compute the MSE and print it
    -    MSERidgePredict[i] = MSE(y_test,ypredictRidge)
    -    MSELassoPredict[i] = MSE(y_test,ypredictLasso)
    -    print(lmb,RegRidge.coef_)
    -    print(lmb,RegLasso.coef_)
    -# Now plot the results
    -plt.figure()
    -plt.plot(np.log10(lambdas), MSERidgePredict, 'b', label = 'MSE Ridge Test')
    -plt.plot(np.log10(lambdas), MSELassoPredict, 'r', label = 'MSE Lasso Test')
    -plt.xlabel('log10(lambda)')
    -plt.ylabel('MSE')
    -plt.legend()
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -

    How can we understand this?

    +

    which is our Lasso cost function!

    @@ -408,7 +345,7 @@ plt.show()

  • 30
  • 31
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs022.html b/doc/pub/week37/html/._week37-bs022.html index 1e7462c1c..d1121de7c 100644 --- a/doc/pub/week37/html/._week37-bs022.html +++ b/doc/pub/week37/html/._week37-bs022.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,29 +290,16 @@ MathJax.Hub.Config({

     

     

     

    -

    Rerunning the above code

    +

    Test Function for what happens with OLS, Ridge and Lasso

    -

    Let us write out the values of the coefficients \( \beta_i \) as functions -of the polynomial degree and noise. We will focus only on the Ridge -results and some few selected values of the hyperparameter \( \lambda \). +

    We will play around with a study of the values for the optimal +parameters \( \boldsymbol{\beta} \) using OLS, Ridge and Lasso regression. For +OLS, you will notice as function of the noise and polynomial degree, +that the parameters \( \beta \) will fluctuate from order to order in the +polynomial fit and that for larger and larger polynomial degrees of freedom, the parameters will tend to increase in value for OLS.

    -

    If we don't include any noise and run this code for different values -of the polynomial degree, we notice that the results for \( \beta_i \) do -not show great changes from one order to the next. This is an -indication that for higher polynomial orders, our parameters become -less important. -

    - -

    If we however add noise, what happens is that the polynomial fit is -trying to adjust the fit to traverse in the best possible way all data -points. This can lead to large fluctuations in the parameters -\( \beta_i \) as functions of polynomial order. It will also be reflected -in a larger value of the variance of each parameter \( \beta_i \). What -Ridge regression (and Lasso as well) are doing then is to try to -quench the fluctuations in the parameters of \( \beta_i \) which have a -large variance (normally for higher orders in the polynomial). -

    +

    For Ridge and Lasso regression, the higher order parameters will typically be reduced, providing thereby less fluctuations from one order to another one.

    @@ -317,14 +309,18 @@ large variance (normally for higher orders in the polynomial).
    import numpy as np
    -import pandas as pd
    -from IPython.display import display
     import matplotlib.pyplot as plt
     from sklearn.model_selection import train_test_split
     from sklearn import linear_model
     
    +def R2(y_data, y_model):
    +    return 1 - np.sum((y_data - y_model) ** 2) / np.sum((y_data - np.mean(y_data)) ** 2)
    +def MSE(y_data,y_model):
    +    n = np.size(y_model)
    +    return np.sum((y_data-y_model)**2)/n
    +
     # Make data set.
    -n = 1000
    +n = 10000
     x = np.random.rand(n)
     y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.randn(n)
     
    @@ -340,20 +336,41 @@ X[:,0] =
     # We split the data in test and training data
     X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
     
    +# matrix inversion to find beta
    +OLSbeta = np.linalg.pinv(X_train.T @ X_train) @ X_train.T @ y_train
    +print(OLSbeta)
    +ypredictOLS = X_test @ OLSbeta
    +print("Test MSE OLS")
    +print(MSE(y_test,ypredictOLS))
    +# Repeat now for Lasso and Ridge regression and various values of the regularization parameter using Scikit-Learn
     # Decide which values of lambda to use
    -nlambdas = 5
    -lambdas = np.logspace(-3, 2, nlambdas)
    +nlambdas = 4
    +MSERidgePredict = np.zeros(nlambdas)
    +MSELassoPredict = np.zeros(nlambdas)
    +lambdas = np.logspace(-3, 1, nlambdas)
     for i in range(nlambdas):
         lmb = lambdas[i]
    -    # Make the fit using Ridge only
    +    # Make the fit using Ridge and Lasso
         RegRidge = linear_model.Ridge(lmb,fit_intercept=False)
         RegRidge.fit(X_train,y_train)
    +    RegLasso = linear_model.Lasso(lmb,fit_intercept=False)
    +    RegLasso.fit(X_train,y_train)
         # and then make the prediction
         ypredictRidge = RegRidge.predict(X_test)
    -    Coeffs = np.array(RegRidge.coef_)
    -    BetaValues = pd.DataFrame(Coeffs)
    -    BetaValues.columns = ['beta']
    -    display(BetaValues)    
    +    ypredictLasso = RegLasso.predict(X_test)
    +    # Compute the MSE and print it
    +    MSERidgePredict[i] = MSE(y_test,ypredictRidge)
    +    MSELassoPredict[i] = MSE(y_test,ypredictLasso)
    +    print(lmb,RegRidge.coef_)
    +    print(lmb,RegLasso.coef_)
    +# Now plot the results
    +plt.figure()
    +plt.plot(np.log10(lambdas), MSERidgePredict, 'b', label = 'MSE Ridge Test')
    +plt.plot(np.log10(lambdas), MSELassoPredict, 'r', label = 'MSE Lasso Test')
    +plt.xlabel('log10(lambda)')
    +plt.ylabel('MSE')
    +plt.legend()
    +plt.show()
     
    @@ -369,6 +386,7 @@ lambdas = np.
    +

    How can we understand this?

    @@ -395,7 +413,7 @@ lambdas = np.31

  • 32
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs023.html b/doc/pub/week37/html/._week37-bs023.html index 9314c5ae3..620398a84 100644 --- a/doc/pub/week37/html/._week37-bs023.html +++ b/doc/pub/week37/html/._week37-bs023.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,17 +290,90 @@ MathJax.Hub.Config({

     

     

     

    -

    Why resampling methods

    +

    Rerunning the above code

    -

    Before we proceed, we need to rethink what we have been doing. In our -eager to fit the data, we have omitted several important elements in -our regression analysis. In what follows we will +

    Let us write out the values of the coefficients \( \beta_i \) as functions +of the polynomial degree and noise. We will focus only on the Ridge +results and some few selected values of the hyperparameter \( \lambda \).

    -
      -
    1. look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff
    2. -
    3. introduce resampling techniques like cross-validation, bootstrapping and jackknife and more
    4. -
    -

    and discuss how to select a given model (one of the difficult parts in machine learning).

    + +

    If we don't include any noise and run this code for different values +of the polynomial degree, we notice that the results for \( \beta_i \) do +not show great changes from one order to the next. This is an +indication that for higher polynomial orders, our parameters become +less important. +

    + +

    If we however add noise, what happens is that the polynomial fit is +trying to adjust the fit to traverse in the best possible way all data +points. This can lead to large fluctuations in the parameters +\( \beta_i \) as functions of polynomial order. It will also be reflected +in a larger value of the variance of each parameter \( \beta_i \). What +Ridge regression (and Lasso as well) are doing then is to try to +quench the fluctuations in the parameters of \( \beta_i \) which have a +large variance (normally for higher orders in the polynomial). +

    + + + +
    +
    +
    +
    +
    +
    import numpy as np
    +import pandas as pd
    +from IPython.display import display
    +import matplotlib.pyplot as plt
    +from sklearn.model_selection import train_test_split
    +from sklearn import linear_model
    +
    +# Make data set.
    +n = 1000
    +x = np.random.rand(n)
    +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.randn(n)
    +
    +Maxpolydegree = 5
    +X = np.zeros((len(x),Maxpolydegree))
    +X[:,0] = 1.0
    +
    +for polydegree in range(1, Maxpolydegree+1):
    +    for degree in range(polydegree):
    +        X[:,degree] = x**(degree)
    +
    +
    +# We split the data in test and training data
    +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
    +
    +# Decide which values of lambda to use
    +nlambdas = 5
    +lambdas = np.logspace(-3, 2, nlambdas)
    +for i in range(nlambdas):
    +    lmb = lambdas[i]
    +    # Make the fit using Ridge only
    +    RegRidge = linear_model.Ridge(lmb,fit_intercept=False)
    +    RegRidge.fit(X_train,y_train)
    +    # and then make the prediction
    +    ypredictRidge = RegRidge.predict(X_test)
    +    Coeffs = np.array(RegRidge.coef_)
    +    BetaValues = pd.DataFrame(Coeffs)
    +    BetaValues.columns = ['beta']
    +    display(BetaValues)    
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    @@ -322,7 +400,7 @@ our regression analysis. In what follows we will

  • 32
  • 33
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs024.html b/doc/pub/week37/html/._week37-bs024.html index 8d0a4c2e2..9568674fe 100644 --- a/doc/pub/week37/html/._week37-bs024.html +++ b/doc/pub/week37/html/._week37-bs024.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,33 +290,17 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods

    -
    -
    - -

    Resampling methods are an indispensable tool in modern -statistics. They involve repeatedly drawing samples from a training -set and refitting a model of interest on each sample in order to -obtain additional information about the fitted model. For example, in -order to estimate the variability of a linear regression fit, we can -repeatedly draw different samples from the training data, fit a linear -regression to each new sample, and then examine the extent to which -the resulting fits differ. Such an approach may allow us to obtain -information that would not be available from fitting the model only -once using the original training sample. -

    +

    Why resampling methods

    -

    Two resampling methods are often used in Machine Learning analyses,

    +

    Before we proceed, we need to rethink what we have been doing. In our +eager to fit the data, we have omitted several important elements in +our regression analysis. In what follows we will +

      -
    1. The bootstrap method
    2. -
    3. and Cross-Validation
    4. +
    5. look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff
    6. +
    7. introduce resampling techniques like cross-validation, bootstrapping and jackknife and more
    -

    In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular -cross-validation and the bootstrap method. -

    -
    -
    - +

    and discuss how to select a given model (one of the difficult parts in machine learning).

    @@ -338,7 +327,7 @@ cross-validation and the bootstrap method.

  • 33
  • 34
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs025.html b/doc/pub/week37/html/._week37-bs025.html index 27cb9c4e8..161d418c6 100644 --- a/doc/pub/week37/html/._week37-bs025.html +++ b/doc/pub/week37/html/._week37-bs025.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,26 +290,29 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling approaches can be computationally expensive

    +

    Resampling methods

    +

    Resampling methods are an indispensable tool in modern +statistics. They involve repeatedly drawing samples from a training +set and refitting a model of interest on each sample in order to +obtain additional information about the fitted model. For example, in +order to estimate the variability of a linear regression fit, we can +repeatedly draw different samples from the training data, fit a linear +regression to each new sample, and then examine the extent to which +the resulting fits differ. Such an approach may allow us to obtain +information that would not be available from fitting the model only +once using the original training sample. +

    -

    Resampling approaches can be computationally expensive, because they -involve fitting the same statistical method multiple times using -different subsets of the training data. However, due to recent -advances in computing power, the computational requirements of -resampling methods generally are not prohibitive. In this chapter, we -discuss two of the most commonly used resampling methods, -cross-validation and the bootstrap. Both methods are important tools -in the practical application of many statistical learning -procedures. For example, cross-validation can be used to estimate the -test error associated with a given statistical learning method in -order to evaluate its performance, or to select the appropriate level -of flexibility. The process of evaluating a model’s performance is -known as model assessment, whereas the process of selecting the proper -level of flexibility for a model is known as model selection. The -bootstrap is widely used. +

    Two resampling methods are often used in Machine Learning analyses,

    +
      +
    1. The bootstrap method
    2. +
    3. and Cross-Validation
    4. +
    +

    In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular +cross-validation and the bootstrap method.

    @@ -335,7 +343,7 @@ bootstrap is widely used.
  • 34
  • 35
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs026.html b/doc/pub/week37/html/._week37-bs026.html index dc18d1946..80ab4d82a 100644 --- a/doc/pub/week37/html/._week37-bs026.html +++ b/doc/pub/week37/html/._week37-bs026.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,19 +290,30 @@ MathJax.Hub.Config({

     

     

     

    -

    Why resampling methods ?

    +

    Resampling approaches can be computationally expensive

    -
      -
    • Our simulations can be treated as computer experiments. This is particularly the case for Monte Carlo methods which are widely used in statistical analyses.
    • -
    • The results can be analysed with the same statistical tools as we would use when analysing experimental data.
    • -
    • As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
    • -
    +

    Resampling approaches can be computationally expensive, because they +involve fitting the same statistical method multiple times using +different subsets of the training data. However, due to recent +advances in computing power, the computational requirements of +resampling methods generally are not prohibitive. In this chapter, we +discuss two of the most commonly used resampling methods, +cross-validation and the bootstrap. Both methods are important tools +in the practical application of many statistical learning +procedures. For example, cross-validation can be used to estimate the +test error associated with a given statistical learning method in +order to evaluate its performance, or to select the appropriate level +of flexibility. The process of evaluating a model’s performance is +known as model assessment, whereas the process of selecting the proper +level of flexibility for a model is known as model selection. The +bootstrap is widely used. +

    - +

    @@ -324,7 +340,7 @@ MathJax.Hub.Config({

  • 35
  • 36
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs027.html b/doc/pub/week37/html/._week37-bs027.html index f7546c059..95e539119 100644 --- a/doc/pub/week37/html/._week37-bs027.html +++ b/doc/pub/week37/html/._week37-bs027.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,19 +290,15 @@ MathJax.Hub.Config({

     

     

     

    -

    Statistical analysis

    +

    Why resampling methods ?

      -
    • As in other experiments, many numerical experiments have two classes of errors:
    • -
        -
      • Statistical errors
      • -
      • Systematical errors
      • -
      -
    • Statistical errors can be estimated using standard tools from statistics
    • -
    • Systematical errors are method specific and must be treated differently from case to case.
    • +
    • Our simulations can be treated as computer experiments. This is particularly the case for Monte Carlo methods which are widely used in statistical analyses.
    • +
    • The results can be analysed with the same statistical tools as we would use when analysing experimental data.
    • +
    • As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
    @@ -328,7 +329,7 @@ MathJax.Hub.Config({
  • 36
  • 37
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs028.html b/doc/pub/week37/html/._week37-bs028.html index afe7cb547..6770abaca 100644 --- a/doc/pub/week37/html/._week37-bs028.html +++ b/doc/pub/week37/html/._week37-bs028.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,30 +290,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods

    +

    Statistical analysis

    +
    +
    + -

    With all these analytical equations for both the OLS and Ridge -regression, we will now outline how to assess a given model. This will -lead to a discussion of the so-called bias-variance tradeoff (see -below) and so-called resampling methods. -

    - -

    One of the quantities we have discussed as a way to measure errors is -the mean-squared error (MSE), mainly used for fitting of continuous -functions. Another choice is the absolute error. -

    - -

    In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data, -we discuss the -

    -
      -
    1. prediction error or simply the test error \( \mathrm{Err_{Test}} \), where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the
    2. -
    3. training error \( \mathrm{Err_{Train}} \), which is the average loss over the training data.
    4. -
    -

    As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error. -For a certain level of complexity the test error will reach minimum, before starting to increase again. The -training error reaches a saturation. -

    +
      +
    • As in other experiments, many numerical experiments have two classes of errors:
    • +
        +
      • Statistical errors
      • +
      • Systematical errors
      • +
      +
    • Statistical errors can be estimated using standard tools from statistics
    • +
    • Systematical errors are method specific and must be treated differently from case to case.
    • +
    +
    +
    +

    @@ -335,7 +333,7 @@ training error reaches a saturation.

  • 37
  • 38
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs029.html b/doc/pub/week37/html/._week37-bs029.html index 709ca1376..a99d0ea26 100644 --- a/doc/pub/week37/html/._week37-bs029.html +++ b/doc/pub/week37/html/._week37-bs029.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,28 +290,30 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods: Bootstrap

    -
    -
    - -

    Bootstrapping is a non-parametric approach to statistical inference -that substitutes computation for more traditional distributional -assumptions and asymptotic results. Bootstrapping offers a number of -advantages: +

    Resampling methods

    + +

    With all these analytical equations for both the OLS and Ridge +regression, we will now outline how to assess a given model. This will +lead to a discussion of the so-called bias-variance tradeoff (see +below) and so-called resampling methods. +

    + +

    One of the quantities we have discussed as a way to measure errors is +the mean-squared error (MSE), mainly used for fitting of continuous +functions. Another choice is the absolute error. +

    + +

    In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data, +we discuss the

      -
    1. The bootstrap is quite general, although there are some cases in which it fails.
    2. -
    3. Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small.
    4. -
    5. It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically.
    6. -
    7. It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).
    8. +
    9. prediction error or simply the test error \( \mathrm{Err_{Test}} \), where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the
    10. +
    11. training error \( \mathrm{Err_{Train}} \), which is the average loss over the training data.
    -
    -
    - - -

    The textbook by Davison on the Bootstrap Methods and their Applications provides many more insights and proofs. In this course we will take a more practical approach and use the results and theorems provided in the literature. For those interested in reading more about the bootstrap methods, we recommend the above text and the one by Efron and Tibshirani.

    - -

    Before we proceed however, we need to remind ourselves about a central theorem in statistics, namely the so-called central limit theorem.

    +

    As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error. +For a certain level of complexity the test error will reach minimum, before starting to increase again. The +training error reaches a saturation. +

    @@ -333,7 +340,7 @@ advantages:

  • 38
  • 39
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs030.html b/doc/pub/week37/html/._week37-bs030.html index 1e5fbffc1..62f42e86b 100644 --- a/doc/pub/week37/html/._week37-bs030.html +++ b/doc/pub/week37/html/._week37-bs030.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,23 +290,28 @@ MathJax.Hub.Config({

     

     

     

    -

    The Central Limit Theorem

    - -

    Suppose we have a PDF \( p(x) \) from which we generate a series \( N \) -of averages \( \mathbb{E}[x_i] \). Each mean value \( \mathbb{E}[x_i] \) -is viewed as the average of a specific measurement, e.g., throwing -dice 100 times and then taking the average value, or producing a certain -amount of random numbers. -For notational ease, we set \( \mathbb{E}[x_i]=x_i \) in the discussion -which follows. We do the same for \( \mathbb{E}[z]=z \). +

    Resampling methods: Bootstrap

    +
    +
    + +

    Bootstrapping is a non-parametric approach to statistical inference +that substitutes computation for more traditional distributional +assumptions and asymptotic results. Bootstrapping offers a number of +advantages:

    +
      +
    1. The bootstrap is quite general, although there are some cases in which it fails.
    2. +
    3. Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small.
    4. +
    5. It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically.
    6. +
    7. It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).
    8. +
    +
    +
    -

    If we compute the mean \( z \) of \( m \) such mean values \( x_i \)

    -$$ - z=\frac{x_1+x_2+\dots+x_m}{m}, -$$ -

    the question we pose is which is the PDF of the new variable \( z \).

    +

    The textbook by Davison on the Bootstrap Methods and their Applications provides many more insights and proofs. In this course we will take a more practical approach and use the results and theorems provided in the literature. For those interested in reading more about the bootstrap methods, we recommend the above text and the one by Efron and Tibshirani.

    + +

    Before we proceed however, we need to remind ourselves about a central theorem in statistics, namely the so-called central limit theorem.

    @@ -328,7 +338,7 @@ $$

  • 39
  • 40
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs031.html b/doc/pub/week37/html/._week37-bs031.html index d1d61284e..a1fbbe2f2 100644 --- a/doc/pub/week37/html/._week37-bs031.html +++ b/doc/pub/week37/html/._week37-bs031.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,23 +290,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Finding the Limit

    +

    The Central Limit Theorem

    -

    The probability of obtaining an average value \( z \) is the product of the -probabilities of obtaining arbitrary individual mean values \( x_i \), -but with the constraint that the average is \( z \). We can express this through -the following expression +

    Suppose we have a PDF \( p(x) \) from which we generate a series \( N \) +of averages \( \mathbb{E}[x_i] \). Each mean value \( \mathbb{E}[x_i] \) +is viewed as the average of a specific measurement, e.g., throwing +dice 100 times and then taking the average value, or producing a certain +amount of random numbers. +For notational ease, we set \( \mathbb{E}[x_i]=x_i \) in the discussion +which follows. We do the same for \( \mathbb{E}[z]=z \).

    + +

    If we compute the mean \( z \) of \( m \) such mean values \( x_i \)

    $$ - \tilde{p}(z)=\int dx_1p(x_1)\int dx_2p(x_2)\dots\int dx_mp(x_m) - \delta(z-\frac{x_1+x_2+\dots+x_m}{m}), + z=\frac{x_1+x_2+\dots+x_m}{m}, $$ -

    where the \( \delta \)-function enbodies the constraint that the mean is \( z \). -All measurements that lead to each individual \( x_i \) are expected to -be independent, which in turn means that we can express \( \tilde{p} \) as the -product of individual \( p(x_i) \). The independence assumption is important in the derivation of the central limit theorem. -

    +

    the question we pose is which is the PDF of the new variable \( z \).

    @@ -328,7 +333,7 @@ product of individual \( p(x_i) \). The independence assumption is important in

  • 40
  • 41
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs032.html b/doc/pub/week37/html/._week37-bs032.html index ac3c6124f..54aaf07bc 100644 --- a/doc/pub/week37/html/._week37-bs032.html +++ b/doc/pub/week37/html/._week37-bs032.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,32 +290,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Rewriting the \( \delta \)-function

    +

    Finding the Limit

    -

    If we use the integral expression for the \( \delta \)-function

    - -$$ - \delta(z-\frac{x_1+x_2+\dots+x_m}{m})=\frac{1}{2\pi}\int_{-\infty}^{\infty} - dq\exp{\left(iq(z-\frac{x_1+x_2+\dots+x_m}{m})\right)}, -$$ - -

    and inserting \( e^{i\mu q-i\mu q} \) where \( \mu \) is the mean value -we arrive at +

    The probability of obtaining an average value \( z \) is the product of the +probabilities of obtaining arbitrary individual mean values \( x_i \), +but with the constraint that the average is \( z \). We can express this through +the following expression

    $$ - \tilde{p}(z)=\frac{1}{2\pi}\int_{-\infty}^{\infty} - dq\exp{\left(iq(z-\mu)\right)}\left[\int_{-\infty}^{\infty} - dxp(x)\exp{\left(iq(\mu-x)/m\right)}\right]^m, -$$ - -

    with the integral over \( x \) resulting in

    - -$$ - \int_{-\infty}^{\infty}dxp(x)\exp{\left(iq(\mu-x)/m\right)}= - \int_{-\infty}^{\infty}dxp(x) - \left[1+\frac{iq(\mu-x)}{m}-\frac{q^2(\mu-x)^2}{2m^2}+\dots\right]. + \tilde{p}(z)=\int dx_1p(x_1)\int dx_2p(x_2)\dots\int dx_mp(x_m) + \delta(z-\frac{x_1+x_2+\dots+x_m}{m}), $$ +

    where the \( \delta \)-function enbodies the constraint that the mean is \( z \). +All measurements that lead to each individual \( x_i \) are expected to +be independent, which in turn means that we can express \( \tilde{p} \) as the +product of individual \( p(x_i) \). The independence assumption is important in the derivation of the central limit theorem. +

    @@ -337,7 +333,7 @@ $$

  • 41
  • 42
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs033.html b/doc/pub/week37/html/._week37-bs033.html index f6ed89a8e..6e543cd17 100644 --- a/doc/pub/week37/html/._week37-bs033.html +++ b/doc/pub/week37/html/._week37-bs033.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,34 +290,32 @@ MathJax.Hub.Config({

     

     

     

    -

    Identifying Terms

    +

    Rewriting the \( \delta \)-function

    -

    The second term on the rhs disappears since this is just the mean and -employing the definition of \( \sigma^2 \) we have +

    If we use the integral expression for the \( \delta \)-function

    + +$$ + \delta(z-\frac{x_1+x_2+\dots+x_m}{m})=\frac{1}{2\pi}\int_{-\infty}^{\infty} + dq\exp{\left(iq(z-\frac{x_1+x_2+\dots+x_m}{m})\right)}, +$$ + +

    and inserting \( e^{i\mu q-i\mu q} \) where \( \mu \) is the mean value +we arrive at

    $$ - \int_{-\infty}^{\infty}dxp(x)e^{\left(iq(\mu-x)/m\right)}= - 1-\frac{q^2\sigma^2}{2m^2}+\dots, + \tilde{p}(z)=\frac{1}{2\pi}\int_{-\infty}^{\infty} + dq\exp{\left(iq(z-\mu)\right)}\left[\int_{-\infty}^{\infty} + dxp(x)\exp{\left(iq(\mu-x)/m\right)}\right]^m, $$ -

    resulting in

    +

    with the integral over \( x \) resulting in

    $$ - \left[\int_{-\infty}^{\infty}dxp(x)\exp{\left(iq(\mu-x)/m\right)}\right]^m\approx - \left[1-\frac{q^2\sigma^2}{2m^2}+\dots \right]^m, + \int_{-\infty}^{\infty}dxp(x)\exp{\left(iq(\mu-x)/m\right)}= + \int_{-\infty}^{\infty}dxp(x) + \left[1+\frac{iq(\mu-x)}{m}-\frac{q^2(\mu-x)^2}{2m^2}+\dots\right]. $$ -

    and in the limit \( m\rightarrow \infty \) we obtain

    - -$$ - \tilde{p}(z)=\frac{1}{\sqrt{2\pi}(\sigma/\sqrt{m})} - \exp{\left(-\frac{(z-\mu)^2}{2(\sigma/\sqrt{m})^2}\right)}, -$$ - -

    which is the normal distribution with variance -\( \sigma^2_m=\sigma^2/m \), where \( \sigma \) is the variance of the PDF \( p(x) \) -and \( \mu \) is also the mean of the PDF \( p(x) \). -

    @@ -339,7 +342,7 @@ and \( \mu \) is also the mean of the PDF \( p(x) \).

  • 42
  • 43
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs034.html b/doc/pub/week37/html/._week37-bs034.html index 901ffc238..ff7a5fe3f 100644 --- a/doc/pub/week37/html/._week37-bs034.html +++ b/doc/pub/week37/html/._week37-bs034.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,45 +290,33 @@ MathJax.Hub.Config({

     

     

     

    -

    Wrapping it up

    +

    Identifying Terms

    -

    Thus, the central limit theorem states that the PDF \( \tilde{p}(z) \) of -the average of \( m \) random values corresponding to a PDF \( p(x) \) -is a normal distribution whose mean is the -mean value of the PDF \( p(x) \) and whose variance is the variance -of the PDF \( p(x) \) divided by \( m \), the number of values used to compute \( z \). -

    - -

    The central limit theorem leads to the well-known expression for the -standard deviation, given by -

    - -$$ - \sigma_m= -\frac{\sigma}{\sqrt{m}}. -$$ - -

    The latter is true only if the average value is known exactly. This is obtained in the limit -\( m\rightarrow \infty \) only. Because the mean and the variance are measured quantities we obtain -the familiar expression in statistics (the so-called Bessel correction) +

    The second term on the rhs disappears since this is just the mean and +employing the definition of \( \sigma^2 \) we have

    $$ - \sigma_m\approx -\frac{\sigma}{\sqrt{m-1}}. + \int_{-\infty}^{\infty}dxp(x)e^{\left(iq(\mu-x)/m\right)}= + 1-\frac{q^2\sigma^2}{2m^2}+\dots, $$ -

    In many cases however the above estimate for the standard deviation, -in particular if correlations are strong, may be too simplistic. Keep -in mind that we have assumed that the variables \( x \) are independent -and identically distributed. This is obviously not always the -case. For example, the random numbers (or better pseudorandom numbers) -we generate in various calculations do always exhibit some -correlations. -

    +

    resulting in

    -

    The theorem is satisfied by a large class of PDFs. Note however that for a -finite \( m \), it is not always possible to find a closed form /analytic expression for -\( \tilde{p}(x) \). +$$ + \left[\int_{-\infty}^{\infty}dxp(x)\exp{\left(iq(\mu-x)/m\right)}\right]^m\approx + \left[1-\frac{q^2\sigma^2}{2m^2}+\dots \right]^m, +$$ + +

    and in the limit \( m\rightarrow \infty \) we obtain

    + +$$ + \tilde{p}(z)=\frac{1}{\sqrt{2\pi}(\sigma/\sqrt{m})} + \exp{\left(-\frac{(z-\mu)^2}{2(\sigma/\sqrt{m})^2}\right)}, +$$ + +

    which is the normal distribution with variance +\( \sigma^2_m=\sigma^2/m \), where \( \sigma \) is the variance of the PDF \( p(x) \) +and \( \mu \) is also the mean of the PDF \( p(x) \).

    @@ -351,7 +344,7 @@ finite \( m \), it is not always possible to find a closed form /analytic expres

  • 43
  • 44
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs035.html b/doc/pub/week37/html/._week37-bs035.html index 5d58e9815..2c3c7ace0 100644 --- a/doc/pub/week37/html/._week37-bs035.html +++ b/doc/pub/week37/html/._week37-bs035.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,23 +290,45 @@ MathJax.Hub.Config({

     

     

     

    -

    Confidence Intervals

    +

    Wrapping it up

    -

    Confidence intervals are used in statistics and represent a type of estimate -computed from the observed data. This gives a range of values for an -unknown parameter such as the parameters \( \boldsymbol{\beta} \) from linear regression. +

    Thus, the central limit theorem states that the PDF \( \tilde{p}(z) \) of +the average of \( m \) random values corresponding to a PDF \( p(x) \) +is a normal distribution whose mean is the +mean value of the PDF \( p(x) \) and whose variance is the variance +of the PDF \( p(x) \) divided by \( m \), the number of values used to compute \( z \).

    -

    With the OLS expressions for the parameters \( \boldsymbol{\beta} \) we found -\( \mathbb{E}(\boldsymbol{\beta}) = \boldsymbol{\beta} \), which means that the estimator of the regression parameters is unbiased. +

    The central limit theorem leads to the well-known expression for the +standard deviation, given by

    -

    We found also that the variance of the estimate of the \( j \)-th regression coefficient is -\( \boldsymbol{\sigma}^2 (\boldsymbol{\beta}_j ) = \boldsymbol{\sigma}^2 [(\mathbf{X}^{T} \mathbf{X})^{-1}]_{jj} \). +$$ + \sigma_m= +\frac{\sigma}{\sqrt{m}}. +$$ + +

    The latter is true only if the average value is known exactly. This is obtained in the limit +\( m\rightarrow \infty \) only. Because the mean and the variance are measured quantities we obtain +the familiar expression in statistics (the so-called Bessel correction) +

    +$$ + \sigma_m\approx +\frac{\sigma}{\sqrt{m-1}}. +$$ + +

    In many cases however the above estimate for the standard deviation, +in particular if correlations are strong, may be too simplistic. Keep +in mind that we have assumed that the variables \( x \) are independent +and identically distributed. This is obviously not always the +case. For example, the random numbers (or better pseudorandom numbers) +we generate in various calculations do always exhibit some +correlations.

    -

    This quantity will be used to -construct a confidence interval for the estimates. +

    The theorem is satisfied by a large class of PDFs. Note however that for a +finite \( m \), it is not always possible to find a closed form /analytic expression for +\( \tilde{p}(x) \).

    @@ -329,7 +356,7 @@ construct a confidence interval for the estimates.

  • 44
  • 45
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs036.html b/doc/pub/week37/html/._week37-bs036.html index 44a8cc82f..5bcea59eb 100644 --- a/doc/pub/week37/html/._week37-bs036.html +++ b/doc/pub/week37/html/._week37-bs036.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,30 +290,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Standard Approach based on the Normal Distribution

    +

    Confidence Intervals

    -

    We will assume that the parameters \( \beta \) follow a normal -distribution. We can then define the confidence interval. Here we will be using as -shorthands \( \mu_{\beta} \) for the above mean value and \( \sigma_{\beta} \) -for the standard deviation. We have then a confidence interval +

    Confidence intervals are used in statistics and represent a type of estimate +computed from the observed data. This gives a range of values for an +unknown parameter such as the parameters \( \boldsymbol{\beta} \) from linear regression.

    -$$ -\left(\mu_{\beta}\pm \frac{z\sigma_{\beta}}{\sqrt{n}}\right), -$$ - -

    where \( z \) defines the level of certainty (or confidence). For a normal -distribution typical parameters are \( z=2.576 \) which corresponds to a -confidence of \( 99\% \) while \( z=1.96 \) corresponds to a confidence of -\( 95\% \). A confidence level of \( 95\% \) is commonly used and it is -normally referred to as a two-sigmas confidence level, that is we -approximate \( z\approx 2 \). +

    With the OLS expressions for the parameters \( \boldsymbol{\beta} \) we found +\( \mathbb{E}(\boldsymbol{\beta}) = \boldsymbol{\beta} \), which means that the estimator of the regression parameters is unbiased.

    -

    For more discussions of confidence intervals (and in particular linked with a discussion of the bootstrap method), see chapter 5 of the textbook by Davison on the Bootstrap Methods and their Applications

    +

    We found also that the variance of the estimate of the \( j \)-th regression coefficient is +\( \boldsymbol{\sigma}^2 (\boldsymbol{\beta}_j ) = \boldsymbol{\sigma}^2 [(\mathbf{X}^{T} \mathbf{X})^{-1}]_{jj} \). +

    -

    In this text you will also find an in-depth discussion of the -Bootstrap method, why it works and various theorems related to it. +

    This quantity will be used to +construct a confidence interval for the estimates.

    @@ -336,7 +334,7 @@ Bootstrap method, why it works and various theorems related to it.

  • 45
  • 46
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs037.html b/doc/pub/week37/html/._week37-bs037.html index 1006e05c2..f7b4bbb81 100644 --- a/doc/pub/week37/html/._week37-bs037.html +++ b/doc/pub/week37/html/._week37-bs037.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,17 +290,30 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods: Bootstrap background

    +

    Standard Approach based on the Normal Distribution

    -

    Since \( \widehat{\beta} = \widehat{\beta}(\boldsymbol{X}) \) is a function of random variables, -\( \widehat{\beta} \) itself must be a random variable. Thus it has -a pdf, call this function \( p(\boldsymbol{t}) \). The aim of the bootstrap is to -estimate \( p(\boldsymbol{t}) \) by the relative frequency of -\( \widehat{\beta} \). You can think of this as using a histogram -in the place of \( p(\boldsymbol{t}) \). If the relative frequency closely -resembles \( p(\vec{t}) \), then using numerics, it is straight forward to -estimate all the interesting parameters of \( p(\boldsymbol{t}) \) using point -estimators. +

    We will assume that the parameters \( \beta \) follow a normal +distribution. We can then define the confidence interval. Here we will be using as +shorthands \( \mu_{\beta} \) for the above mean value and \( \sigma_{\beta} \) +for the standard deviation. We have then a confidence interval +

    + +$$ +\left(\mu_{\beta}\pm \frac{z\sigma_{\beta}}{\sqrt{n}}\right), +$$ + +

    where \( z \) defines the level of certainty (or confidence). For a normal +distribution typical parameters are \( z=2.576 \) which corresponds to a +confidence of \( 99\% \) while \( z=1.96 \) corresponds to a confidence of +\( 95\% \). A confidence level of \( 95\% \) is commonly used and it is +normally referred to as a two-sigmas confidence level, that is we +approximate \( z\approx 2 \). +

    + +

    For more discussions of confidence intervals (and in particular linked with a discussion of the bootstrap method), see chapter 5 of the textbook by Davison on the Bootstrap Methods and their Applications

    + +

    In this text you will also find an in-depth discussion of the +Bootstrap method, why it works and various theorems related to it.

    @@ -323,7 +341,7 @@ estimators.

  • 46
  • 47
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs038.html b/doc/pub/week37/html/._week37-bs038.html index 7c0edd416..db96c74d2 100644 --- a/doc/pub/week37/html/._week37-bs038.html +++ b/doc/pub/week37/html/._week37-bs038.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,22 +290,17 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods: More Bootstrap background

    +

    Resampling methods: Bootstrap background

    -

    In the case that \( \widehat{\beta} \) has -more than one component, and the components are independent, we use the -same estimator on each component separately. If the probability -density function of \( X_i \), \( p(x) \), had been known, then it would have -been straightforward to do this by: -

    -
      -
    1. Drawing lots of numbers from \( p(x) \), suppose we call one such set of numbers \( (X_1^*, X_2^*, \cdots, X_n^*) \).
    2. -
    3. Then using these numbers, we could compute a replica of \( \widehat{\beta} \) called \( \widehat{\beta}^* \).
    4. -
    -

    By repeated use of the above two points, many -estimates of \( \widehat{\beta} \) can be obtained. The -idea is to use the relative frequency of \( \widehat{\beta}^* \) -(think of a histogram) as an estimate of \( p(\boldsymbol{t}) \). +

    Since \( \widehat{\beta} = \widehat{\beta}(\boldsymbol{X}) \) is a function of random variables, +\( \widehat{\beta} \) itself must be a random variable. Thus it has +a pdf, call this function \( p(\boldsymbol{t}) \). The aim of the bootstrap is to +estimate \( p(\boldsymbol{t}) \) by the relative frequency of +\( \widehat{\beta} \). You can think of this as using a histogram +in the place of \( p(\boldsymbol{t}) \). If the relative frequency closely +resembles \( p(\vec{t}) \), then using numerics, it is straight forward to +estimate all the interesting parameters of \( p(\boldsymbol{t}) \) using point +estimators.

    @@ -328,7 +328,7 @@ idea is to use the relative frequency of \( \widehat{\beta}^* \)

  • 47
  • 48
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs039.html b/doc/pub/week37/html/._week37-bs039.html index 9df4ea007..f50f6d326 100644 --- a/doc/pub/week37/html/._week37-bs039.html +++ b/doc/pub/week37/html/._week37-bs039.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,19 +290,22 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods: Bootstrap approach

    +

    Resampling methods: More Bootstrap background

    -

    But -unless there is enough information available about the process that -generated \( X_1,X_2,\cdots,X_n \), \( p(x) \) is in general -unknown. Therefore, Efron in 1979 asked the -question: What if we replace \( p(x) \) by the relative frequency -of the observation \( X_i \)? +

    In the case that \( \widehat{\beta} \) has +more than one component, and the components are independent, we use the +same estimator on each component separately. If the probability +density function of \( X_i \), \( p(x) \), had been known, then it would have +been straightforward to do this by:

    - -

    If we draw observations in accordance with -the relative frequency of the observations, will we obtain the same -result in some asymptotic sense? The answer is yes. +

      +
    1. Drawing lots of numbers from \( p(x) \), suppose we call one such set of numbers \( (X_1^*, X_2^*, \cdots, X_n^*) \).
    2. +
    3. Then using these numbers, we could compute a replica of \( \widehat{\beta} \) called \( \widehat{\beta}^* \).
    4. +
    +

    By repeated use of the above two points, many +estimates of \( \widehat{\beta} \) can be obtained. The +idea is to use the relative frequency of \( \widehat{\beta}^* \) +(think of a histogram) as an estimate of \( p(\boldsymbol{t}) \).

    @@ -325,7 +333,7 @@ result in some asymptotic sense? The answer is yes.

  • 48
  • 49
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs040.html b/doc/pub/week37/html/._week37-bs040.html index c1adc6b8d..45ca12c28 100644 --- a/doc/pub/week37/html/._week37-bs040.html +++ b/doc/pub/week37/html/._week37-bs040.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,25 +290,19 @@ MathJax.Hub.Config({

     

     

     

    -

    Resampling methods: Bootstrap steps

    +

    Resampling methods: Bootstrap approach

    -

    The independent bootstrap works like this:

    +

    But +unless there is enough information available about the process that +generated \( X_1,X_2,\cdots,X_n \), \( p(x) \) is in general +unknown. Therefore, Efron in 1979 asked the +question: What if we replace \( p(x) \) by the relative frequency +of the observation \( X_i \)? +

    -
      -
    1. Draw with replacement \( n \) numbers for the observed variables \( \boldsymbol{x} = (x_1,x_2,\cdots,x_n) \).
    2. -
    3. Define a vector \( \boldsymbol{x}^* \) containing the values which were drawn from \( \boldsymbol{x} \).
    4. -
    5. Using the vector \( \boldsymbol{x}^* \) compute \( \widehat{\beta}^* \) by evaluating \( \widehat \beta \) under the observations \( \boldsymbol{x}^* \).
    6. -
    7. Repeat this process \( k \) times.
    8. -
    -

    When you are done, you can draw a histogram of the relative frequency -of \( \widehat \beta^* \). This is your estimate of the probability -distribution \( p(t) \). Using this probability distribution you can -estimate any statistics thereof. In principle you never draw the -histogram of the relative frequency of \( \widehat{\beta}^* \). Instead -you use the estimators corresponding to the statistic of interest. For -example, if you are interested in estimating the variance of \( \widehat -\beta \), apply the etsimator \( \widehat \sigma^2 \) to the values -\( \widehat \beta^* \). +

    If we draw observations in accordance with +the relative frequency of the observations, will we obtain the same +result in some asymptotic sense? The answer is yes.

    @@ -331,7 +330,7 @@ example, if you are interested in estimating the variance of \( \widehat

  • 49
  • 50
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs041.html b/doc/pub/week37/html/._week37-bs041.html index 6e34f7ada..e645b7948 100644 --- a/doc/pub/week37/html/._week37-bs041.html +++ b/doc/pub/week37/html/._week37-bs041.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,72 +290,27 @@ MathJax.Hub.Config({

     

     

     

    -

    Code example for the Bootstrap method

    +

    Resampling methods: Bootstrap steps

    -

    The following code starts with a Gaussian distribution with mean value -\( \mu =100 \) and variance \( \sigma=15 \). We use this to generate the data -used in the bootstrap analysis. The bootstrap analysis returns a data -set after a given number of bootstrap operations (as many as we have -data points). This data set consists of estimated mean values for each -bootstrap operation. The histogram generated by the bootstrap method -shows that the distribution for these mean values is also a Gaussian, -centered around the mean value \( \mu=100 \) but with standard deviation -\( \sigma/\sqrt{n} \), where \( n \) is the number of bootstrap samples (in -this case the same as the number of original data points). The value -of the standard deviation is what we expect from the central limit -theorem. +

    The independent bootstrap works like this:

    + +
      +
    1. Draw with replacement \( n \) numbers for the observed variables \( \boldsymbol{x} = (x_1,x_2,\cdots,x_n) \).
    2. +
    3. Define a vector \( \boldsymbol{x}^* \) containing the values which were drawn from \( \boldsymbol{x} \).
    4. +
    5. Using the vector \( \boldsymbol{x}^* \) compute \( \widehat{\beta}^* \) by evaluating \( \widehat \beta \) under the observations \( \boldsymbol{x}^* \).
    6. +
    7. Repeat this process \( k \) times.
    8. +
    +

    When you are done, you can draw a histogram of the relative frequency +of \( \widehat \beta^* \). This is your estimate of the probability +distribution \( p(t) \). Using this probability distribution you can +estimate any statistics thereof. In principle you never draw the +histogram of the relative frequency of \( \widehat{\beta}^* \). Instead +you use the estimators corresponding to the statistic of interest. For +example, if you are interested in estimating the variance of \( \widehat +\beta \), apply the etsimator \( \widehat \sigma^2 \) to the values +\( \widehat \beta^* \).

    - - -
    -
    -
    -
    -
    -
    import numpy as np
    -from time import time
    -from scipy.stats import norm
    -import matplotlib.pyplot as plt
    -
    -# Returns mean of bootstrap samples 
    -# Bootstrap algorithm
    -def bootstrap(data, datapoints):
    -    t = np.zeros(datapoints)
    -    n = len(data)
    -    # non-parametric bootstrap         
    -    for i in range(datapoints):
    -        t[i] = np.mean(data[np.random.randint(0,n,n)])
    -    # analysis    
    -    print("Bootstrap Statistics :")
    -    print("original           bias      std. error")
    -    print("%8g %8g %14g %15g" % (np.mean(data), np.std(data),np.mean(t),np.std(t)))
    -    return t
    -
    -# We set the mean value to 100 and the standard deviation to 15
    -mu, sigma = 100, 15
    -datapoints = 10000
    -# We generate random numbers according to the normal distribution
    -x = mu + sigma*np.random.randn(datapoints)
    -# bootstrap returns the data sample                                    
    -t = bootstrap(x, datapoints)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -

    We see that our new variance and from that the standard deviation, agrees with the central limit theorem.

    -

    diff --git a/doc/pub/week37/html/._week37-bs042.html b/doc/pub/week37/html/._week37-bs042.html index 4ca498568..441da945a 100644 --- a/doc/pub/week37/html/._week37-bs042.html +++ b/doc/pub/week37/html/._week37-bs042.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,7 +290,22 @@ MathJax.Hub.Config({

     

     

     

    -

    Plotting the Histogram

    +

    Code example for the Bootstrap method

    + +

    The following code starts with a Gaussian distribution with mean value +\( \mu =100 \) and variance \( \sigma=15 \). We use this to generate the data +used in the bootstrap analysis. The bootstrap analysis returns a data +set after a given number of bootstrap operations (as many as we have +data points). This data set consists of estimated mean values for each +bootstrap operation. The histogram generated by the bootstrap method +shows that the distribution for these mean values is also a Gaussian, +centered around the mean value \( \mu=100 \) but with standard deviation +\( \sigma/\sqrt{n} \), where \( n \) is the number of bootstrap samples (in +this case the same as the number of original data points). The value +of the standard deviation is what we expect from the central limit +theorem. +

    +
    @@ -293,15 +313,32 @@ MathJax.Hub.Config({
    -
    # the histogram of the bootstrapped data (normalized data if density = True)
    -n, binsboot, patches = plt.hist(t, 50, density=True, facecolor='red', alpha=0.75)
    -# add a 'best fit' line  
    -y = norm.pdf(binsboot, np.mean(t), np.std(t))
    -lt = plt.plot(binsboot, y, 'b', linewidth=1)
    -plt.xlabel('x')
    -plt.ylabel('Probability')
    -plt.grid(True)
    -plt.show()
    +  
    import numpy as np
    +from time import time
    +from scipy.stats import norm
    +import matplotlib.pyplot as plt
    +
    +# Returns mean of bootstrap samples 
    +# Bootstrap algorithm
    +def bootstrap(data, datapoints):
    +    t = np.zeros(datapoints)
    +    n = len(data)
    +    # non-parametric bootstrap         
    +    for i in range(datapoints):
    +        t[i] = np.mean(data[np.random.randint(0,n,n)])
    +    # analysis    
    +    print("Bootstrap Statistics :")
    +    print("original           bias      std. error")
    +    print("%8g %8g %14g %15g" % (np.mean(data), np.std(data),np.mean(t),np.std(t)))
    +    return t
    +
    +# We set the mean value to 100 and the standard deviation to 15
    +mu, sigma = 100, 15
    +datapoints = 10000
    +# We generate random numbers according to the normal distribution
    +x = mu + sigma*np.random.randn(datapoints)
    +# bootstrap returns the data sample                                    
    +t = bootstrap(x, datapoints)
     
    @@ -317,6 +354,7 @@ plt.show()
    +

    We see that our new variance and from that the standard deviation, agrees with the central limit theorem.

    @@ -343,7 +381,7 @@ plt.show()

  • 51
  • 52
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs043.html b/doc/pub/week37/html/._week37-bs043.html index 48ca08c48..a2bd52fc6 100644 --- a/doc/pub/week37/html/._week37-bs043.html +++ b/doc/pub/week37/html/._week37-bs043.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,64 +290,38 @@ MathJax.Hub.Config({

     

     

     

    -

    The bias-variance tradeoff

    +

    Plotting the Histogram

    -

    We will discuss the bias-variance tradeoff in the context of -continuous predictions such as regression. However, many of the -intuitions and ideas discussed here also carry over to classification -tasks. Consider a dataset \( \mathcal{D} \) consisting of the data -\( \mathbf{X}_\mathcal{D}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\} \). -

    + +
    +
    +
    +
    +
    +
    # the histogram of the bootstrapped data (normalized data if density = True)
    +n, binsboot, patches = plt.hist(t, 50, density=True, facecolor='red', alpha=0.75)
    +# add a 'best fit' line  
    +y = norm.pdf(binsboot, np.mean(t), np.std(t))
    +lt = plt.plot(binsboot, y, 'b', linewidth=1)
    +plt.xlabel('x')
    +plt.ylabel('Probability')
    +plt.grid(True)
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    Let us assume that the true data is generated from a noisy model

    - -$$ -\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon} -$$ - -

    where \( \epsilon \) is normally distributed with mean zero and standard deviation \( \sigma^2 \).

    - -

    In our derivation of the ordinary least squares method we defined then -an approximation to the function \( f \) in terms of the parameters -\( \boldsymbol{\beta} \) and the design matrix \( \boldsymbol{X} \) which embody our model, -that is \( \boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\beta} \). -

    - -

    Thereafter we found the parameters \( \boldsymbol{\beta} \) by optimizing the means squared error via the so-called cost function

    -$$ -C(\boldsymbol{X},\boldsymbol{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]. -$$ - -

    We can rewrite this as

    -$$ -\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\frac{1}{n}\sum_i(f_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\sigma^2. -$$ - -

    The three terms represent the square of the bias of the learning -method, which can be thought of as the error caused by the simplifying -assumptions built into the method. The second term represents the -variance of the chosen model and finally the last terms is variance of -the error \( \boldsymbol{\epsilon} \). -

    - -

    To derive this equation, we need to recall that the variance of \( \boldsymbol{y} \) and \( \boldsymbol{\epsilon} \) are both equal to \( \sigma^2 \). The mean value of \( \boldsymbol{\epsilon} \) is by definition equal to zero. Furthermore, the function \( f \) is not a stochastics variable, idem for \( \boldsymbol{\tilde{y}} \). -We use a more compact notation in terms of the expectation value -

    -$$ -\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}})^2\right], -$$ - -

    and adding and subtracting \( \mathbb{E}\left[\boldsymbol{\tilde{y}}\right] \) we get

    -$$ -\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}}+\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right], -$$ - -

    which, using the abovementioned expectation values can be rewritten as

    -$$ -\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right]+\mathrm{Var}\left[\boldsymbol{\tilde{y}}\right]+\sigma^2, -$$ - -

    that is the rewriting in terms of the so-called bias, the variance of the model \( \boldsymbol{\tilde{y}} \) and the variance of \( \boldsymbol{\epsilon} \).

    @@ -369,7 +348,7 @@ $$

  • 52
  • 53
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs044.html b/doc/pub/week37/html/._week37-bs044.html index 3943f0c3a..d67bf9529 100644 --- a/doc/pub/week37/html/._week37-bs044.html +++ b/doc/pub/week37/html/._week37-bs044.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,13 +290,64 @@ MathJax.Hub.Config({

     

     

     

    -

    A way to Read the Bias-Variance Tradeoff

    +

    The bias-variance tradeoff

    -

    -
    -

    -
    -

    +

    We will discuss the bias-variance tradeoff in the context of +continuous predictions such as regression. However, many of the +intuitions and ideas discussed here also carry over to classification +tasks. Consider a dataset \( \mathcal{D} \) consisting of the data +\( \mathbf{X}_\mathcal{D}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\} \). +

    + +

    Let us assume that the true data is generated from a noisy model

    + +$$ +\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon} +$$ + +

    where \( \epsilon \) is normally distributed with mean zero and standard deviation \( \sigma^2 \).

    + +

    In our derivation of the ordinary least squares method we defined then +an approximation to the function \( f \) in terms of the parameters +\( \boldsymbol{\beta} \) and the design matrix \( \boldsymbol{X} \) which embody our model, +that is \( \boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\beta} \). +

    + +

    Thereafter we found the parameters \( \boldsymbol{\beta} \) by optimizing the means squared error via the so-called cost function

    +$$ +C(\boldsymbol{X},\boldsymbol{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]. +$$ + +

    We can rewrite this as

    +$$ +\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\frac{1}{n}\sum_i(f_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\sigma^2. +$$ + +

    The three terms represent the square of the bias of the learning +method, which can be thought of as the error caused by the simplifying +assumptions built into the method. The second term represents the +variance of the chosen model and finally the last terms is variance of +the error \( \boldsymbol{\epsilon} \). +

    + +

    To derive this equation, we need to recall that the variance of \( \boldsymbol{y} \) and \( \boldsymbol{\epsilon} \) are both equal to \( \sigma^2 \). The mean value of \( \boldsymbol{\epsilon} \) is by definition equal to zero. Furthermore, the function \( f \) is not a stochastics variable, idem for \( \boldsymbol{\tilde{y}} \). +We use a more compact notation in terms of the expectation value +

    +$$ +\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}})^2\right], +$$ + +

    and adding and subtracting \( \mathbb{E}\left[\boldsymbol{\tilde{y}}\right] \) we get

    +$$ +\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}}+\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right], +$$ + +

    which, using the abovementioned expectation values can be rewritten as

    +$$ +\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right]+\mathrm{Var}\left[\boldsymbol{\tilde{y}}\right]+\sigma^2, +$$ + +

    that is the rewriting in terms of the so-called bias, the variance of the model \( \boldsymbol{\tilde{y}} \) and the variance of \( \boldsymbol{\epsilon} \).

    @@ -317,6 +373,8 @@ MathJax.Hub.Config({

  • 52
  • 53
  • 54
  • +
  • ...
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs045.html b/doc/pub/week37/html/._week37-bs045.html index e02d2cda3..71a6a564c 100644 --- a/doc/pub/week37/html/._week37-bs045.html +++ b/doc/pub/week37/html/._week37-bs045.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,83 +290,13 @@ MathJax.Hub.Config({

     

     

     

    -

    Example code for Bias-Variance tradeoff

    - - -
    -
    -
    -
    -
    -
    import matplotlib.pyplot as plt
    -import numpy as np
    -from sklearn.linear_model import LinearRegression, Ridge, Lasso
    -from sklearn.preprocessing import PolynomialFeatures
    -from sklearn.model_selection import train_test_split
    -from sklearn.pipeline import make_pipeline
    -from sklearn.utils import resample
    -
    -np.random.seed(2018)
    -
    -n = 500
    -n_boostraps = 100
    -degree = 18  # A quite high value, just to show.
    -noise = 0.1
    -
    -# Make data set.
    -x = np.linspace(-1, 3, n).reshape(-1, 1)
    -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape)
    -
    -# Hold out some test data that is never used in training.
    -x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    -
    -# Combine x transformation and model into one operation.
    -# Not neccesary, but convenient.
    -model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
    -
    -# The following (m x n_bootstraps) matrix holds the column vectors y_pred
    -# for each bootstrap iteration.
    -y_pred = np.empty((y_test.shape[0], n_boostraps))
    -for i in range(n_boostraps):
    -    x_, y_ = resample(x_train, y_train)
    -
    -    # Evaluate the new model on the same test data each time.
    -    y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
    -
    -# Note: Expectations and variances taken w.r.t. different training
    -# data sets, hence the axis=1. Subsequent means are taken across the test data
    -# set in order to obtain a total value, but before this we have error/bias/variance
    -# calculated per data point in the test set.
    -# Note 2: The use of keepdims=True is important in the calculation of bias as this 
    -# maintains the column vector form. Dropping this yields very unexpected results.
    -error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    -bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    -variance = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    -print('Error:', error)
    -print('Bias^2:', bias)
    -print('Var:', variance)
    -print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance))
    -
    -plt.plot(x[::5, :], y[::5, :], label='f(x)')
    -plt.scatter(x_test, y_test, label='Data points')
    -plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred')
    -plt.legend()
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    A way to Read the Bias-Variance Tradeoff

    +

    +
    +

    +
    +

    @@ -386,6 +321,7 @@ plt.show()

  • 52
  • 53
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs046.html b/doc/pub/week37/html/._week37-bs046.html index 5e54e47f2..6204b1a48 100644 --- a/doc/pub/week37/html/._week37-bs046.html +++ b/doc/pub/week37/html/._week37-bs046.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -285,7 +290,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Understanding what happens

    +

    Example code for Bias-Variance tradeoff

    @@ -303,40 +308,48 @@ MathJax.Hub.Config({ np.random.seed(2018) -n = 40 +n = 500 n_boostraps = 100 -maxdegree = 14 - +degree = 18 # A quite high value, just to show. +noise = 0.1 # Make data set. -x = np.linspace(-3, 3, n).reshape(-1, 1) -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape) -error = np.zeros(maxdegree) -bias = np.zeros(maxdegree) -variance = np.zeros(maxdegree) -polydegree = np.zeros(maxdegree) +x = np.linspace(-1, 3, n).reshape(-1, 1) +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape) + +# Hold out some test data that is never used in training. x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2) -for degree in range(maxdegree): - model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False)) - y_pred = np.empty((y_test.shape[0], n_boostraps)) - for i in range(n_boostraps): - x_, y_ = resample(x_train, y_train) - y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel() +# Combine x transformation and model into one operation. +# Not neccesary, but convenient. +model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False)) - polydegree[degree] = degree - error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) ) - bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 ) - variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) ) - print('Polynomial degree:', degree) - print('Error:', error[degree]) - print('Bias^2:', bias[degree]) - print('Var:', variance[degree]) - print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree])) +# The following (m x n_bootstraps) matrix holds the column vectors y_pred +# for each bootstrap iteration. +y_pred = np.empty((y_test.shape[0], n_boostraps)) +for i in range(n_boostraps): + x_, y_ = resample(x_train, y_train) -plt.plot(polydegree, error, label='Error') -plt.plot(polydegree, bias, label='bias') -plt.plot(polydegree, variance, label='Variance') + # Evaluate the new model on the same test data each time. + y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel() + +# Note: Expectations and variances taken w.r.t. different training +# data sets, hence the axis=1. Subsequent means are taken across the test data +# set in order to obtain a total value, but before this we have error/bias/variance +# calculated per data point in the test set. +# Note 2: The use of keepdims=True is important in the calculation of bias as this +# maintains the column vector form. Dropping this yields very unexpected results. +error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) ) +bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 ) +variance = np.mean( np.var(y_pred, axis=1, keepdims=True) ) +print('Error:', error) +print('Bias^2:', bias) +print('Var:', variance) +print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance)) + +plt.plot(x[::5, :], y[::5, :], label='f(x)') +plt.scatter(x_test, y_test, label='Data points') +plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred') plt.legend() plt.show() @@ -377,6 +390,7 @@ plt.show()
  • 52
  • 53
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs047.html b/doc/pub/week37/html/._week37-bs047.html index b6733d01a..719c50e34 100644 --- a/doc/pub/week37/html/._week37-bs047.html +++ b/doc/pub/week37/html/._week37-bs047.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -284,39 +289,76 @@ MathJax.Hub.Config({

     

     

     

    - -

    Summing up

    + +

    Understanding what happens

    -

    The bias-variance tradeoff summarizes the fundamental tension in -machine learning, particularly supervised learning, between the -complexity of a model and the amount of training data needed to train -it. Since data is often limited, in practice it is often useful to -use a less-complex model with higher bias, that is a model whose asymptotic -performance is worse than another model because it is easier to -train and less sensitive to sampling noise arising from having a -finite-sized training dataset (smaller variance). -

    + +
    +
    +
    +
    +
    +
    import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.linear_model import LinearRegression, Ridge, Lasso
    +from sklearn.preprocessing import PolynomialFeatures
    +from sklearn.model_selection import train_test_split
    +from sklearn.pipeline import make_pipeline
    +from sklearn.utils import resample
     
    -

    The above equations tell us that in -order to minimize the expected test error, we need to select a -statistical learning method that simultaneously achieves low variance -and low bias. Note that variance is inherently a nonnegative quantity, -and squared bias is also nonnegative. Hence, we see that the expected -test MSE can never lie below \( Var(\epsilon) \), the irreducible error. -

    +np.random.seed(2018) -

    What do we mean by the variance and bias of a statistical learning -method? The variance refers to the amount by which our model would change if we -estimated it using a different training data set. Since the training -data are used to fit the statistical learning method, different -training data sets will result in a different estimate. But ideally the -estimate for our model should not vary too much between training -sets. However, if a method has high variance then small changes in -the training data can result in large changes in the model. In general, more -flexible statistical methods have higher variance. -

    +n = 40 +n_boostraps = 100 +maxdegree = 14 + + +# Make data set. +x = np.linspace(-3, 3, n).reshape(-1, 1) +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape) +error = np.zeros(maxdegree) +bias = np.zeros(maxdegree) +variance = np.zeros(maxdegree) +polydegree = np.zeros(maxdegree) +x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2) + +for degree in range(maxdegree): + model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False)) + y_pred = np.empty((y_test.shape[0], n_boostraps)) + for i in range(n_boostraps): + x_, y_ = resample(x_train, y_train) + y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel() + + polydegree[degree] = degree + error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) ) + bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 ) + variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) ) + print('Polynomial degree:', degree) + print('Error:', error[degree]) + print('Bias^2:', bias[degree]) + print('Var:', variance[degree]) + print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree])) + +plt.plot(polydegree, error, label='Error') +plt.plot(polydegree, bias, label='bias') +plt.plot(polydegree, variance, label='Variance') +plt.legend() +plt.show() +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    You may also find this recent article of interest.

    @@ -339,6 +381,7 @@ flexible statistical methods have higher variance.

  • 52
  • 53
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs048.html b/doc/pub/week37/html/._week37-bs048.html index 40c6bfd4e..ab14bd60b 100644 --- a/doc/pub/week37/html/._week37-bs048.html +++ b/doc/pub/week37/html/._week37-bs048.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -284,101 +289,39 @@ MathJax.Hub.Config({

     

     

     

    - -

    Another Example from Scikit-Learn's Repository

    + +

    Summing up

    - -
    -
    -
    -
    -
    -
    """
    -============================
    -Underfitting vs. Overfitting
    -============================
    +

    The bias-variance tradeoff summarizes the fundamental tension in +machine learning, particularly supervised learning, between the +complexity of a model and the amount of training data needed to train +it. Since data is often limited, in practice it is often useful to +use a less-complex model with higher bias, that is a model whose asymptotic +performance is worse than another model because it is easier to +train and less sensitive to sampling noise arising from having a +finite-sized training dataset (smaller variance). +

    -This example demonstrates the problems of underfitting and overfitting and -how we can use linear regression with polynomial features to approximate -nonlinear functions. The plot shows the function that we want to approximate, -which is a part of the cosine function. In addition, the samples from the -real function and the approximations of different models are displayed. The -models have polynomial features of different degrees. We can see that a -linear function (polynomial with degree 1) is not sufficient to fit the -training samples. This is called **underfitting**. A polynomial of degree 4 -approximates the true function almost perfectly. However, for higher degrees -the model will **overfit** the training data, i.e. it learns the noise of the -training data. -We evaluate quantitatively **overfitting** / **underfitting** by using -cross-validation. We calculate the mean squared error (MSE) on the validation -set, the higher, the less likely the model generalizes correctly from the -training data. -""" +

    The above equations tell us that in +order to minimize the expected test error, we need to select a +statistical learning method that simultaneously achieves low variance +and low bias. Note that variance is inherently a nonnegative quantity, +and squared bias is also nonnegative. Hence, we see that the expected +test MSE can never lie below \( Var(\epsilon) \), the irreducible error. +

    -print(__doc__) - -import numpy as np -import matplotlib.pyplot as plt -from sklearn.pipeline import Pipeline -from sklearn.preprocessing import PolynomialFeatures -from sklearn.linear_model import LinearRegression -from sklearn.model_selection import cross_val_score - - -def true_fun(X): - return np.cos(1.5 * np.pi * X) - -np.random.seed(0) - -n_samples = 30 -degrees = [1, 4, 15] - -X = np.sort(np.random.rand(n_samples)) -y = true_fun(X) + np.random.randn(n_samples) * 0.1 - -plt.figure(figsize=(14, 5)) -for i in range(len(degrees)): - ax = plt.subplot(1, len(degrees), i + 1) - plt.setp(ax, xticks=(), yticks=()) - - polynomial_features = PolynomialFeatures(degree=degrees[i], - include_bias=False) - linear_regression = LinearRegression() - pipeline = Pipeline([("polynomial_features", polynomial_features), - ("linear_regression", linear_regression)]) - pipeline.fit(X[:, np.newaxis], y) - - # Evaluate the models using crossvalidation - scores = cross_val_score(pipeline, X[:, np.newaxis], y, - scoring="neg_mean_squared_error", cv=10) - - X_test = np.linspace(0, 1, 100) - plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label="Model") - plt.plot(X_test, true_fun(X_test), label="True function") - plt.scatter(X, y, edgecolor='b', s=20, label="Samples") - plt.xlabel("x") - plt.ylabel("y") - plt.xlim((0, 1)) - plt.ylim((-2, 2)) - plt.legend(loc="best") - plt.title("Degree {}\nMSE = {:.2e}(+/- {:.2e})".format( - degrees[i], -scores.mean(), scores.std())) -plt.show() -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    What do we mean by the variance and bias of a statistical learning +method? The variance refers to the amount by which our model would change if we +estimated it using a different training data set. Since the training +data are used to fit the statistical learning method, different +training data sets will result in a different estimate. But ideally the +estimate for our model should not vary too much between training +sets. However, if a method has high variance then small changes in +the training data can result in large changes in the model. In general, more +flexible statistical methods have higher variance. +

    +

    You may also find this recent article of interest.

    @@ -400,6 +343,7 @@ plt.show()

  • 52
  • 53
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs049.html b/doc/pub/week37/html/._week37-bs049.html index e30ab52d3..de5e548cb 100644 --- a/doc/pub/week37/html/._week37-bs049.html +++ b/doc/pub/week37/html/._week37-bs049.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -284,24 +289,101 @@ MathJax.Hub.Config({

     

     

     

    - -

    Various steps in cross-validation

    + +

    Another Example from Scikit-Learn's Repository

    + + +
    +
    +
    +
    +
    +
    """
    +============================
    +Underfitting vs. Overfitting
    +============================
    +
    +This example demonstrates the problems of underfitting and overfitting and
    +how we can use linear regression with polynomial features to approximate
    +nonlinear functions. The plot shows the function that we want to approximate,
    +which is a part of the cosine function. In addition, the samples from the
    +real function and the approximations of different models are displayed. The
    +models have polynomial features of different degrees. We can see that a
    +linear function (polynomial with degree 1) is not sufficient to fit the
    +training samples. This is called **underfitting**. A polynomial of degree 4
    +approximates the true function almost perfectly. However, for higher degrees
    +the model will **overfit** the training data, i.e. it learns the noise of the
    +training data.
    +We evaluate quantitatively **overfitting** / **underfitting** by using
    +cross-validation. We calculate the mean squared error (MSE) on the validation
    +set, the higher, the less likely the model generalizes correctly from the
    +training data.
    +"""
    +
    +print(__doc__)
    +
    +import numpy as np
    +import matplotlib.pyplot as plt
    +from sklearn.pipeline import Pipeline
    +from sklearn.preprocessing import PolynomialFeatures
    +from sklearn.linear_model import LinearRegression
    +from sklearn.model_selection import cross_val_score
    +
    +
    +def true_fun(X):
    +    return np.cos(1.5 * np.pi * X)
    +
    +np.random.seed(0)
    +
    +n_samples = 30
    +degrees = [1, 4, 15]
    +
    +X = np.sort(np.random.rand(n_samples))
    +y = true_fun(X) + np.random.randn(n_samples) * 0.1
    +
    +plt.figure(figsize=(14, 5))
    +for i in range(len(degrees)):
    +    ax = plt.subplot(1, len(degrees), i + 1)
    +    plt.setp(ax, xticks=(), yticks=())
    +
    +    polynomial_features = PolynomialFeatures(degree=degrees[i],
    +                                             include_bias=False)
    +    linear_regression = LinearRegression()
    +    pipeline = Pipeline([("polynomial_features", polynomial_features),
    +                         ("linear_regression", linear_regression)])
    +    pipeline.fit(X[:, np.newaxis], y)
    +
    +    # Evaluate the models using crossvalidation
    +    scores = cross_val_score(pipeline, X[:, np.newaxis], y,
    +                             scoring="neg_mean_squared_error", cv=10)
    +
    +    X_test = np.linspace(0, 1, 100)
    +    plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label="Model")
    +    plt.plot(X_test, true_fun(X_test), label="True function")
    +    plt.scatter(X, y, edgecolor='b', s=20, label="Samples")
    +    plt.xlabel("x")
    +    plt.ylabel("y")
    +    plt.xlim((0, 1))
    +    plt.ylim((-2, 2))
    +    plt.legend(loc="best")
    +    plt.title("Degree {}\nMSE = {:.2e}(+/- {:.2e})".format(
    +        degrees[i], -scores.mean(), scores.std()))
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    When the repetitive splitting of the data set is done randomly, -samples may accidently end up in a fast majority of the splits in -either training or test set. Such samples may have an unbalanced -influence on either model building or prediction evaluation. To avoid -this \( k \)-fold cross-validation structures the data splitting. The -samples are divided into \( k \) more or less equally sized exhaustive and -mutually exclusive subsets. In turn (at each split) one of these -subsets plays the role of the test set while the union of the -remaining subsets constitutes the training set. Such a splitting -warrants a balanced representation of each sample in both training and -test set over the splits. Still the division into the \( k \) subsets -involves a degree of randomness. This may be fully excluded when -choosing \( k=n \). This particular case is referred to as leave-one-out -cross-validation (LOOCV). -

    @@ -322,6 +404,7 @@ cross-validation (LOOCV).

  • 52
  • 53
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/week37-bs.html b/doc/pub/week37/html/week37-bs.html index eb476f9f4..d3cd07a53 100644 --- a/doc/pub/week37/html/week37-bs.html +++ b/doc/pub/week37/html/week37-bs.html @@ -37,6 +37,10 @@ doconce format html week37.do.txt --html_style=bootstrap --pygments_html_style=d
  • Plans for week 37
  • -
  • Linking the regression analysis with a statistical interpretation
  • -
  • Assumptions made
  • -
  • Expectation value and variance
  • -
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • -
  • Material for lecture Thursday September 14
  • -
  • Deriving OLS from a probability distribution
  • -
  • Independent and Identically Distrubuted (iid)
  • -
  • Maximum Likelihood Estimation (MLE)
  • -
  • A new Cost Function
  • -
  • More basic Statistics and Bayes' theorem
  • -
  • Marginal Probability
  • -
  • Conditional Probability
  • -
  • Bayes' Theorem
  • -
  • Interpretations of Bayes' Theorem
  • -
  • Example of Usage of Bayes' theorem
  • -
  • Doing it correctly
  • -
  • Bayes' Theorem and Ridge and Lasso Regression
  • -
  • Ridge and Bayes
  • -
  • Lasso and Bayes
  • -
  • Test Function for what happens with OLS, Ridge and Lasso
  • -
  • Rerunning the above code
  • -
  • Why resampling methods
  • -
  • Resampling methods
  • -
  • Resampling approaches can be computationally expensive
  • -
  • Why resampling methods ?
  • -
  • Statistical analysis
  • -
  • Resampling methods
  • -
  • Resampling methods: Bootstrap
  • -
  • The Central Limit Theorem
  • -
  • Finding the Limit
  • -
  • Rewriting the \( \delta \)-function
  • -
  • Identifying Terms
  • -
  • Wrapping it up
  • -
  • Confidence Intervals
  • -
  • Standard Approach based on the Normal Distribution
  • -
  • Resampling methods: Bootstrap background
  • -
  • Resampling methods: More Bootstrap background
  • -
  • Resampling methods: Bootstrap approach
  • -
  • Resampling methods: Bootstrap steps
  • -
  • Code example for the Bootstrap method
  • -
  • Plotting the Histogram
  • -
  • The bias-variance tradeoff
  • -
  • A way to Read the Bias-Variance Tradeoff
  • -
  • Example code for Bias-Variance tradeoff
  • -
  • Understanding what happens
  • -
  • Summing up
  • -
  • Another Example from Scikit-Learn's Repository
  • -
  • Various steps in cross-validation
  • -
  • Cross-validation in brief
  • -
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • -
  • More examples on bootstrap and cross-validation and errors
  • -
  • The same example but now with cross-validation
  • +
  • Material from last week and relevant for the weekly exercises
  • +
  • Linking the regression analysis with a statistical interpretation
  • +
  • Assumptions made
  • +
  • Expectation value and variance
  • +
  • Expectation value and variance for \( \boldsymbol{\beta} \)
  • +
  • Material for lecture Thursday September 14
  • +
  • Deriving OLS from a probability distribution
  • +
  • Independent and Identically Distrubuted (iid)
  • +
  • Maximum Likelihood Estimation (MLE)
  • +
  • A new Cost Function
  • +
  • More basic Statistics and Bayes' theorem
  • +
  • Marginal Probability
  • +
  • Conditional Probability
  • +
  • Bayes' Theorem
  • +
  • Interpretations of Bayes' Theorem
  • +
  • Example of Usage of Bayes' theorem
  • +
  • Doing it correctly
  • +
  • Bayes' Theorem and Ridge and Lasso Regression
  • +
  • Ridge and Bayes
  • +
  • Lasso and Bayes
  • +
  • Test Function for what happens with OLS, Ridge and Lasso
  • +
  • Rerunning the above code
  • +
  • Why resampling methods
  • +
  • Resampling methods
  • +
  • Resampling approaches can be computationally expensive
  • +
  • Why resampling methods ?
  • +
  • Statistical analysis
  • +
  • Resampling methods
  • +
  • Resampling methods: Bootstrap
  • +
  • The Central Limit Theorem
  • +
  • Finding the Limit
  • +
  • Rewriting the \( \delta \)-function
  • +
  • Identifying Terms
  • +
  • Wrapping it up
  • +
  • Confidence Intervals
  • +
  • Standard Approach based on the Normal Distribution
  • +
  • Resampling methods: Bootstrap background
  • +
  • Resampling methods: More Bootstrap background
  • +
  • Resampling methods: Bootstrap approach
  • +
  • Resampling methods: Bootstrap steps
  • +
  • Code example for the Bootstrap method
  • +
  • Plotting the Histogram
  • +
  • The bias-variance tradeoff
  • +
  • A way to Read the Bias-Variance Tradeoff
  • +
  • Example code for Bias-Variance tradeoff
  • +
  • Understanding what happens
  • +
  • Summing up
  • +
  • Another Example from Scikit-Learn's Repository
  • +
  • Various steps in cross-validation
  • +
  • Cross-validation in brief
  • +
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • +
  • More examples on bootstrap and cross-validation and errors
  • +
  • The same example but now with cross-validation
  • @@ -303,10 +308,12 @@ MathJax.Hub.Config({
    -

    Sep 10, 2023

    +

    Sep 11, 2023


    + +

    Read »

    @@ -328,7 +335,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 54
  • +
  • 55
  • »
  • diff --git a/doc/pub/week37/html/week37-reveal.html b/doc/pub/week37/html/week37-reveal.html index 952023375..e7ceb58d1 100644 --- a/doc/pub/week37/html/week37-reveal.html +++ b/doc/pub/week37/html/week37-reveal.html @@ -184,10 +184,12 @@ MathJax.Hub.Config({
    -

    Sep 10, 2023

    +

    Sep 11, 2023


    + +
    © 1999-2023, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license @@ -209,6 +211,8 @@ MathJax.Hub.Config({

  • Work on project 1
  • See also additional note on scaling (jupyter-notebook) sent separately. This will be discussed during the first hour of each session.
  • + +

  • For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.
  • @@ -219,22 +223,29 @@ MathJax.Hub.Config({

  • Statistical interpretation of Ridge and Lasso regression
  • -

  • Resampling techniques, Bootstrap and cross validation
  • +

  • Resampling techniques, Bootstrap and cross validation and bias-variance tradeoff
  • -

  • Recommended Reading: +

  • Reads and Videos:
      -

    1. Lectures on Resampling methods (these lectures)
    2. +

    3. Hastie et al Chapter 7, here we recommend 7.1-7.5 and 7.10 (cross-validation) and 7.11 (bootstrap).
    4. -

    5. Bishop 1.3 (cross-validation) and 3.2 (bias-variance tradeoff)
    6. +

    7. Video on cross validation
    8. +
        -

      1. Hastie et al Chapter 7, here we recommend 7.1-7.5 and 7.10 (cross-validation) and 7.11 (bootstrap).
      2. +

      3. Video on bias-variance tradeoff
      4. +
      +

  • +
    +

    Material from last week and relevant for the weekly exercises

    +
    +

    Linking the regression analysis with a statistical interpretation

    @@ -432,6 +443,8 @@ $$ matrix product is non-negative definite. This means the variance we obtain with the standard OLS will always for \( \lambda > 0 \) be larger than the variance of \( \boldsymbol{\beta} \) obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below.

    + +

    For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.

    diff --git a/doc/pub/week37/html/week37-solarized.html b/doc/pub/week37/html/week37-solarized.html index 26ad9e03b..89c29f8ce 100644 --- a/doc/pub/week37/html/week37-solarized.html +++ b/doc/pub/week37/html/week37-solarized.html @@ -64,6 +64,10 @@ div.toc p,a {
    + +









    Plans for week 37

    @@ -266,6 +272,7 @@ MathJax.Hub.Config({
  • Exercise for week 37
  • Work on project 1
  • See also additional note on scaling (jupyter-notebook) sent separately. This will be discussed during the first hour of each session.
  • +
  • For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.
  • @@ -274,17 +281,22 @@ MathJax.Hub.Config({

    • Statistical interpretation of Ridge and Lasso regression
    • -
    • Resampling techniques, Bootstrap and cross validation
    • -
    • Recommended Reading: +
    • Resampling techniques, Bootstrap and cross validation and bias-variance tradeoff
    • +
    • Reads and Videos:
        -
      1. Lectures on Resampling methods (these lectures)
      2. -
      3. Bishop 1.3 (cross-validation) and 3.2 (bias-variance tradeoff)
      4. Hastie et al Chapter 7, here we recommend 7.1-7.5 and 7.10 (cross-validation) and 7.11 (bootstrap).
      5. +
      6. Video on cross validation
      7. +
          +
        1. Video on bias-variance tradeoff
        2. +
    +









    +

    Material from last week and relevant for the weekly exercises

    +

    Linking the regression analysis with a statistical interpretation

    @@ -461,6 +473,8 @@ matrix product is non-negative definite. This means the variance we obtain with the standard OLS will always for \( \lambda > 0 \) be larger than the variance of \( \boldsymbol{\beta} \) obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below.

    +

    For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.

    +









    Material for lecture Thursday September 14

    diff --git a/doc/pub/week37/html/week37.html b/doc/pub/week37/html/week37.html index aa62c0e00..f0a003695 100644 --- a/doc/pub/week37/html/week37.html +++ b/doc/pub/week37/html/week37.html @@ -141,6 +141,10 @@ div.toc p,a {
    + +









    Plans for week 37

    @@ -343,6 +349,7 @@ MathJax.Hub.Config({
  • Exercise for week 37
  • Work on project 1
  • See also additional note on scaling (jupyter-notebook) sent separately. This will be discussed during the first hour of each session.
  • +
  • For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.
  • @@ -351,17 +358,22 @@ MathJax.Hub.Config({

    +









    +

    Material from last week and relevant for the weekly exercises

    +

    Linking the regression analysis with a statistical interpretation

    @@ -538,6 +550,8 @@ matrix product is non-negative definite. This means the variance we obtain with the standard OLS will always for \( \lambda > 0 \) be larger than the variance of \( \boldsymbol{\beta} \) obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below.

    +

    For more discussions of Ridge regression and calculation of averages, Wessel van Wieringen's article is highly recommended.

    +









    Material for lecture Thursday September 14

    diff --git a/doc/pub/week37/ipynb/ipynb-week37-src.tar.gz b/doc/pub/week37/ipynb/ipynb-week37-src.tar.gz index d5a603c6ad96eb429138bcb5a14e8f624aa4e2d9..0e39cfbb88715e45faa37f06ac3f275d72bb1775 100644 GIT binary patch delta 62 zcmWN_Hvxb!002Si6KW*jBm!{7@Dm#&K4OO{Lg2" ] }, { "cell_type": "markdown", - "id": "8ce2123e", + "id": "4e4a25aa", "metadata": { "editable": true }, @@ -46,25 +48,37 @@ "\n", " * See also additional note on scaling (jupyter-notebook) sent separately. This will be discussed during the first hour of each session.\n", "\n", + " * For more discussions of Ridge regression and calculation of averages, [Wessel van Wieringen's](https://arxiv.org/abs/1509.09169) article is highly recommended.\n", + "\n", " \n", "**Material for the lecture on Thursday September 7.**\n", "\n", " * Statistical interpretation of Ridge and Lasso regression\n", "\n", - " * Resampling techniques, Bootstrap and cross validation\n", + " * Resampling techniques, Bootstrap and cross validation and bias-variance tradeoff\n", "\n", - " * Recommended Reading:\n", + " * Reads and Videos:\n", "\n", - "a. Lectures on Resampling methods (these lectures)\n", + "a. Hastie et al Chapter 7, here we recommend 7.1-7.5 and 7.10 (cross-validation) and 7.11 (bootstrap). \n", "\n", - "b. Bishop 1.3 (cross-validation) and 3.2 (bias-variance tradeoff)\n", + "b. [Video on cross validation](https://www.youtube.com/watch?v=fSytzGwwBVw)\n", "\n", - "c. Hastie et al Chapter 7, here we recommend 7.1-7.5 and 7.10 (cross-validation) and 7.11 (bootstrap)." + "1. [Video on bias-variance tradeoff](https://www.youtube.com/watch?v=EuBBz3bI-aA)" ] }, { "cell_type": "markdown", - "id": "fb87684a", + "id": "e66517cd", + "metadata": { + "editable": true + }, + "source": [ + "## Material from last week and relevant for the weekly exercises" + ] + }, + { + "cell_type": "markdown", + "id": "d3ccbcff", "metadata": { "editable": true }, @@ -93,7 +107,7 @@ }, { "cell_type": "markdown", - "id": "6dc640e8", + "id": "1ec219ea", "metadata": { "editable": true }, @@ -109,7 +123,7 @@ }, { "cell_type": "markdown", - "id": "01bb7bf0", + "id": "7bcbae1d", "metadata": { "editable": true }, @@ -128,7 +142,7 @@ }, { "cell_type": "markdown", - "id": "3ba96dfc", + "id": "f9586614", "metadata": { "editable": true }, @@ -142,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "dada2667", + "id": "260198c3", "metadata": { "editable": true }, @@ -154,7 +168,7 @@ }, { "cell_type": "markdown", - "id": "7e153b73", + "id": "9cd1009f", "metadata": { "editable": true }, @@ -165,7 +179,7 @@ }, { "cell_type": "markdown", - "id": "616b8399", + "id": "831c80d0", "metadata": { "editable": true }, @@ -177,7 +191,7 @@ }, { "cell_type": "markdown", - "id": "c1be60fe", + "id": "ddea48e2", "metadata": { "editable": true }, @@ -189,7 +203,7 @@ }, { "cell_type": "markdown", - "id": "72417578", + "id": "bb03631f", "metadata": { "editable": true }, @@ -205,7 +219,7 @@ }, { "cell_type": "markdown", - "id": "fa6c56eb", + "id": "96be3b4a", "metadata": { "editable": true }, @@ -216,7 +230,7 @@ }, { "cell_type": "markdown", - "id": "e58682e5", + "id": "e2456163", "metadata": { "editable": true }, @@ -239,7 +253,7 @@ }, { "cell_type": "markdown", - "id": "326cc77c", + "id": "6f9438d3", "metadata": { "editable": true }, @@ -250,7 +264,7 @@ }, { "cell_type": "markdown", - "id": "2bab9073", + "id": "716fbb1c", "metadata": { "editable": true }, @@ -262,7 +276,7 @@ }, { "cell_type": "markdown", - "id": "ce082810", + "id": "112e96a7", "metadata": { "editable": true }, @@ -274,7 +288,7 @@ }, { "cell_type": "markdown", - "id": "843e8043", + "id": "6004f2b0", "metadata": { "editable": true }, @@ -288,7 +302,7 @@ }, { "cell_type": "markdown", - "id": "7eeaa862", + "id": "67047db2", "metadata": { "editable": true }, @@ -319,7 +333,7 @@ }, { "cell_type": "markdown", - "id": "0bae7ab8", + "id": "19491ff6", "metadata": { "editable": true }, @@ -341,7 +355,7 @@ }, { "cell_type": "markdown", - "id": "43d3580d", + "id": "d8331c32", "metadata": { "editable": true }, @@ -353,7 +367,7 @@ }, { "cell_type": "markdown", - "id": "342271f8", + "id": "e1c4f171", "metadata": { "editable": true }, @@ -366,7 +380,7 @@ }, { "cell_type": "markdown", - "id": "23469bef", + "id": "13f61d69", "metadata": { "editable": true }, @@ -378,7 +392,7 @@ }, { "cell_type": "markdown", - "id": "9efdf6d1", + "id": "99b96b03", "metadata": { "editable": true }, @@ -390,7 +404,7 @@ }, { "cell_type": "markdown", - "id": "a3a9d6f9", + "id": "c2b27e85", "metadata": { "editable": true }, @@ -402,19 +416,21 @@ }, { "cell_type": "markdown", - "id": "27b5bf11", + "id": "f5b75667", "metadata": { "editable": true }, "source": [ "The difference is non-negative definite since each component of the\n", "matrix product is non-negative definite. \n", - "This means the variance we obtain with the standard OLS will always for $\\lambda > 0$ be larger than the variance of $\\boldsymbol{\\beta}$ obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below." + "This means the variance we obtain with the standard OLS will always for $\\lambda > 0$ be larger than the variance of $\\boldsymbol{\\beta}$ obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below. \n", + "\n", + "For more discussions of Ridge regression and calculation of averages, [Wessel van Wieringen's](https://arxiv.org/abs/1509.09169) article is highly recommended." ] }, { "cell_type": "markdown", - "id": "c307a6f7", + "id": "7f5ff40a", "metadata": { "editable": true }, @@ -424,7 +440,7 @@ }, { "cell_type": "markdown", - "id": "e80b1779", + "id": "220f7410", "metadata": { "editable": true }, @@ -447,7 +463,7 @@ }, { "cell_type": "markdown", - "id": "2cf13647", + "id": "359441fa", "metadata": { "editable": true }, @@ -459,7 +475,7 @@ }, { "cell_type": "markdown", - "id": "3b05ebc3", + "id": "de51ae81", "metadata": { "editable": true }, @@ -472,7 +488,7 @@ }, { "cell_type": "markdown", - "id": "b3174320", + "id": "efde679c", "metadata": { "editable": true }, @@ -484,7 +500,7 @@ }, { "cell_type": "markdown", - "id": "c26303cd", + "id": "dfdfdc22", "metadata": { "editable": true }, @@ -496,7 +512,7 @@ }, { "cell_type": "markdown", - "id": "ecae9f3a", + "id": "97e70afc", "metadata": { "editable": true }, @@ -508,7 +524,7 @@ }, { "cell_type": "markdown", - "id": "cfc8dc94", + "id": "3a6b38b6", "metadata": { "editable": true }, @@ -519,7 +535,7 @@ }, { "cell_type": "markdown", - "id": "9fc233c8", + "id": "e83f98cd", "metadata": { "editable": true }, @@ -531,7 +547,7 @@ }, { "cell_type": "markdown", - "id": "18147119", + "id": "9f4c2e6b", "metadata": { "editable": true }, @@ -542,7 +558,7 @@ }, { "cell_type": "markdown", - "id": "22b62bbd", + "id": "72e617a0", "metadata": { "editable": true }, @@ -554,7 +570,7 @@ }, { "cell_type": "markdown", - "id": "737e25bf", + "id": "9ea2d900", "metadata": { "editable": true }, @@ -564,7 +580,7 @@ }, { "cell_type": "markdown", - "id": "a1ab690a", + "id": "7d09b114", "metadata": { "editable": true }, @@ -595,7 +611,7 @@ }, { "cell_type": "markdown", - "id": "3374f736", + "id": "dd6500ad", "metadata": { "editable": true }, @@ -607,7 +623,7 @@ }, { "cell_type": "markdown", - "id": "744753bc", + "id": "4af29a16", "metadata": { "editable": true }, @@ -619,7 +635,7 @@ }, { "cell_type": "markdown", - "id": "aaddf4e3", + "id": "7ead95ed", "metadata": { "editable": true }, @@ -629,7 +645,7 @@ }, { "cell_type": "markdown", - "id": "b0cf31d0", + "id": "67fb8467", "metadata": { "editable": true }, @@ -641,7 +657,7 @@ }, { "cell_type": "markdown", - "id": "cada4348", + "id": "24a5cd8c", "metadata": { "editable": true }, @@ -651,7 +667,7 @@ }, { "cell_type": "markdown", - "id": "e046eb3c", + "id": "ed820729", "metadata": { "editable": true }, @@ -663,7 +679,7 @@ }, { "cell_type": "markdown", - "id": "1d2a0989", + "id": "365fb5fa", "metadata": { "editable": true }, @@ -673,7 +689,7 @@ }, { "cell_type": "markdown", - "id": "cb565693", + "id": "bd7855ac", "metadata": { "editable": true }, @@ -685,7 +701,7 @@ }, { "cell_type": "markdown", - "id": "25068a42", + "id": "9e29025f", "metadata": { "editable": true }, @@ -695,7 +711,7 @@ }, { "cell_type": "markdown", - "id": "b3721117", + "id": "1b8037cd", "metadata": { "editable": true }, @@ -715,7 +731,7 @@ }, { "cell_type": "markdown", - "id": "f03dba42", + "id": "0ccdc885", "metadata": { "editable": true }, @@ -727,7 +743,7 @@ }, { "cell_type": "markdown", - "id": "c3e1b9dc", + "id": "847e622f", "metadata": { "editable": true }, @@ -737,7 +753,7 @@ }, { "cell_type": "markdown", - "id": "f2d3df3c", + "id": "ee751166", "metadata": { "editable": true }, @@ -749,7 +765,7 @@ }, { "cell_type": "markdown", - "id": "17833b8f", + "id": "be7cff70", "metadata": { "editable": true }, @@ -761,7 +777,7 @@ }, { "cell_type": "markdown", - "id": "d2edb005", + "id": "d36dd303", "metadata": { "editable": true }, @@ -773,7 +789,7 @@ }, { "cell_type": "markdown", - "id": "0e6a552a", + "id": "26f65c8e", "metadata": { "editable": true }, @@ -785,7 +801,7 @@ }, { "cell_type": "markdown", - "id": "1da77c5c", + "id": "6845bdf4", "metadata": { "editable": true }, @@ -797,7 +813,7 @@ }, { "cell_type": "markdown", - "id": "dfd3cd9c", + "id": "d570e83d", "metadata": { "editable": true }, @@ -809,7 +825,7 @@ }, { "cell_type": "markdown", - "id": "984f95fe", + "id": "ff9d6f1b", "metadata": { "editable": true }, @@ -821,7 +837,7 @@ }, { "cell_type": "markdown", - "id": "57251306", + "id": "c46a8a6c", "metadata": { "editable": true }, @@ -833,7 +849,7 @@ }, { "cell_type": "markdown", - "id": "059fd08b", + "id": "f87663f8", "metadata": { "editable": true }, @@ -843,7 +859,7 @@ }, { "cell_type": "markdown", - "id": "647e2bd0", + "id": "25463a43", "metadata": { "editable": true }, @@ -855,7 +871,7 @@ }, { "cell_type": "markdown", - "id": "79e37adb", + "id": "9fda9c4b", "metadata": { "editable": true }, @@ -865,7 +881,7 @@ }, { "cell_type": "markdown", - "id": "1d2d71f6", + "id": "b72296af", "metadata": { "editable": true }, @@ -884,7 +900,7 @@ }, { "cell_type": "markdown", - "id": "c979c88d", + "id": "c0f70cb6", "metadata": { "editable": true }, @@ -905,7 +921,7 @@ }, { "cell_type": "markdown", - "id": "39e28f06", + "id": "ec5a065c", "metadata": { "editable": true }, @@ -917,7 +933,7 @@ }, { "cell_type": "markdown", - "id": "cd2b7d95", + "id": "03a88654", "metadata": { "editable": true }, @@ -928,7 +944,7 @@ }, { "cell_type": "markdown", - "id": "ec1b5947", + "id": "e566862a", "metadata": { "editable": true }, @@ -941,7 +957,7 @@ }, { "cell_type": "markdown", - "id": "adbf2eaa", + "id": "eb5c1596", "metadata": { "editable": true }, @@ -953,7 +969,7 @@ }, { "cell_type": "markdown", - "id": "1edba656", + "id": "abe58c1e", "metadata": { "editable": true }, @@ -963,7 +979,7 @@ }, { "cell_type": "markdown", - "id": "77f11061", + "id": "8e1b19e3", "metadata": { "editable": true }, @@ -975,7 +991,7 @@ }, { "cell_type": "markdown", - "id": "7adf60b2", + "id": "d3cacca7", "metadata": { "editable": true }, @@ -985,7 +1001,7 @@ }, { "cell_type": "markdown", - "id": "e4ba6d40", + "id": "37dfb75b", "metadata": { "editable": true }, @@ -997,7 +1013,7 @@ }, { "cell_type": "markdown", - "id": "d4825ca0", + "id": "af07f8e1", "metadata": { "editable": true }, @@ -1007,7 +1023,7 @@ }, { "cell_type": "markdown", - "id": "90fd46f6", + "id": "3b6b522c", "metadata": { "editable": true }, @@ -1021,7 +1037,7 @@ }, { "cell_type": "markdown", - "id": "0b654143", + "id": "6f4051af", "metadata": { "editable": true }, @@ -1033,7 +1049,7 @@ }, { "cell_type": "markdown", - "id": "f1805911", + "id": "4597eb7b", "metadata": { "editable": true }, @@ -1043,7 +1059,7 @@ }, { "cell_type": "markdown", - "id": "95ce6429", + "id": "d482cbef", "metadata": { "editable": true }, @@ -1055,7 +1071,7 @@ }, { "cell_type": "markdown", - "id": "f1dabb09", + "id": "02873be9", "metadata": { "editable": true }, @@ -1065,7 +1081,7 @@ }, { "cell_type": "markdown", - "id": "2c6159db", + "id": "339ec806", "metadata": { "editable": true }, @@ -1077,7 +1093,7 @@ }, { "cell_type": "markdown", - "id": "6c646f2b", + "id": "b34d5a32", "metadata": { "editable": true }, @@ -1087,7 +1103,7 @@ }, { "cell_type": "markdown", - "id": "601b1f4a", + "id": "e9597501", "metadata": { "editable": true }, @@ -1099,7 +1115,7 @@ }, { "cell_type": "markdown", - "id": "a76fed44", + "id": "690252a2", "metadata": { "editable": true }, @@ -1109,7 +1125,7 @@ }, { "cell_type": "markdown", - "id": "704790b3", + "id": "4e65aba5", "metadata": { "editable": true }, @@ -1125,7 +1141,7 @@ }, { "cell_type": "markdown", - "id": "cba445ab", + "id": "0e959d5b", "metadata": { "editable": true }, @@ -1137,7 +1153,7 @@ }, { "cell_type": "markdown", - "id": "78799c01", + "id": "9c2b57ea", "metadata": { "editable": true }, @@ -1147,7 +1163,7 @@ }, { "cell_type": "markdown", - "id": "95301efa", + "id": "33753cbf", "metadata": { "editable": true }, @@ -1159,7 +1175,7 @@ }, { "cell_type": "markdown", - "id": "aadd27d4", + "id": "7a7c13ee", "metadata": { "editable": true }, @@ -1172,7 +1188,7 @@ }, { "cell_type": "markdown", - "id": "f5c0865e", + "id": "43c1af38", "metadata": { "editable": true }, @@ -1184,7 +1200,7 @@ }, { "cell_type": "markdown", - "id": "079ec95a", + "id": "eb1d8208", "metadata": { "editable": true }, @@ -1194,7 +1210,7 @@ }, { "cell_type": "markdown", - "id": "0a400711", + "id": "3a4d823a", "metadata": { "editable": true }, @@ -1206,7 +1222,7 @@ }, { "cell_type": "markdown", - "id": "68aa28b8", + "id": "3b7843f3", "metadata": { "editable": true }, @@ -1216,7 +1232,7 @@ }, { "cell_type": "markdown", - "id": "231e2cd3", + "id": "3bb6c2a2", "metadata": { "editable": true }, @@ -1228,7 +1244,7 @@ }, { "cell_type": "markdown", - "id": "30439f67", + "id": "49df5689", "metadata": { "editable": true }, @@ -1240,7 +1256,7 @@ }, { "cell_type": "markdown", - "id": "e098ebf4", + "id": "f5762104", "metadata": { "editable": true }, @@ -1250,7 +1266,7 @@ }, { "cell_type": "markdown", - "id": "1a650147", + "id": "78d098f6", "metadata": { "editable": true }, @@ -1262,7 +1278,7 @@ }, { "cell_type": "markdown", - "id": "45268f44", + "id": "21e5c34e", "metadata": { "editable": true }, @@ -1274,7 +1290,7 @@ }, { "cell_type": "markdown", - "id": "3bb57d62", + "id": "af23961f", "metadata": { "editable": true }, @@ -1286,7 +1302,7 @@ }, { "cell_type": "markdown", - "id": "85f17bee", + "id": "dcb35147", "metadata": { "editable": true }, @@ -1296,7 +1312,7 @@ }, { "cell_type": "markdown", - "id": "2593323c", + "id": "d055dad4", "metadata": { "editable": true }, @@ -1308,7 +1324,7 @@ }, { "cell_type": "markdown", - "id": "2b9db4cf", + "id": "7d68d8af", "metadata": { "editable": true }, @@ -1318,7 +1334,7 @@ }, { "cell_type": "markdown", - "id": "18c3feaa", + "id": "886c23d9", "metadata": { "editable": true }, @@ -1337,7 +1353,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "867b9beb", + "id": "d85e186c", "metadata": { "collapsed": false, "editable": true @@ -1413,7 +1429,7 @@ }, { "cell_type": "markdown", - "id": "d7c84a02", + "id": "92320794", "metadata": { "editable": true }, @@ -1423,7 +1439,7 @@ }, { "cell_type": "markdown", - "id": "4d30306e", + "id": "34f0f009", "metadata": { "editable": true }, @@ -1453,7 +1469,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "552d035f", + "id": "73338e5e", "metadata": { "collapsed": false, "editable": true @@ -1502,7 +1518,7 @@ }, { "cell_type": "markdown", - "id": "6f096159", + "id": "e82b4efa", "metadata": { "editable": true }, @@ -1521,7 +1537,7 @@ }, { "cell_type": "markdown", - "id": "2cf4e58f", + "id": "a48bc8bd", "metadata": { "editable": true }, @@ -1549,7 +1565,7 @@ }, { "cell_type": "markdown", - "id": "7a0f155f", + "id": "07a08246", "metadata": { "editable": true }, @@ -1575,7 +1591,7 @@ }, { "cell_type": "markdown", - "id": "45743608", + "id": "48eafe81", "metadata": { "editable": true }, @@ -1592,7 +1608,7 @@ }, { "cell_type": "markdown", - "id": "9733f49c", + "id": "f2ffd411", "metadata": { "editable": true }, @@ -1612,7 +1628,7 @@ }, { "cell_type": "markdown", - "id": "e6bad6a2", + "id": "a8560d24", "metadata": { "editable": true }, @@ -1641,7 +1657,7 @@ }, { "cell_type": "markdown", - "id": "2890adbe", + "id": "ad73c1f3", "metadata": { "editable": true }, @@ -1666,7 +1682,7 @@ }, { "cell_type": "markdown", - "id": "b3e094d1", + "id": "dba4d0b3", "metadata": { "editable": true }, @@ -1686,7 +1702,7 @@ }, { "cell_type": "markdown", - "id": "009e18db", + "id": "ffea99bd", "metadata": { "editable": true }, @@ -1698,7 +1714,7 @@ }, { "cell_type": "markdown", - "id": "ede1f63d", + "id": "80240e41", "metadata": { "editable": true }, @@ -1708,7 +1724,7 @@ }, { "cell_type": "markdown", - "id": "0520172f", + "id": "a726a2ed", "metadata": { "editable": true }, @@ -1723,7 +1739,7 @@ }, { "cell_type": "markdown", - "id": "430fc1bb", + "id": "47f6f97f", "metadata": { "editable": true }, @@ -1736,7 +1752,7 @@ }, { "cell_type": "markdown", - "id": "ea20567c", + "id": "8169ea64", "metadata": { "editable": true }, @@ -1749,7 +1765,7 @@ }, { "cell_type": "markdown", - "id": "5080a638", + "id": "4ea3d00d", "metadata": { "editable": true }, @@ -1761,7 +1777,7 @@ }, { "cell_type": "markdown", - "id": "0e83403d", + "id": "4a56b729", "metadata": { "editable": true }, @@ -1774,7 +1790,7 @@ }, { "cell_type": "markdown", - "id": "e4061590", + "id": "f06605f3", "metadata": { "editable": true }, @@ -1785,7 +1801,7 @@ }, { "cell_type": "markdown", - "id": "0dc0bc33", + "id": "bfbff4b0", "metadata": { "editable": true }, @@ -1799,7 +1815,7 @@ }, { "cell_type": "markdown", - "id": "38251e33", + "id": "bf027c40", "metadata": { "editable": true }, @@ -1809,7 +1825,7 @@ }, { "cell_type": "markdown", - "id": "ede3119e", + "id": "1a6c358c", "metadata": { "editable": true }, @@ -1823,7 +1839,7 @@ }, { "cell_type": "markdown", - "id": "8d066bd8", + "id": "ca21ac8a", "metadata": { "editable": true }, @@ -1836,7 +1852,7 @@ }, { "cell_type": "markdown", - "id": "ddaa8ed1", + "id": "e2a2138c", "metadata": { "editable": true }, @@ -1849,7 +1865,7 @@ }, { "cell_type": "markdown", - "id": "823aac27", + "id": "0fe07df0", "metadata": { "editable": true }, @@ -1859,7 +1875,7 @@ }, { "cell_type": "markdown", - "id": "0be0e1d1", + "id": "b7065082", "metadata": { "editable": true }, @@ -1872,7 +1888,7 @@ }, { "cell_type": "markdown", - "id": "767214ea", + "id": "f30c25d1", "metadata": { "editable": true }, @@ -1882,7 +1898,7 @@ }, { "cell_type": "markdown", - "id": "e8e438ee", + "id": "ceabbf5a", "metadata": { "editable": true }, @@ -1895,7 +1911,7 @@ }, { "cell_type": "markdown", - "id": "6614b12e", + "id": "bf4192c1", "metadata": { "editable": true }, @@ -1907,7 +1923,7 @@ }, { "cell_type": "markdown", - "id": "e0c4c291", + "id": "bdea26d3", "metadata": { "editable": true }, @@ -1926,7 +1942,7 @@ }, { "cell_type": "markdown", - "id": "9ace0ff1", + "id": "7b7b7cd5", "metadata": { "editable": true }, @@ -1939,7 +1955,7 @@ }, { "cell_type": "markdown", - "id": "0c2f955c", + "id": "36798a32", "metadata": { "editable": true }, @@ -1951,7 +1967,7 @@ }, { "cell_type": "markdown", - "id": "662e0ef6", + "id": "050a629e", "metadata": { "editable": true }, @@ -1964,7 +1980,7 @@ }, { "cell_type": "markdown", - "id": "de544526", + "id": "379954a2", "metadata": { "editable": true }, @@ -1984,7 +2000,7 @@ }, { "cell_type": "markdown", - "id": "205e21f3", + "id": "11f4eb37", "metadata": { "editable": true }, @@ -2007,7 +2023,7 @@ }, { "cell_type": "markdown", - "id": "684800bc", + "id": "39758f21", "metadata": { "editable": true }, @@ -2022,7 +2038,7 @@ }, { "cell_type": "markdown", - "id": "f5371b42", + "id": "0df0f9da", "metadata": { "editable": true }, @@ -2034,7 +2050,7 @@ }, { "cell_type": "markdown", - "id": "1af4951a", + "id": "afab14dd", "metadata": { "editable": true }, @@ -2054,7 +2070,7 @@ }, { "cell_type": "markdown", - "id": "09c395b4", + "id": "f660896d", "metadata": { "editable": true }, @@ -2074,7 +2090,7 @@ }, { "cell_type": "markdown", - "id": "6adf425e", + "id": "ae5dbbb7", "metadata": { "editable": true }, @@ -2098,7 +2114,7 @@ }, { "cell_type": "markdown", - "id": "33684bab", + "id": "8c7d89fd", "metadata": { "editable": true }, @@ -2119,7 +2135,7 @@ }, { "cell_type": "markdown", - "id": "93afbfce", + "id": "007fc517", "metadata": { "editable": true }, @@ -2149,7 +2165,7 @@ }, { "cell_type": "markdown", - "id": "b83a6f7b", + "id": "ffa15f0f", "metadata": { "editable": true }, @@ -2173,7 +2189,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "835031da", + "id": "148980bb", "metadata": { "collapsed": false, "editable": true @@ -2210,7 +2226,7 @@ }, { "cell_type": "markdown", - "id": "5c4a77ee", + "id": "50102556", "metadata": { "editable": true }, @@ -2220,7 +2236,7 @@ }, { "cell_type": "markdown", - "id": "16122555", + "id": "3270ab07", "metadata": { "editable": true }, @@ -2231,7 +2247,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "ee3efc1f", + "id": "79a91fd5", "metadata": { "collapsed": false, "editable": true @@ -2251,7 +2267,7 @@ }, { "cell_type": "markdown", - "id": "805384cc", + "id": "3ef95383", "metadata": { "editable": true }, @@ -2269,7 +2285,7 @@ }, { "cell_type": "markdown", - "id": "dcf35e1c", + "id": "052ad629", "metadata": { "editable": true }, @@ -2281,7 +2297,7 @@ }, { "cell_type": "markdown", - "id": "a54f68f6", + "id": "679bcbe9", "metadata": { "editable": true }, @@ -2298,7 +2314,7 @@ }, { "cell_type": "markdown", - "id": "d12f2d9f", + "id": "d1e190f6", "metadata": { "editable": true }, @@ -2310,7 +2326,7 @@ }, { "cell_type": "markdown", - "id": "d579339a", + "id": "c7900d3e", "metadata": { "editable": true }, @@ -2320,7 +2336,7 @@ }, { "cell_type": "markdown", - "id": "23cfe14f", + "id": "a3037a95", "metadata": { "editable": true }, @@ -2332,7 +2348,7 @@ }, { "cell_type": "markdown", - "id": "340d3a87", + "id": "2ebea5d5", "metadata": { "editable": true }, @@ -2349,7 +2365,7 @@ }, { "cell_type": "markdown", - "id": "c3b4b4e1", + "id": "53873c37", "metadata": { "editable": true }, @@ -2361,7 +2377,7 @@ }, { "cell_type": "markdown", - "id": "2e287a3a", + "id": "e3c28704", "metadata": { "editable": true }, @@ -2371,7 +2387,7 @@ }, { "cell_type": "markdown", - "id": "aa7081f3", + "id": "54aedc50", "metadata": { "editable": true }, @@ -2383,7 +2399,7 @@ }, { "cell_type": "markdown", - "id": "7e59cf97", + "id": "45da140f", "metadata": { "editable": true }, @@ -2393,7 +2409,7 @@ }, { "cell_type": "markdown", - "id": "c714fdf8", + "id": "a3718cb8", "metadata": { "editable": true }, @@ -2405,7 +2421,7 @@ }, { "cell_type": "markdown", - "id": "d4e5a1cf", + "id": "cee0f294", "metadata": { "editable": true }, @@ -2415,7 +2431,7 @@ }, { "cell_type": "markdown", - "id": "c1d8da6e", + "id": "9ad0456d", "metadata": { "editable": true }, @@ -2431,7 +2447,7 @@ }, { "cell_type": "markdown", - "id": "66c36e93", + "id": "48f6b197", "metadata": { "editable": true }, @@ -2442,7 +2458,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "f61025ec", + "id": "e763164f", "metadata": { "collapsed": false, "editable": true @@ -2507,7 +2523,7 @@ }, { "cell_type": "markdown", - "id": "4d672738", + "id": "c61c9a39", "metadata": { "editable": true }, @@ -2518,7 +2534,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "a33e8bfa", + "id": "dbaa91c0", "metadata": { "collapsed": false, "editable": true @@ -2575,7 +2591,7 @@ }, { "cell_type": "markdown", - "id": "a8985ebd", + "id": "92b2b3b4", "metadata": { "editable": true }, @@ -2613,7 +2629,7 @@ }, { "cell_type": "markdown", - "id": "00397c67", + "id": "ea30e4f6", "metadata": { "editable": true }, @@ -2624,7 +2640,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "502dd405", + "id": "bdf694bb", "metadata": { "collapsed": false, "editable": true @@ -2706,7 +2722,7 @@ }, { "cell_type": "markdown", - "id": "cb0bf1e6", + "id": "945905cd", "metadata": { "editable": true }, @@ -2731,7 +2747,7 @@ }, { "cell_type": "markdown", - "id": "3e645104", + "id": "e17e6eb9", "metadata": { "editable": true }, @@ -2759,7 +2775,7 @@ }, { "cell_type": "markdown", - "id": "3282f57f", + "id": "31961c30", "metadata": { "editable": true }, @@ -2772,7 +2788,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "565a4b4c", + "id": "870e0bac", "metadata": { "collapsed": false, "editable": true @@ -2872,7 +2888,7 @@ }, { "cell_type": "markdown", - "id": "bdf27fbc", + "id": "e2b755f5", "metadata": { "editable": true }, @@ -2883,7 +2899,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "136ba5cc", + "id": "55fb097e", "metadata": { "collapsed": false, "editable": true @@ -2972,7 +2988,7 @@ }, { "cell_type": "markdown", - "id": "fe903555", + "id": "84f9c9d4", "metadata": { "editable": true }, @@ -2982,7 +2998,7 @@ }, { "cell_type": "markdown", - "id": "87d0482f", + "id": "ddbfdfd5", "metadata": { "editable": true }, @@ -2995,7 +3011,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "d68a2217", + "id": "fc0518f6", "metadata": { "collapsed": false, "editable": true diff --git a/doc/src/week37/exercisesweek37.do.txt b/doc/src/week37/exercisesweek37.do.txt index 50e915e90..1b5d34a24 100644 --- a/doc/src/week37/exercisesweek37.do.txt +++ b/doc/src/week37/exercisesweek37.do.txt @@ -8,7 +8,7 @@ DATE: Deadline is Sunday September 17 at midnight This exercise deals with various mean values and variances in linear regression method (here it may be useful to look up chapter 3, equation (3.8) of "Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer":"https://www.springer.com/gp/book/9780387848570"). The exercise is also a part of project 1 and can be reused in the theory part of the project. - +For more discussions on Ridge regression and calculation of expectation values, "Wessel van Wieringen's":"https://arxiv.org/abs/1509.09169" article is highly recommended. The assumption we have made is diff --git a/doc/src/week37/week37.do.txt b/doc/src/week37/week37.do.txt index 6b659df0a..b0603c151 100644 --- a/doc/src/week37/week37.do.txt +++ b/doc/src/week37/week37.do.txt @@ -13,16 +13,15 @@ DATE: today * Exercise for week 37 * Work on project 1 * See also additional note on scaling (jupyter-notebook) sent separately. This will be discussed during the first hour of each session. + * For more discussions of Ridge regression and calculation of averages, "Wessel van Wieringen's":"https://arxiv.org/abs/1509.09169" article is highly recommended. !eblock !bblock Material for the lecture on Thursday September 7 * Statistical interpretation of Ridge and Lasso regression * Resampling techniques, Bootstrap and cross validation and bias-variance tradeoff - * Recommended Reading: - o Lectures on Resampling methods (these lectures) - o Bishop 1.3 (cross-validation) and 3.2 (bias-variance tradeoff) + * Reads and Videos: o Hastie et al Chapter 7, here we recommend 7.1-7.5 and 7.10 (cross-validation) and 7.11 (bootstrap). - * "Video on cross validation":"https://www.youtube.com/watch?v=fSytzGwwBVw" - * "Video on bias-variance tradeoff":"https://www.youtube.com/watch?v=EuBBz3bI-aA" + o "Video on cross validation":"https://www.youtube.com/watch?v=fSytzGwwBVw" + o "Video on bias-variance tradeoff":"https://www.youtube.com/watch?v=EuBBz3bI-aA" !eblock @@ -201,6 +200,7 @@ The difference is non-negative definite since each component of the matrix product is non-negative definite. This means the variance we obtain with the standard OLS will always for $\lambda > 0$ be larger than the variance of $\bm{\beta}$ obtained with the Ridge estimator. This has interesting consequences when we discuss the so-called bias-variance trade-off below. +For more discussions of Ridge regression and calculation of averages, "Wessel van Wieringen's":"https://arxiv.org/abs/1509.09169" article is highly recommended. !split