Session Ready
Exercise

Fit a Bayesian GLM

Bayesian statistical models return samples of the parameters of interest (the "posterior" distribution) based on some "prior" distribution which is then updated by the data. The Bayesian modeling process returns a number of samples from which you can compute the mean, or an exceedance probability, or any other quantity you might compute from a distribution.

Before you fit a model with spatial correlation, you'll first fit the same model as before, but using Bayesian inference.

Instructions
100 XP

The london data set has been loaded.

  • The R2BayesX package provides an interface to the BayesX code.

  • Fit the GLM for flu as before.

  • Show its summary…

  • and the confidence intervals of its coefficients, using confint() Check the model coefficients and standard errors for significance.

  • The syntax for bayesx() is similar, but the offset has to be specified explicitly from the data frame, the family name is in quotes, and the spatial data frame needs to be turned into a plain data frame. Run the model fitting and inspect with summary().

  • Plot the samples from the Bayesian model. On the left is the "trace" of samples in sequential order, and on the right is the parameter density. For this model there is an intercept and a slope for the Health Deprivation score. The parameter density should correspond with the parameter summary.