D.PARK = 250.214

D.PARK = 2724.089

D.PARK = 5202.328

D.PARK = 7668.833

Hill llllln

Illllllllllllllllllllllll

Illllllllllllllll II

Illllllllllllllll

Number of road killings

Number of road killings

Fig. 16.9 Examples of negative binomial distributions. The density curves have a parameter of k = 11.8, and the mean value / was taken from the fitted values at certain arbitrary chosen values along the D.PARK gradient

16.5 GAMM: Adding Spatial Correlation

In the previous section, we applied a GAM and found that the optimal model contains a smoother for D.PARK and OPEN.L. The residuals were plotted against the spatial coordinates, and we could not see any clear spatial patterns in these residuals. Instead of making this plot, we can also make a variogram of the residuals. The easiest option is to use the function Variogram from the nlme package, which is designed to work with the gls, lme, and gamm functions. All we need to do now is to rerun the GAM as a GAMM, just like we reran the linear regression with a GLS in Chapter 4 and use the Variogram function on its results. The code is given below and the resulting graph in Fig. 16.10, where there is a minor indication that points close to each other are more similar than points further separated along the road (this can be seen from a slightly increasing pattern in the variogram). However, one can equally well argue that the points form a horizontal band of points, indicating independence.

> library(nlme)

> M4 <- gamm(TOT.N ~ s(OPEN.L) + s(D.PARK), data = RK, family = negative.binomial(theta = 11.8))

> M4Var <- Variogram(M4$lme, form =~ D.PARK.KM, nugget = TRUE, data = RK)

It is also possible to add a spatial correlation structure to the model and see whether it improves anything. This can easily be done by using one of the available correlation structures corExp, corSpher, corRatio, or corGaus. According to the protocol defined in Chapters 4 and 5, we should start with a model containing smoothers of all explanatory variables. However, such a model did not converge. We therefore used the optimal model from the GAM with D.PARK and OPEN.L and

Was this article helpful? |

## Post a comment