Produce an RW2 Adjacency matrix for a rectangular grid for use with areal spatial models. This formulation uses cofficients inspired by a thin plate spline, as described in Rue & Held, section 3.4.2 Here I'm outputting an adjacency matrix of 'neighbor weights' which makes Q construction for regular latices easy to do when not trying to make inference about all cells (i.e., one can just eliminate rows and columns associated with cells one isn't interested in and set Q=-Adj+Diag(sum(Adj))
rect_adj_RW2(x, y, byrow = FALSE)
number of cells on horizontal side of grid
number of cells on vertical side of grid
If TRUE, cell indices are filled along rows (default is FALSE)
adjacency matrix