I was wondering if it is possible to run MCMC chains on more than one core per chain. I tried:
I am updated to R version 4.3.2. Sean Anderson has given me these reproducible examples:
library(RTMB)
set.seed(123)
data <- list(Y = rnorm(10) + 1:10, x=1:10)
parameters <- list(a=0, b=0, logSigma=0)
f <- function(parms) {
Y <- data$Y
x <- data$x
a <- parms$a
b <- parms$b
logSigma <- parms$logSigma
ADREPORT(exp(2*logSigma));
nll = -sum(dnorm(Y, a+b*x, exp(logSigma), TRUE))
nll
}
obj <- MakeADFun(f, parameters)
library(tmbstan)
s <- tmbstan(obj, iter = 100, chains = 2, cores = 1) # works
s <- tmbstan(obj, iter = 100, chains = 2, cores = 2) # doesn’t work
s <- tmbstan(obj, iter = 100, chains = 2, cores = 3) # doesn’t work
Also this ran for Sean, but not for me:
TMB::runExample("simple")
fit <- tmbstan(obj, chains=2, iter = 50, cores = 2) # works