nimblewomble
:
An R package for Bayesian wombling with nimble
The goal of nimblewomble
is to perform Bayesian Wombling
(boundary analysis) using nimble
.
For more details on point-referenced Wombling please refer to: a. Bayesian Wombling: Sudipto Banerjee and Alan E. Gelfandhttps://doi.org/10.1198/016214506000000041 b. Bayesian Modeling with Curvature Processes: Aritra Halder, Sudipto Banerjee and Dipak K. Dey https://doi.org/10.1080/01621459.2023.2177166
You can install the development version of nimblewomble
like so:
::install_github("arh926/nimblewomble") devtools
This is a basic example which shows you the workflow on a simulated data:
require(nimble)
require(nimblewomble)
set.seed(1)
= 1e2
N = 1
tau = matrix(runif(2 * N, -10, 10), ncol = 2); colnames(coords) = c("x", "y")
coords = rnorm(N, 20 * sin(sqrt(coords[, 1]^2 + coords[, 2]^2)), tau)
y
= gp_fit(coords = coords, y = y, kernel = "matern1")
mc_sp
= zbeta_samples(y = y, coords = coords,
zbeta model = mc_sp$mcmc,
kernel = "matern1")
= ysplit = seq(-10, 10, by = 1)[-c(1, 21)]
xsplit = as.matrix(expand.grid(xsplit, ysplit), ncol = 2)
grid colnames(grid) = c("x", "y")
= sprates(grid = grid,
gradients coords = coords,
model = zbeta,
kernel = "matern1")
require(ggplot2)
require(ggplot2)
require(cowplot)
require(MBA)
require(metR)
= sp_ggplot(data_frame = data.frame(grid,
p1 z = gradients$estimate.sx[,"50%"],
sig = gradients$estimate.sx$sig))
p1
= # Pick a curve from the surface that is interesting to you
curve = spwombling(coords = coords,
wm curve = curve,
model = zbeta,
kernel = "matern1")
= sapply(wm$estimate.wm$sig, function(x){
col.pts if(x == 1) return("green")
else if(x == -1) return("cyan")
else return(NA)
})
= sp_ggplot(obs, legend.key.height = 0.7, legend.key.width = 0.4, text.size = 10)
p2
+ geom_path(curve, mapping = aes(x, y), linewidth = 2) +
p2 geom_path(curve, mapping = aes(x, y), colour = c(col.pts, NA), linewidth = 1, na.rm = TRUE)
Name | ||
---|---|---|
Aritra Halder (maintainer) | aritra.halder@drexel.edu | Asst. Professor, Dept. of Biostatistics, Drexel Univ. |
Sudipto Banerjee | sudipto@ucla.edu | Professor & Past Chair, Dept. of Biostatistics, UCLA |