Last updated: 2020-10-27
Checks: 2 0
Knit directory: misc/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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 results in this page were generated with repository version 5a6cc2a. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
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: .Rhistory
Ignored: .Rproj.user/
Untracked files:
Untracked: analysis/bayeslogit.md
Untracked: analysis/polya_gamma.md
Untracked: code/kowal2019code/
Untracked: code/logistic.R
Unstaged changes:
Modified: analysis/test_typora.md
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 repository in which changes were made to the R Markdown (analysis/bayeslogit.Rmd
) and HTML (docs/bayeslogit.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 5a6cc2a | DongyueXie | 2020-10-27 | wflow_publish(c(“analysis/index.Rmd”, “analysis/kl.Rmd”, “analysis/polya_gamma.Rmd”, |
This paper provides a connection between Jaakkola and Jordan (2000) and Polya-gamma augmentation for logistic regression.
David Blei’s paper, Variational inference: A review for statisticians, has been cited a lot as good VB introduction.(I guess I should re-read it several times, and often). VB tries to find a tractable approximation of the posterir distribution \(p(\theta|y)\) where \(\theta\) is coeffients and \(y\) is observed data.
The approximation is posed as an optimization problem, by minimizing KL divergence, \[ KL(q(\theta)||p(\theta|y)) = \int q(\theta)\log\frac{q(\theta)}{p(\theta|y)}d\theta = \int q(\theta)\log\frac{q(\theta)p(y)}{p(y,\theta)}d\theta. \]
(On why its \(KL(q(\theta)||p(\theta|y))\) instead of \(KL(p(\theta|y)||q(\theta))\))
The evidence lower bound ELBO is \[ELBO(q(\theta)) = \int q(\theta))\log\frac{p(y,\theta)}{q(\theta)} = \log p(y) - KL(q(\theta)||p(\theta|y)) \\= E(\log p(y|\theta)) - KL(q(\theta)||p(\theta))\]
The optimal \(q_j(\theta_j)\) is proportional to the exp expected log of complete likelihood, \[q^*_j(\theta_j)\propto exp\{E_{-j}\log p(\theta_j|\theta_{-j},y)\}.\]
(Why? ELBO\((q_j) = E_j E_{-j}\log p(\theta_j,\theta_{-j},y) - E_j \log q_j(\theta_j)+constant \\= -E_j\log\frac{q_j}{\exp{(E_{-j}\log p(\theta_j,\theta_{-j},y))}}\))
Suppose each complete conditional is in the exponential family \[p(\theta_j|\theta_{-j},y) = h(\theta_j)\exp\{\eta_j(\theta_{-j},y)^T\theta_j - a(\eta_j(\theta_{-j},y))\}\] where \(h\) is a base measure and \(a(\cdot)\) is the log normalizer and \(\eta\) is the canonical parameter.
(The exponential family is \(f(y;\theta,\phi) = \exp\{(y\theta-b(\theta))/a(\phi)+c(y,\phi)\}\). If the dispersion parameter \(\phi\) is known, this is an exponential family model with canonical parameter \(\theta\). often \(a(\phi)=1\), \(c(y,\phi) = c(y)\))
Then the update is \[q_j(\theta_j)\propto \exp\{\log h(\theta_j)+E(\eta_j(\theta_{-j},y))^T\theta_j - E(a(\eta_j(\theta_{-j},y)))\} \\ \propto h(\theta_j)\exp\{E(\eta_j(\theta_{-j},y))^T\theta_j\}\]
Let \(\beta\) be the global coefficients and \(z\) be the local variables, and \(y\) the observed data, then the joint distribution of \(y,\beta,z\) is \[p(y,\beta,z) = p(\beta)\Pi_i p(z_i|\beta)p(y_i|z_i,\beta) = p(\beta)\Pi_i p(y_i,z_i|\beta)\] where \(\Pi_i p(y_i,z_i|\beta)\) is from an exponential family and \(p(\beta)\) is a conjugate prior for the density.