Skip to content

Instantly share code, notes, and snippets.

View bbolker's full-sized avatar

Ben Bolker bbolker

View GitHub Profile
@bbolker
bbolker / 3d_kriging_cgs.R
Created February 25, 2025 16:26 — forked from mikebirdgeneau/3d_kriging_cgs.R
3D Kriging with Conditional Gaussian Simulation in R
library(gstat)
library(lattice)
# Create Data Points (Random)
n <- 50
data3D <- data.frame(x = runif(n), y = runif(n), z = runif(n), v = rnorm(n))
coordinates(data3D) = ~x+y+z
# Create empty grid to krige
range1D <- seq(from = 0, to = 1, length = 20)
@bbolker
bbolker / cbrm.R
Created May 22, 2023 20:36 — forked from derekpowell/cbrm.R
Wrapper for brm() that supports caching of BRMS models
cbrm <- function(formula,
data,
family = gaussian(),
prior = NULL,
autocor = NULL,
cov_ranef = NULL,
sample_prior = c("no", "yes", "only"),
sparse = FALSE,
knots = NULL,
stan_funs = NULL,
bigcorPar <- function(x, nblocks = 10, verbose = TRUE, ncore="all", ...){
library(ff, quietly = TRUE)
require(doMC)
if(ncore=="all"){
ncore = multicore:::detectCores()
registerDoMC(cores = ncore)
} else{
registerDoMC(cores = ncore)
}