How to set "dist=" in gratia::smooth_estimates?

25 Views Asked by At

I'm attempting to plot a tensor smooth of my model's spatial component, and the "dist=" option is helpful for making sure it doesn't plot predictions too far away from each site. However, I can't figure out how to set it to my specifications. I want each gps coordinate (WGS 1984) to have a 60-foot (18.288 m) radius around it, but I'm not sure how to set that in the code.

library(mgcv)
library(gratia)

m2 <- bam(num ~ 
            s(sal) + 
            s(DO) + 
            s(ave_tt) + 
            s(ave_hw) + 
            te(Longitude, Latitude) + # <- term to plot
            s(CYR.std) + 
            s(CYR.std, fSeason, bs='fs') + 
            s(CYR.std, by=fSite) + 
            s(fSite, bs = "re") +
            s(fCYR, bs = "re"), 
          offset(log(area_sampled)), 
          method = "fREML",
          discrete = TRUE,
          select = TRUE,
          family = nb(),
          data = shrimp2)

sm <- gratia::smooth_estimates(m2, smooth = "te(Lon", dist = ??, partial_match = TRUE)

ggplot(sm, aes(x = Longitude, y = Latitude)) +
  geom_raster(aes(fill = est)) +
  geom_contour(aes(z = est), colour = "black") +
  geom_point(data = shrimp2, alpha = 0.2) + 
  scale_fill_distiller(palette = "RdBu", type = "div") +
  expand_limits(fill = c(-1,1) * abs(max(sm[["est"]])))
0

There are 0 best solutions below