Hi, I am working on spatial panel data analysis. The research work focuses on West Africa countries. I have tried all I could to convert my shapefile to binary contiguity matrix, then try to fit it with my model. But am facing errors after running the code. Below is my chunks code
data <- read.csv(paste(my.dir,'energy_data.csv',sep=""))
eco <- rgdal::readOGR(paste(my.dir,"/EcowasWA/ecowas.shp",sep=""))
data.g<- attr(eco, "data")
Creating Queen Contiguity based neighbours ----------------
wm_q <- poly2nb(eco, queen = TRUE)
weight matrix represented as a normal matrix
q <- nb2mat(temp)
transform the weights matrix into a listw
ecolw <- mat2listw(q)
my model
fm <- REC ~ ACT + ATE + EIL + TEO + CO2 + TFE
Random Effect Model
model_1 <- spml(formula = fm, data = data, index = NULL, listw = ecolw, model = "random", lag = TRUE, spatial.error = "b")
This is the error am facing
Error in spreml(formula = formula, data = data, index = index, w = listw2mat(listw), : **
** Non conformable spatial weights
Kindly assist me