Dear all,
I encountered the same problem when I was running a linear model on HPC cluster, and I got "Error: Failed to create the shared library". I have tried the
foo <- nimbleFunction( run = function(x = double(1)) {return(sum(x)); returnType(double())})
cfoo <- compileNimble(foo)cfoo(1:10)which works good on the cluster, does that mean compiler setup is working, and so what's the problem of my code?
My code is like this:
#mcmc function
run_linear_mcmc<-function(data){
# Model Definition
model_code <- nimbleCode({
beta0 ~ dnorm(0, sd = 100)
beta1 ~ dnorm(0, sd = 100)
sigma ~ dunif(0, 50)
for(i in 1:N) {
mean_wbgtmax[i] ~ dnorm(beta0 + beta1 * year[i], sd = sigma)
}
})
# set the constant
constants<-list(N=nrow(data))
data_list <- list(mean_wbgtmax = data$mean_wbgtmax, year = data$year)
inits <- list(beta0 = 0, beta1 = 0, sigma = 1)
niter<- 10000
# configure and run MCMC
mcmc_output<-nimbleMCMC(code = model_code,
constants = constants,
data = data_list,
inits = inits,
monitors = c('beta0', 'beta1', 'sigma'),
niter = niter)
# get the posterior summary
beta1_samples <- mcmc_output[,"beta1"]
mean_posterior <- mean(beta1_samples)
ci <- quantile(beta1_samples, c(0.025, 0.975))
prob_gt_0 <- mean(beta1_samples > 0)
return(list(ct_id=unique(data$ct_id),mean = mean_posterior, ci = ci, prob_gt_0 = prob_gt_0))
}
Defining model
Building model
Setting data and initial values
Running calculate on model
[Note] Any error reports that follow may simply reflect missing values in model variables.
Checking model sizes and dimensions
Checking model calculations
Compiling
[Note] This may take a minute.
[Note] Use 'showCompilerOutput = TRUE' to see C++ compilation details.
Error: Failed to create the shared library. Run 'printErrors()' to see the compilation errors.
Execution halted
Thank you so much for your help!!
Best ,
Xicheng