[R-sig-Geo] Error when performing a spatial eigenvector selection in R

DIEGO CEPEDA GOMEZ diegoceped@ @ending from ucm@e@
Wed Oct 10 09:31:02 CEST 2018


Dear all,

I am currently trying to do a Gaussian linear regression in R with data
that may be spatially autocorrelated. My dataset contains geographic
coordinates (value of longitude, value of latitude), species, independent
variables (BS and LTS) and some explanatory variables; it looks like:

head(dataset)

coordinates SPECIES                BS   LTS  DEPTH OCEAN(155, 47)
Cristaphyes abyssorum  8.66 28.3  5373  WPac(150, 41)    Cristaphyes
abyssorum  8.66 28.3  5250  WPac (-72, -41)   Cristaphyes anomalus
8.69   NA    35  EPac(-74, -44)   Cristaphyes anomalus   8.69   NA
35  EPac(-57, -46)   Cristaphyes anomalus   8.69   NA    NA  WAtl(29,
80)     Cristaphyes arctous    8.32 27.0   393  EAtl

tail(dataset)

coordinates SPECIES                  BS   LTS   DEPTH  OCEAN(-80, 27)
 Zelinkaderes brightae    NA   20.1  13.04  WAtl(-80, 27)
Zelinkaderes floridensis 7.10 12.4  140.00 WAtl(35, 25)
Zelinkaderes klepali     NA   25.0  1.00   WInd(9, 57)
Zelinkaderes submersus   7.99 21.4  30.00  EAtl(130, 36)
Zelinkaderes yong        NA   12.7  4.50   WAtl

The dataset also include the values of latitude and longitude in separated
columns.

I extracted positive eigenvector-based spatial filters from a truncated
matrix of geographic distances among sampling sites. I would like to treat
spatial filters as candidate explanatory variables in my linear regression
model. I did this as following:

First of all, I created a neighbor list object (nb). In my case of
irregular samplings, I used the function knearneight of the R package spdep:

knea8 <-knearneight(coordinates(dataset), longlat=TRUE, k=8)

neib8 <-knn2nb(knea8)

Then, I created a spatial weighting matrix with the function nb2listw of
the R package spdep:

nb2listw(neib8)

distgab8 <- nbdists(neib8, coordinates(dataset))

str(distgab8)

fdist<-lapply(distgab8, function(x) 1-x/max(dist(coordinates(dataset))))

listwgab8 <- nb2listw(neib8, glist = fdist8, style = "B")

Then, I built spatial predictors to incorporate them in the Gaussian linear
regression. I did this with the mem function of the R package adespatial,
as following:

mem.gab8 <- mem(listwgab8)

Additionally, Moran's I were computed and tested for each eigenvector with
the moran.randtest function, as following:

moranI8 <-moran.randtest(mem.gab8, listwgab8, 99)

I obtained some eigenvectors with significant positive spatial
autocorrelation. Now, I would like to include them in the Gaussian linear
regression. I tried to do this with the function ME of spdep, as following:

GLM1 <- ME(BS~LATITUDE, data=dataset, listw=listwgab8,
family=gaussian, nsim=99, alpha=0.05)

Unfortunately, I receive this error:

Error in sW %*% var : Cholmod error 'X and/or Y have wrong dimensions' at
file ../MatrixOps/cholmod_sdmult.c, line 90


Would anybody know how I could solve this error? Or, if is there another
way to perform a spatial eigenvector selection in a Gaussian linear
regression?

Thank you in advance

Best wishes,

Diego

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list