I guess that was the thing. I had to use this command. Thanks for your helping!
However, when I do it:
SARmodel <- lagsarlm(obitos ~ pop_60 + area, data=SP, W.list)
Occurs that error:
Error in lagsarlm(obitos ~ pop_60 + area, data = SP, W.list) : NAs in lagged dependent variable
In addition: Warning message:
In lag.listw(listw, y, zero.policy = zero.policy) : NAs in lagged values
Do you have some idea of how to solve this? I think there is some NA value in a cell, but there isn't. I visually checked all my data from my database. So, I think the problem could be in my shapefile.
That's my code:
SP1 <- read.csv("26012021.csv", header = TRUE, sep = ";", dec = ",")
SP <- SP1[(-646),]
shape.SP <- readOGR("C:/Users/lucas/Desktop/IC - Silvio/R/sp_municipios","SP_Municipios_2019")
W.nb <- poly2nb(shape.SP, row.names = rownames(shape.SP@data))
W.list <- nb2listw(W.nb, style="W", zero.policy = TRUE)
SARmodel <- lagsarlm(obitos ~ pop_60 + area, data=SP, W.list)
The variables are in portuguese because I'm brazilian, but this is irrelevant.
I'm not understand, as well, how is my database linked with the shapefile as I make the lagsarlm procedure. Is something wrong in my code?
Thanks for everything.