Last updated: 2025-03-05

Checks: 2 0

Knit directory: fiveMinuteStats/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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 1352fc2. 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:


working directory clean

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/variational_inference.Rmd) and HTML (docs/variational_inference.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 1352fc2 Peter Carbonetto 2025-03-05 workflowr::wflow_publish("variational_inference.Rmd", verbose = TRUE)
Rmd e1a2bea Peter Carbonetto 2025-03-05 workflowr::wflow_publish("index.Rmd")

Prerequisites

Prerequisites will go here.

  • MCMC sampling (and specifically Gibbs sampling) will be used to illustrate some of the key ideas so you should be familiar with those.

Introduction

Add introduction here.

Ridge regression

We will use the ridge regression model as our running example to illustrate the use of variational inference to perform posterior inferences. Although variational inference methods aren’t really needed because the math works out very well for this model, its convenient mathematical properties will be helpful for understanding the variational approximations since we can compare the approximations to the exact calculations.

Although you may have seen the ridge regression model elsewhere, it hasn’t been introduced in another of the other fiveMinuteStats vignettes, so we will briefly (re)introduce it here.

Ridge regression can be introduced in different ways. Here we will view it as a Bayesian model (with a likelihood and a prior, and our interest is in performing posterior inferences using this model).

We start with a standard linear regression model: \[ y_i \sim N(\mathbf{x}_i^T\mathbf{b}, \sigma^2), \quad i = 1, \ldots, n. \]

Here, \(i\) is a sample, and the data for sample \(i\) are the output \(y_i\) and the \(p\) inputs \(x_{i1}, \ldots, x_{ip}\) stored as a vector \(\mathbf{x}_i\). Typically one also includes an intercept term, and we will ignore this detail here for simplicity (noting that it is easy to add without fundamentally changing the math).

Give posterior mean and posterior covariance matrix.


This site was created with R Markdown