I need to apply Generalized linear modeling and Additive modeling to my data (continuous and categorical explanatory variables). But my data is spatially autocorrelated. What is the best options?
There are a couple choices that you could research.
1) you could subsample you data until the Moran's I (or variogram) indicates that there is no longer spatial correlation.
2) you could group the data so that locations within a certain distance of each other belong to a group variable. You would then specify the intercept of your models as a random effect across groups.
3) Or you could model the spatial correlation explicitly.
Take a look at this website. It describes things fairly well and has example code...
if you want to combine modelling spatial dependency and the smooth non-linearity of a Gam have a look at the free software Bayes X and its fairly extensive manual that specifically covers this case
Thank you all for very useful suggestions. But the last response from Dr Kelvyn is exactly what I need. linear and nonlinear relationships with continuous and categorical variables in case of spatial autocorrelation.
To account for potential spatial autocorrelation you can include the geographical position, i.e. the latitude-longitude interaction term in the analyses (Wood, S.N., 2006. Generalized additive models: an introduction with R. London: Taylor & Francis, CRC Press, 384 pp. ISBN, 978-7-58488-474-3.)
Perhaps this paper might be of use to you. It has a recipe for rigorously testing spatial autocorrelation (spline correlograms are better than straight Moran's I in my opinion), and a recipe for testing whether you need to bother with spatially explicit models. Good luck!
I have been using marginal models fit with generalized estimating equations (GEEs). This are helpful if your data was collected repeatedly for the same subjects. These can be fit in R using the geepack library https://cran.r-project.org/web/packages/geepack/geepack.pdf . You can find good details on this approach and useful books here https://wildlifesnpits.wordpress.com/2014/10/24/dealing-with-ugly-data-generalized-estimating-equations-gee/ :) I hope everything goes well!
Hi Levan, I applied the Moran's eigenvector mapping methods to GLMS in my paper "Spatial interactions in saithe and hake distribution". This technique is might at first be difficult to handle but at then it is really efficient. There is a review for Dormann 2007 that deals and compare several methods to do that (including MEM).
Have a look in the R-INLA package, which solves a large class of statistical models using the integrated nested laplace approximation and the latent Gaussian field approach to lead with spatial autocorrelation.
One option for linear e non-linear GLM is to account for spatial autocorrelation using spatial eigenvectors, specifically Moran Eigenvectors, which will transform the GLM into a Spatial Eigenvectors GLM. I recently published a paper using this approach and you can have a look if you want. Also, the review published by Dormann is really useful.
Moran’s I test can detect spatial autocorrelation using R-package ‘spdep’. Spatial autocorrelation can be minimized by removing closely occurring points or evenly spreading occurrence points across the area of interest. Moran's I test should be performed after each treatment until satisfying results obtained. You can see the detailed method of evenly distributing occurrence points to minimize spatial autocorrelation in the supplementary material of the paper listed below.
First of all, you should check whether you have a general spatial trend (with a global Moran's test) or whether you data points are spatially autororrelated (made with you GLMM residuals fitted previously) with a LOCAL Moran's test, which makes randomisations with increasing increment (distance for correlation tested), so if the autocorrelation is only at the distance 0, then it's fine. Package "ncf" or "spdep" handles that.
If you have a significant autocorrelation in your data, then you should add a spatial covariance matrix in your model, to control for autocorrelation. Package glmmTMB propose several solutions :
Dormann et al. (2007) is a nice review to deal with autocorrelated data. GLMs and GAMs with autocorrelated data are types of mixed models that account for non-independece among sampling units. As several pointed out, there are several good packages for this purpose including nlme, lme4, MASS, glmmTMB. I also recommend you Zuur's book "Mixed effects models and extensions in ecology with R" for clear and easy step-by-step routines.
There are several good statistical packages are available. R-INLA is one of them. Dormann et al. have published a review to deal with autocorrelated data
One option for GAM in the R package 'mgcv' is to explicitly model latitude and longitude as a spatially autocorrelated smoothing term (similar to a random effect) using a term like this:
+ s(longitude, latitude, bs="gp", k= 100, m=2)
There are lots of great resources from Wood, the creator of mgcv that shows just how powerful GAMs are for these kinds of problems. Check out for example this page on the different types of smoothing terms you can use and why:
I think that this method allowing you to test bayesian approches. You Can apply GLM and The CAR model can be written as (Keitt et al. 2002): Y = Xb +rW (Y -Xb)o.
simultaneous, GLS modeling directly co variance using parametric function.