I'm using the function autocov_dist
from spdep
package to estimate the aucovariate. I'm using inverse distance as a weight. When I tested it on my data I got this error message:
Error in autocov_dist(Var, xy, nbs = 100, style = "B", type = "inverse") : is.vector(z) is not TRUE
Here a reproducible example (I'm showing large values in the coordinates because in my real data the spatial coordinates are in UTM):
library(spdep)
set.seed <- 123
xy<- as.data.frame(cbind(rnorm(1000,100000, 100), (rnorm(1000,500000, 100))))
Var <- rnorm(1000,2, 1)
autocov <- autocov_dist(Var, xy, nbs=100, style="B",type="inverse")
Also, what is exactly the definition of the neighboring radius (the nbs
argument in the function) because I couldn't find a clear definition in the function documentation.
To set seed you have to to use set.seed(number)
.
xy
needs to be a matrix you have converted it to a dataframe. Try :
library(spdep)
set.seed(123)
xy<- cbind(rnorm(1000,100000, 100), (rnorm(1000,500000, 100)))
Var <- rnorm(1000,2, 1)
autocov <- autocov_dist(Var, xy, nbs=100, style="B",type="inverse")