Skip to content
Prev 26504 / 29559 Next

Spatial Panel Models Problem (Splm package)

On Mon, 7 May 2018, felipe tavares wrote:

            
This is the problem. You do not need to generate the Kronecker problem 
yourself (using the example in ?spml:

library(splm)
data(Produc, package = "plm")
data(usaww)
W <- mat2listw(usaww, style = "W")

# This is what you did:

years <- length(unique(Produc$year))
kronecker.W <- listw2dgCMatrix(W)
W_queen2 <- kronecker(Diagonal(years), kronecker.W)
W_queen <- mat2listw(W_queen2, style = "W")

fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
SAR <- spml(fm, listw = W_queen, model="within", spatial.error= NULL,
   lag = TRUE, data=Produc)
# Error in lag.listw(listw, u, zero.policy = zero.policy) :
#   object lengths differ

# It works if you just pass the listw object:
SAR <- spml(fm, listw = W, model="within", spatial.error= NULL,lag = TRUE,
   data=Produc)

When reading documentation, please do not ignore the examples. They are 
tested once a day on more than 12 different platforms, and can be relied 
upon. This is also explained in the JSS article, which I assume you have 
read and will cite.

Roger