# NOT RUN {
# create 5x5 square
poly <- raster::rasterToPolygons(raster::raster(nrows = 5, ncols = 5,
xmn = -1.25, xmx = 1.25,
ymn = -1.25, ymx = 1.25,
res = 0.5,
crs = "+proj=longlat +datum=WGS84"))
df <- data.frame("x" = stats::rnorm(n = 25))
dt <- sp::SpatialPolygonsDataFrame(poly, df)
knots <- cbind(c(-0.75, 0.0, 0.75, -0.75, 0.0, 0.75, -0.75, 0.0, 0.75),
c(-0.75,-0.75, -0.75, 0.0, 0.0, 0.0, 0.75, 0.75, 0.75))
res <- optRegion(spatialData = dt,
response = "x",
sigmavar = rep(1, 25),
gL = 5,
gU = 7,
nGibbs = 50L,
nBurn = 10L,
nThin = 1L,
nw = 2000L,
knots = knots)
plot(x = res, dB = dt)
# }
Run the code above in your browser using DataLab