[R-sig-Geo] Spatial autocorrelation help
Patrick Schratz
p@trick@@chr@tz @ending from gm@il@com
Tue Jul 10 20:38:26 CEST 2018
Hi Dechen,
it is very important to account for SAC in any model. This can be done in various ways. In log.reg it is common to include spatial autocorrelation structures that describe the underlying SAC. To do so, you can use mixed models, e.g. MASS::glmmPQL().
Also have a look at Wood (2017) Generalized Additive Models in R.
I did account for it in my master thesis.Even though the code is not attached, it may help you: https://zenodo.org/record/814262
Cheers, Patrick
On Jul 10 2018, at 7:46 pm, Dechen Lham <dechen.lham using ieu.uzh.ch> wrote:
>
> Hello all,
> I would like some help in my problem below:
> I am running a logistic regression and my best model residuals has spatial autocorrelation (SAC) when checked as below and also on the raw data of the response type. My response is binary 0 and 1 (type of prey and to be predicted by several predictors). These type of prey are obtained from a total of 200 locations (where the faecal samples are collected from). In order to account for this SAC , I used the auto_covdist function from spdep package. But when i use this as a new predictor in my model, and then check for spatial autocorrelation in the residues of the model, there is still spatial autocorrelation,…..could u see if i am doing something wrong please?
> #account for SAC in the model using weights
> # auto_covariate is a distance weighted covariate
> data$response <- as.numeric(data$response)
> auto_weight <- autocov_dist(data$prey.type, xy=coords, nbs=1, type="inverse", zero.policy = TRUE,style="W", longlat = TRUE)
>
> m5_auto <- glm(response ~ predictor1 + predictor2 + predictor3 + predictor4 + predictor1:predictor4, weight=auto_weight, family=quasibinomial("logit"), data=data)
> # check spatial autocorrelation - first convert data to spatial points dataframe
> dat <- SpatialPointsDataFrame(cbind(data$long, data$lat), data)
> lstw <- nb2listw(knn2nb(knearneigh(dat, k = 2)))
>
> # check SAC in model residuals
> moran.test(residuals.glm(m5_auto), lstw) # and gives the below:
>
> Moran I test under randomisation
> data: residuals.glm(m5)
> weights: lstw
>
> Moran I statistic standard deviate = 1.9194, p-value = 0.02747
> alternative hypothesis: greater
> sample estimates:
> Moran I statistic Expectation Variance
> 0.160824328 -0.004608295 0.007428642
>
> -Someone said its stupid to account for spatial autocorrelation in a logistic regression when you have a significant SAC using moran’s I. So i am now wondering how this can be solved? or does a SAC in a logistic regression be just ignored?
> I am new to spatial statistics and now idea how to move with such. I only know that my data has spatial
> autocorrelation (which i hope to have checked correctly using morans I as above) and now need to account for this in my analysis. Some advice would be greatly appreciated by people who have used to account for SAC in their logistic models. Is a logistic mixed models an option to consider?especially if your covariates are spatial in nature,…i read somewhere that if you cant account for SAC in glm then you can move to mixed models esp if your covariates are spatial which is expected to digest the SAC.
>
> Help and advice would be greatly appreciated.
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list