<div dir="ltr">Attaching the code and the dataset:<div><br></div><div><div><br></div><div><div><div># code</div><div>library(spdep)</div><div>library(adespatial)</div><div>mydata=read.csv("example_data.csv",header=TRUE)</div><div>attach(mydata)</div><div><br></div><div><br></div><div># creating neighbors map from the coordinates</div><div>xy=SpatialPoints(as.matrix(mydata[,c(5,6)]))</div><div>myneighbors=dnearneigh(as.matrix(mydata[,c(5,6)]), 0, 1000, row.names = NULL, longlat = TRUE)# 1000 kilometer distance</div><div>myweight=nb2listw(myneighbors,style="W") # style W </div><div># creating PCNM</div><div>spatial_eigenvectors=dbmem(as.matrix(mydata[,c(5,6)]),MEM.autocor="positive")</div><div><br></div><div># simple regression model  </div><div>alpha_lm=lm(alpha~evenness+I_A+gamma+herb_cover+woody_cover) # <br></div><div>summary(alpha_lm)</div><div>moran.test(alpha_lm$residuals,myweight) # significant spatial autocorelation</div><div><br></div><div><br></div><div># regression model with all positive eigenvectors</div><div>PCNM_lm=lm(alpha~evenness+I_A+gamma+herb_cover+woody_cover+</div><div>               spatial_eigenvectors[,1]+spatial_eigenvectors[,2]+spatial_eigenvectors[,3]+</div><div>               spatial_eigenvectors[,4]+spatial_eigenvectors[,5]+spatial_eigenvectors[,6]+</div><div>               spatial_eigenvectors[,7]+spatial_eigenvectors[,8]+spatial_eigenvectors[,9]+</div><div>             spatial_eigenvectors[,10]+spatial_eigenvectors[,11]+spatial_eigenvectors[,12])</div><div>                                                     </div><div>summary(PCNM_lm)</div><div>moran.test(PCNM_lm$residuals,myweight) # significant spatial autocorelation</div><div><br></div><div><br></div><div># SAR error regression model </div><div>sar_alpha=errorsarlm(alpha~evenness+I_A+gamma+herb_cover+woody_cover,data=mydata,myweight)</div><div>summary(sar_alpha)</div><div>moran.test(sar_alpha$residuals,myweight) # no spatial autocorelation</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 15, 2017 at 12:24 PM, Roger Bivand <span dir="ltr"><<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Wed, 15 Nov 2017, niv de malach wrote:<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi,<br>
I am trying to include spatial eigenvectors ( in my regression using *dbmem<br>
*command from *adespatial* package) in order to account for spatial<span><br>
correlation. The problem is that even after including all the positive<br>
eigenvectors there is still a positive significant spatial autocorrelation<br>
in the residuals (based on Moran's I test). The magnitude of this problem<br>
is affected by the styles I use for the spatial weight (using the styles<br></span>
"U","W" "B" "C" of the function *nb2list* from *spdep*) but in all styles<span><br>
Moran's I is still significantly positive.<br>
</span></blockquote>
<br>
Maybe there is negative residual autocorrelation, and only choosing eigenvectors matching positive eigenvalues is enhancing pattern jumble (oversmoothing the model leaving jumble in the residuals)? Do you have an example you could share (link to offline downloadable code+data if need be)?<br>
<br>
Roger<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>
<br>
Interestingly this problem doesn't occur when I use a SAR models (<br></span>
*errorsarlm* command from *spdep* package).<span><br>
<br>
So, does it make sense to use PCNM approach when it removes only a portion<br>
the spatial autocorrelation?<br>
<br>
Thanks<br>
Niv<br>
<br></span>
ᐧ<br>
<br>
        [[alternative HTML version deleted]]<br>
<br>
______________________________<wbr>_________________<br>
R-sig-Geo mailing list<br>
<a href="mailto:R-sig-Geo@r-project.org" target="_blank">R-sig-Geo@r-project.org</a><br>
<a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" rel="noreferrer" target="_blank">https://stat.ethz.ch/mailman/l<wbr>istinfo/r-sig-geo</a><span class="gmail-m_2370438801445660858HOEnZb"><font color="#888888"><br>
</font></span></blockquote><span class="gmail-m_2370438801445660858HOEnZb"><font color="#888888">
<br>
-- <br>
Roger Bivand<br>
Department of <a href="https://maps.google.com/?q=Economics,+No&entry=gmail&source=g" target="_blank">Economics, No</a>rwegian School of Economics,<br>
Helleveien 30, N-5045 Bergen, Norway.<br>
voice: <a href="tel:%2B47%2055%2095%2093%2055" value="+4755959355" target="_blank">+47 55 95 93 55</a>; e-mail: <a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
Editor-in-Chief of The R Journal, <a href="https://journal.r-project.org/index.html" rel="noreferrer" target="_blank">https://journal.r-project.org/<wbr>index.html</a><br>
<a href="http://orcid.org/0000-0003-2392-6140" rel="noreferrer" target="_blank">http://orcid.org/0000-0003-239<wbr>2-6140</a><br>
<a href="https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en" rel="noreferrer" target="_blank">https://scholar.google.no/cita<wbr>tions?user=AWeghB0AAAAJ&hl=en</a></font></span></blockquote></div><br></div></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=abml2ZGVtYWxhY2hAZ21haWwuY29t&type=zerocontent&guid=5cb06e62-5c0e-4ae2-a37e-7125f1663739"><font color="#ffffff" size="1">ᐧ</font></div>