I'm trying to run a lasso model for spatial (polygons) data in R. It has been very very difficult to find a package that allows me to do run the spatial lasso model and at the same time allows me to get the Beta coefficients for my independent variables. Which is my final goal: using lasso to evaluate which variables are important for the model and which are not, considering the spatial relationship in my data.
I have tried with the following:
glmnetcv
function from thespm2
package.scgwr_p
function from thescgwr
package.lasso.ss
function from thespselect
package.
From the example the spm2
package provides:
library(spm2)
data(petrel)
x <- as.matrix(petrel[, c(1, 2, 6:9)]) #Columns 1 and 2 are longitude and latitude##
y <- log(petrel[, 5] + 1) #Column 1 is the dependent variable
set.seed(1234)
glmnetcv1 <- glmnetcv(x, y, validation = "CV", predacc = "ALL", alpha = 1)
Given this code, I would like to get information of which of the variables (from columns 6 to 9) are important in this model. And which variables are not.
If there is another package that I'm missing that can deal with spatial data (polygons) and lasso models, please let me know!
Any help would be so much appreciated!!!