Skip to content
Prev 26503 / 29559 Next

Spatial Panel Models Problem (Splm package)

Hi Roger.

First of all, thank for your help.

Yes, my first two colums are year and id (identification for cities).

I really do not understand, because with the same data I run the regression
in Stata.

There is my full code:
""
# Data
data <- read.xlsx("RJ_database.xlsx", 1, header = TRUE)
panel <- pdata.frame(data, index = c("id", "year"))
time <- length(unique(data$year)) #Salving data time length

pdim(panel)
summary(panel)

poly <- readOGR(dsn ="C:/Users/user/OneDrive/Resource Policy Paper", layer
= "RJ") #Desktop
RJ <- poly2nb(poly)

W <- nb2listw(RJ, style = "W", glist = NULL)
summary(W)

### Kronecker Product
kronecker.W <- listw2dgCMatrix(W)
W_queen2 <- kronecker(Diagonal(time), kronecker.W)
W_queen <- mat2listw(W_queen2, style = "W")

SAR <- spml(gdp ~ oivrev, listw = rjq, model="within", spatial.error= NULL,
lag = TRUE, data=panel)
summary(W_queen)
str(panel)

OLS <- plm(gdp ~ oivrev, model = "within", data = panel)
summary(OLS)

""
And, weird the most is when I run OLS model panel works.

Could you try in your own R to check it out?

Thank you.
On Sat, May 5, 2018 at 7:35 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote: