Session Ready
Exercise

Adding a spatially autocorrelated effect

You've fitted a non-spatial GLM with BayesX. You can include a spatially correlated term based on the adjacency structure by adding a term to the formula specifying a spatially correlated model.

Instructions
100 XP

The spatial data object, london is already loaded.

  • Use poly2nb() to compute the neighborhood structure of london to an nb object.
  • R2BayesX uses its own objects for the adjacency. Convert the nb object to a gra object.
  • The sx function specifies additional terms to bayesx. Create a term using the "spatial" basis and the gra object for the boroughs to define the map.
  • Print a summary of the model object. You should see a table of coefficients for the parametric part of the model as in the previous exercise, and then a table of "Smooth terms variance" with one row for the spatial term. Note that since BayesX can fit many different forms in its sx terms, most of which, like the spatial model here, cannot be simply expressed with a parameter or two. This table shows the variance of the random effects - for further explanation consult a text on random effects modeling.