I want to use the mgcv
package in R to run the model
df <- as.data.frame(spdf)
mod <- gam(y ~ s(geoid, bs = 'mrf', xt = list(nb = nb), k = 20) +
s(month, bs = 'cc', k = 12),
data = df,
method = 'REML',
family = Gamma(link = log))
where spdf is a SpatialPolygonDataFrame.
I am having problems understanding how to create the nb
object since the data df
have duplicates geoid
values (one for each month) and when I run
nb <- poly2nb(spdf, row.names = spdf@data@geoid)
I get the error
Error in poly2nb(spdf, row.names = spdf@data@geoid): non-unique row.names given
Thanks