final Bayes stuff
This commit is contained in:
@@ -1127,7 +1127,7 @@ In the more general case the various inputs should be replaced by the possible f
|
||||
We can now rewrite the above probability as
|
||||
!bt
|
||||
\[
|
||||
p(\bm{D}\vert\bm{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\bm{X}_{i,*}\bm{\beta})^2}{2\sigma^2}\right]}..
|
||||
p(\bm{D}\vert\bm{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\bm{X}_{i,*}\bm{\beta})^2}{2\sigma^2}\right]}.
|
||||
\]
|
||||
!et
|
||||
|
||||
@@ -1441,7 +1441,7 @@ For ordinary least squares we postulated that the maximum likelihood for the doa
|
||||
is given by
|
||||
!bt
|
||||
\[
|
||||
p(\bm{D}\vert\bm{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\bm{X}_{i,*}\bm{\beta})^2}{2\sigma^2}\right]}..
|
||||
p(\bm{D}\vert\bm{\beta})=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\bm{X}_{i,*}\bm{\beta})^2}{2\sigma^2}\right]}.
|
||||
\]
|
||||
!et
|
||||
|
||||
@@ -1463,6 +1463,86 @@ p(\bm{\beta}\vert\bm{D})\propto p(\bm{D}\vert\bm{\beta})p(\bm{\beta}).
|
||||
We have a model for $p(\bm{D}\vert\bm{\beta})$ but need one for the _prior_ $p(\bm{\beta}$!
|
||||
|
||||
|
||||
!split
|
||||
===== Ridge and Bayes =====
|
||||
|
||||
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 $\bm{\beta}$ and the mean value, assume that the prior for the values $\bm{\beta}$ is given by a Gaussian with mean value zero and variance $\tau^2$, that is
|
||||
|
||||
!bt
|
||||
\[
|
||||
p(\bm{\beta})=\prod_{j=0}^{p-1}\exp{-(\frac{\beta_j^2}{2\tau^2}}.
|
||||
\]
|
||||
!et
|
||||
|
||||
Our posterior probability becomes then (omitting the normalization factor which is just a constant)
|
||||
!bt
|
||||
\[
|
||||
p(\bm{\beta}=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\bm{X}_{i,*}\bm{\beta})^2}{2\sigma^2}\right]}\prod_{j=0}^{p-1}\exp{-(\frac{\beta_j^2}{2\tau^2}}.
|
||||
\]
|
||||
!et
|
||||
|
||||
|
||||
We can now optimize this quantity with respect to $\bm{\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
|
||||
|
||||
|
||||
!bt
|
||||
\[
|
||||
C(\bm{\beta}=\frac{n}{2}\log{2\pi\sigma^2}+\frac{\vert\vert (\bm{y}-\bm{X}\bm{\beta})\vert\vert_2^2}{2\sigma^2}+\frac{1}{2\tau^2}\vert\vert\bm{\beta}\vert\vert_2^2,
|
||||
\]
|
||||
!et
|
||||
and replacing $1/2\tau^2$ with $\lambda$ we have
|
||||
|
||||
!bt
|
||||
\[
|
||||
C(\bm{\beta}=\frac{n}{2}\log{2\pi\sigma^2}+\frac{\vert\vert (\bm{y}-\bm{X}\bm{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\bm{\beta}\vert\vert_2^2,
|
||||
\]
|
||||
!et
|
||||
which is our Ridge cost function! Nice, isn't it?
|
||||
|
||||
!split
|
||||
===== Lasso and Bayes =====
|
||||
|
||||
To derive the Lasso cost function, we simply replace the Gaussian prior with an exponential distribution ("Laplace in this case":"https://en.wikipedia.org/wiki/Laplace_distribution") with zero mean value, that is
|
||||
|
||||
!bt
|
||||
\[
|
||||
p(\bm{\beta})=\prod_{j=0}^{p-1}\exp{-(\frac{\vert\beta_j\vert}{\tau}}.
|
||||
\]
|
||||
!et
|
||||
|
||||
Our posterior probability becomes then (omitting the normalization factor which is just a constant)
|
||||
!bt
|
||||
\[
|
||||
p(\bm{\beta}=\prod_{i=0}^{n-1}\frac{1}{\sqrt{2\pi\sigma^2}}\exp{\left[-\frac{(y_i-\bm{X}_{i,*}\bm{\beta})^2}{2\sigma^2}\right]}\prod_{j=0}^{p-1}\exp{-(\frac{\vert\beta_j\vert}{\tau}}.
|
||||
\]
|
||||
!et
|
||||
|
||||
|
||||
Taking the negative
|
||||
logarithm of the posterior probability and leaving out the
|
||||
constants terms that do not depend on $\beta$, we have
|
||||
|
||||
|
||||
!bt
|
||||
\[
|
||||
C(\bm{\beta}=\frac{n}{2}\log{2\pi\sigma^2}+\frac{\vert\vert (\bm{y}-\bm{X}\bm{\beta})\vert\vert_2^2}{2\sigma^2}+\frac{1}{\tau}\vert\vert\bm{\beta}\vert\vert_1,
|
||||
\]
|
||||
!et
|
||||
and replacing $1/\tau$ with $\lambda$ we have
|
||||
|
||||
!bt
|
||||
\[
|
||||
C(\bm{\beta}=\frac{n}{2}\log{2\pi\sigma^2}+\frac{\vert\vert (\bm{y}-\bm{X}\bm{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\bm{\beta}\vert\vert_1,
|
||||
\]
|
||||
!et
|
||||
which is our Lasso cost function!
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user