1

I have geographical data at the town level for 35 000 towns. I want to estimate the impact of my covariates X on a dependent variable Y, taking into account autocorrelation. I have first computed weight matrix and then I used the command spautolm from the package spam but it returned me an error message because my dataset is too large. Do you have any ideas of how can I fix it? Is there any other equivalent commands that would work?

library(haven)
library(tibble)
library(sp)
library(data.table)

myvars <- c("longitude","latitude","Y","X")
newdata2 <- na.omit(X2000[myvars]) #drop observations with no values for one observation
df <- data.frame(newdata2) 
newdata3<- unique(df) #drop duplicates in terms of longitude and latitude
coordinates(newdata3) <- c("longitude2","latitude2") #set the coordinates
coords<-coordinates(newdata3) 
Sy4_nb <- knn2nb(knearneigh(coords, k = 4)) # Display the k closest neighbours
Sy4_lw_idwB <- nb2listw(Sy8_nb, glist = idw, style = "B") #generate a list weighted by the distance

When I try to run such formulas:

spautolm(formula = Y~X, data = newdata3, listw = Sy4_lw_idwB)

It returns me : Error: cannot allocate vector of size 8.3 Gb

  • 1
    Possible duplicate of [R memory management / cannot allocate vector of size n Mb](https://stackoverflow.com/questions/5171593/r-memory-management-cannot-allocate-vector-of-size-n-mb) – Matthew Ciaramitaro Feb 22 '18 at 17:56

0 Answers0