STAT 638 (Fall 2026), Lecture 22
Overview
Samiran Sinha develops Bayesian linear regression from its likelihood, prior, and posterior building blocks, showing how scalar and multivariate normal posteriors follow from completing the square. He then compares classical and Bayesian regression in R, explains MCMC diagnostics and posterior prediction, demonstrates a custom g-prior sampler, and introduces Bayesian model selection through posterior model probabilities and model averaging.
Key takeaways
- Combining normal likelihood and prior terms adds their precisions: in the scalar case the posterior variance is 1/(A + C), and the mean is (AB + CD)/(A + C).
- For multiple regression coefficients, the same update uses matrix precision, with covariance (B + D)⁻¹; matrix dimensions and multiplication order must be checked carefully.
- Four chains with 3,000 iterations each produce 12,000 draws, but discarding half as warmup leaves 6,000 draws for posterior summaries; effective sample size can be much lower when autocorrelation is high.
- An R-hat near 1 indicates that chains have mixed toward the same posterior distribution, but does not imply independent draws; trace plots and effective sample sizes are also needed.
- Posterior prediction at a fixed predictor vector requires repeatedly drawing parameters from their posterior and then drawing a future outcome conditional on those parameters.
- Bayesian model selection can either choose the model with the highest posterior probability or average estimates across models using posterior model probabilities as weights.
Chapters
- Sinha lays out the Bayesian building blocks: likelihood, prior distribution, posterior distribution, posterior summaries, and posterior predictive distribution.
- Linear regression links a numeric outcome to explanatory variables and provides a foundation for models with binary, count, or categorical outcomes.
- The lecture focuses on completing the square to derive conditional distributions for regression parameters.
- Multiplying two quadratic exponential terms yields a posterior whose precision is the sum of the two precisions, denoted A + C.
- The resulting normal posterior has variance 1/(A + C) and mean (AB + CD)/(A + C), where B and D are the component means.
- The scalar derivation shows how combining a normal likelihood and normal prior produces a normal posterior.
- For vector parameters, the scalar precisions become symmetric positive definite matrices, and the combined posterior covariance is (B + D)⁻¹.
- The posterior mean is (B + D)⁻¹(BA + DC), using Sinha's vector notation for the two quadratic terms.
- Matrix dimensions and multiplication order matter in the vector derivation, unlike scalar multiplication.
- The same normal-update structure applies to the vector of regression coefficients in a multiple-predictor model.
- Classical regression tests whether an individual coefficient equals zero using its t statistic and corresponding p-value.
- Sinha fits a Gaussian regression with the R function stan_glm, four MCMC chains, and 3,000 iterations per chain.
- The coefficient and intercept priors are Normal(0, 10); the prior for the residual variance is left to the package default.
- With flexible priors, Bayesian posterior estimates are expected to be broadly similar to classical estimates when model assumptions hold.
- The Stan output reports posterior means, Monte Carlo standard errors, effective sample sizes, and R-hat values alongside regression estimates.
- Four chains of 3,000 iterations give 12,000 total draws; with half discarded as warmup, 6,000 draws remain for summaries.
- A smaller effective sample size signals stronger autocorrelation; the residual standard deviation parameter has an effective sample size around 1,725.
- Trace plots and autocorrelation function plots reveal that draws for the residual standard deviation move less freely than draws for regression coefficients.
- R-hat, the Gelman-Rubin potential scale reduction factor, compares variation between chains with variation within chains.
- Sinha cites R-hat values near 1, with 1.01 or lower often used as a satisfactory convergence guideline.
- A chain can converge to the target posterior while still having substantial autocorrelation, so R-hat and effective sample size diagnose different issues.
- High autocorrelation makes sampling less efficient because the chain explores its parameter space slowly.
- A posterior predictive check compares the observed outcome distribution with predictive distributions generated at the observed explanatory-variable values.
- Different predictor settings yield multiple predictive densities; a model with no explanatory variables would instead have one common predictive density.
- For the regression example, Sinha illustrates prediction at settings such as weight 150, age 46, walk time 10 minutes, and heart rate 90.
- Predictive summaries include the median and the 2.5th and 97.5th percentiles.
- The posterior predictive distribution for a future outcome Y-tilde at predictors x₀ is generated by drawing parameters from the posterior, then drawing Y-tilde conditional on x₀ and those parameters.
- Repeating the two-stage draw many times produces predictive samples whose median and percentile interval summarize uncertainty.
- Sinha contrasts stan_glm with the widely used brms package, which uses the NUTS MCMC algorithm for general posterior distributions.
- He advises checking package documentation and default priors, especially the unspecified prior for the residual variance.
- The g-prior sets the regression coefficient prior to a multivariate normal with mean zero and covariance proportional to g times σ²(XᵀX)⁻¹, with an inverse-gamma prior for σ².
- Because the full conditionals are standard distributions, the custom sampler alternates multivariate normal draws for β with inverse-gamma draws for σ².
- Sinha uses a Cholesky decomposition to generate multivariate normal draws and notes that this approach may matter more when the coefficient dimension is near 1,000 than when it is four or five.
- The initial g-prior run gives a suspiciously different intercept estimate, about 24.34 versus about 34.53 in other fits, and an implausibly narrow interval, prompting checks of g, convergence, and the code.
- For candidate models Mₖ with parameter vectors θₖ, the marginal likelihood integrates the model likelihood over the prior for θₖ.
- Posterior model probability is proportional to the prior probability of Mₖ multiplied by its marginal likelihood.
- One strategy selects the model with the largest posterior model probability.
- Model averaging instead combines each model's posterior distribution for a quantity of interest, weighted by that model's posterior probability.
Transcript excerpt
0:01 Sinha, Samiran: Alright, so if you feel that I'm going too slow… Sinha, Samiran: Covering the material, let me know. Sinha, Samiran: And I'm saying it on record. Sinha, Samiran: The reason I'm going slow, because I want you to understand the basics. If you understand the basics. With a very simple model, then you can apply this technique to… to any complex models. Sinha, Samiran: So, just to give you some overview of what we are doing. Sinha, Samiran: is the Bayesian inference, right? Sinha, Samiran: The Bayesian inference. Sinha, Samiran: Now, it has several components, but the building blocks are the following.
1:06 Sinha, Samiran: Likelihood function. Sinha, Samiran: prior distributions. Sinha, Samiran: And that will give you the posterior distribution. Sinha, Samiran: And posterior distributions can be used for. Sinha, Samiran: Calculating different summaries. Sinha, Samiran: and posterior predictive distribution. Sinha, Samiran: distribution.
1:59 Sinha, Samiran: And. Sinha, Samiran: Posterior distribution can be used for? Sinha, Samiran: Model checking, like, marginal likelihood calculation for model checking. Sinha, Samiran: So this is the general philosophy. Sinha, Samiran: We are following. Now, we are in the linear regression part. Linear regression, why I'm spending time on linear regression? This is the basic of any regression. Sinha, Samiran: And regression is, you are making connection between the outcome variable, or the dependent variable, with a set of explanatory variables. Which could be the predictor variables, or independent variables. Sinha, Samiran: And if we understand the basic philosophy or mechanism, then we can apply this technique, linear regression technique.
2:53 Sinha, Samiran: to other models, other models where your outcome is not a numeric outcome, but it is a binary Sinha, Samiran: Or a count outcome, or a categorical outcome. Sinha, Samiran: One thing I found that some students struggle. Sinha, Samiran: For the linear model to figure out the.
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Samiran Sinha.