Last updated: 2019-08-01
Checks: 2 0
Knit directory: susie-mixture/analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .RData
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.RData
Ignored: analysis/.Rhistory
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view them.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 034283b | Zhengyang Fang | 2019-07-22 | Build site. |
html | 6d9cbaa | Zhengyang Fang | 2019-07-22 | Build site. |
html | 2a474f9 | Zhengyang Fang | 2019-07-22 | Build site. |
html | c72a707 | Zhengyang Fang | 2019-07-22 | Build site. |
html | 8092e5a | Zhengyang Fang | 2019-07-19 | Build site. |
html | 5d3e3ef | Zhengyang Fang | 2019-07-11 | Build site. |
html | 3eee187 | Zhengyang Fang | 2019-07-03 | Build site. |
html | f303e14 | Zhengyang Fang | 2019-07-01 | Build site. |
html | def2b27 | Zhengyang Fang | 2019-06-28 | Build site. |
html | 05f778b | Zhengyang Fang | 2019-06-28 | Build site. |
html | 15c60a7 | Zhengyang Fang | 2019-06-27 | Build site. |
Rmd | 835f959 | Zhengyang Fang | 2019-06-27 | wflow_publish(“reference_summary_VI.Rmd”) |
Consider the linear problem
\[ Y=\beta_0+\sum_{k=1}^p\textbf X_k\beta_k+\epsilon,\epsilon\sim N(0,\sigma^2) \] where the range of \(p\) can be as large as \(10^5\sim 10^6\).
Under the Bayesian setting, we assume the prior distribution of \(\beta_k\) to be a spike-and-slab
prior. And we introduce the indicator variable \(\gamma=(\gamma_1,\gamma_2,\dots,\gamma_k)^T\), \(\gamma_k=0\) indicates \(\beta_k=0~w.p.1\), i.e.\(\beta_k\) is not a true factor. And \(\gamma_k=1\) indicates \(\beta_k\neq 0\), i.e. \(\beta_k\) is a true factor. In the variable selection scenario, our goal is to estimate \(\gamma\), specifically posterior inclusion probabilities
(PIP), which we will define later.
We also assume \(\mathbb P(\gamma_k=1)=\pi\). And for true factors we assume \[ \beta_k|\gamma_k=1\sim N(0,\sigma^2\sigma_\beta^2). \]
The parameters involved: \(\theta=(\sigma^2,\sigma_\beta^2,\pi)\). It turns out that the estimation of \(\gamma\) can be very sensitive to \(\theta\). Therefore, we assume an approriate prior for \(\theta\), and calculate
\[ PIP(k)=\mathbb P(\gamma_k=1|\textbf X,Y)=\frac{\sum_{\gamma_{-k}}\iint \mathbb P(Y,\beta,\gamma_k=1,\gamma_{-k}|\textbf X,\theta)d\beta d\theta}{\sum_{\gamma}\iint\mathbb P(Y,\beta,\gamma|\textbf X,\theta)p(\theta) d\beta d\theta}. \]
Computing PIP
directly will be extremely time-consuming. To sum over \(\gamma\), there are \(2^{p}\) terms in total. It is impossible to compute when \(p\) is large. Not to mention each term is a complex high-dimensional integration (\(\beta\in\mathbb R^p\)).
Variational inference will provide a reasonable approximation to this, so that we don’t have to deal with such a complex problem. We will show the detail of this method in the following sections.
We do importance sampling on the parameters \(\theta=(\sigma^2,\sigma_\beta^2,\pi)\), for each sample:
Step 1. Estimate the variance \(Var(\beta_k|\gamma_k=1)=s_k^2\).
Step 2. Compute PIP
and posterior means with a coordinate-descent method.
Step 3. Estimate the importance weights for each sample with a lowerbound.
The variational inference framework is to approximate the posterior distribution \(f(\beta,\gamma)=\mathbb P(\beta,\gamma|\textbf X,y,\theta)\) by searching for a distribution \(q(\beta,\gamma)\) to minimize the KL-divergence \[ D(q||f)=\int q(\beta,\gamma)\log\frac{q(\beta,\gamma)}{f(\beta,\gamma)}d\beta d\gamma. \] And restrict \(q(\beta,\gamma)\) to be of the form \[ q(\beta,\gamma;\phi)=\prod_{k=1}^p q(\beta_k,\gamma_k,\phi_k). \] (Independent factor assumption)
And the individual factors have the form \[ q(\beta_k,\gamma_k;\phi_k)=\alpha_kN(\beta_k|\mu_k.s_k^2)\mathbb I_{\gamma_k=1}+(1-\alpha_k)\delta_0(\beta_k)\mathbb I_{\gamma_k=0}. \]
This family assumes the factors are independent and each of them has a spike-and-slab
prior. This is the case when \(X^TX\) is diagnal.
We set the partial derivatives to zero and solve for the best parameters. The formula goes as follows.
\[ Var(\beta_k|\gamma_k=1)\approx s^2_k=\frac{\sigma^2}{(\textbf X^T\textbf X)_{kk}+1/\sigma_{\beta}^2}. \]
\[ \mathbb E(\beta_k|\gamma_k=1)\approx \mu_k=\frac{s_k^2}{\sigma^2}\left((\textbf X^Ty)_k-\sum_{j\neq k}(\textbf X^T\textbf X)_{jk}\alpha_j\mu_j\right). \]
\[ \frac{\mathbb P(\gamma_k=1|\textbf X,y,\theta)}{\mathbb P(\gamma_k=0|\textbf X,y,\theta)}\approx \frac{\alpha_k}{1-\alpha_k}=\frac{\pi}{1-\pi}\cdot\frac{s_k}{\sigma_\beta\sigma}\cdot e^{\mu_k^2/(2s_k^2)}. \]
In our algorithm, we keep updating the values via the formulas above, until it converges. This is a coordinate-descent algorithm.
In the importance sampling scheme, the importance weight is \[ w(\theta)=\frac{\mathbb P(y|\textbf X,\theta)p(\theta)}{\tilde p(\theta)}. \]
Where \(p(\theta)\) is the prior of the parameters, and \(\tilde p(\theta)\) is the sampling distribution. These two are easy to get. But \(\mathbb P(y|\textbf X,\theta)\) is intractable for now. We use a lower bound to estimate it.