Spatial Panel Data Analysis

Our analysis is based on samples from three countries in West Africa. The data are in the period of 1990 to 2018 on seven variables ( One dependent variable and six independent variables). The code used is as follows.

Load Data

data <- read.csv(paste(my.dir,'testdata.csv',sep=""))

Load Shapefile

Wafrica <- raster::getData("GADM", country = "Benin", level = 1)
Wafrica2 <- raster::getData("GADM", country = "Nigeria", level = 1)
Wafrica3 <- raster::getData("GADM", country = "Togo", level = 1)
weafrica <- merge(Wafrica, Wafrica2, Wafrica3)

Creation of a k matrix plus close neighbours

map_crd <- coordinates(weafrica)
Points <- SpatialPoints(map_crd)
knn_k <- knearneigh(Points, k=3)
k_nb <- knn2nb(knn_k)
wknn_k <- nb2listw(k_nb, style="W")

my model

fm <- REC ~ ACT + ATE + EIL + TEO + CO2 + TFE

Fixed effects model

slmtest(fm, data = data, listw = wknn_k, test="lml", model="within")

The follow was the error received at the end of the code.

Error in bigW %*% hatY : not conformable for multiplication

Kindly assist me in looking at the code to get desire result instead of the error message am seeing.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.