Running ‘check_huiwalter.R’ [0s/1s]
  Running ‘checkinputs.R’ [0s/1s]
  Running ‘checkmethods.R’ [7s/33s]
  Running ‘checkmodule.R’ [4s/7s]
  Running ‘checkstudy.R’ [0s/2s]
  Running ‘spelling.R’ [0s/1s]
  Running ‘testthat.R’ [1s/2s]
Running the tests in ‘tests/check_huiwalter.R’ failed.
Complete output:
  > library("runjags")
  > set.seed(2022-03-09)
  > 
  > N <- 600
  > status <- rbinom(N, 1, rep(c(0.25,0.5,0.75), each=N/3))
  > testdata <- data.frame(Population = rep(1:3, each=N/3), Test1 = rbinom(N, 1, status*0.75 + (1-status)*0.05), Test2 = rbinom(N, 1, status*0.75 + (1-status)*0.05), Test3=rbinom(N, 1, status*0.75 + (1-status)*0.05))
  > 
  > template_huiwalter(testdata, outfile="huiwalter_model.txt", covariance=TRUE, cov_as_cor=TRUE)
  The model and data have been written to huiwalter_model.txt in the current working directory
  You should check and alter priors before running the model
  > results <- run.jags("huiwalter_model.txt")
  Loading required namespace: rjags
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Calls: run.jags ... as.numeric_version -> numeric_version -> .make_numeric_version
  Execution halted
Running the tests in ‘tests/checkinputs.R’ failed.
Complete output:
  > # First load runjags and verify that the options can be set:
  > library('runjags')
  > runjags.options(inits.warning=FALSE, rng.warning=FALSE, silent.jags=TRUE)
  > newopts <- runjags.options()
  > stopifnot(newopts$inits.warning==FALSE)
  > stopifnot(newopts$rng.warning==FALSE)
  > stopifnot(newopts$silent.jags==TRUE)
  > 
  > 
  > # Test some runjags inputs with the rjags method:
  > 
  > testnum <- 1
  > if(require("rjags")){
  + 
  + 	# Required for nvar etc:
  + 	library("coda")
  + 
  + 	model <- "model {
  + 	for(i in 1 : N){ #data# N
  + 	Y[i] ~ dnorm(true.y[i], precision); #data# Y
  + 	true.y[i] <- (m * X[i]) + c; #data# X
  + 	}
  + 	m ~ dunif(-1000,1000); #inits# m
  + 	c ~ dunif(-1000,1000);
  + 	precision ~ dexp(1);
  + 	#monitor# m, c, precision
  + 	}"
  + 
  + 	# Simulate the data
  + 	X <- 1:100
  + 	Y <- rnorm(length(X), 2*X + 10, 1)
  + 	N <- length(X)
  + 
  + 	initfunction <- function(chain) return(switch(chain, "1"=list(m=-10), "2"=list(m=10)))
  + 	initfunction2 <- function() return(switch(sample(c(1,2),1), "1"=list(m=-10), "2"=list(m=10)))
  + 
  + 	datalist <- list(X=X, Y=Y, N=N)
  + 	
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='rjags')
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction2, method='rjags')
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=lapply(1:2,initfunction), method='rjags')
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction(1), method='rjags')
  + 
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, data=datalist, inits=initfunction, method='rjags')
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, data=datalist, inits=initfunction2, method='rjags')
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, data=datalist, inits=lapply(1:2,initfunction), method='rjags')
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, data=datalist, inits=initfunction(1), method='rjags')
  + 	stopifnot(nvar(as.mcmc.list(results))==(3))
  + 	stopifnot(all(varnames(as.mcmc.list(results))==c('m','c','precision')))
  + 
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- extend.jags(results,sample=1000)
  + 	stopifnot(niter(as.mcmc.list(results))==2000)
  + 	stopifnot(nvar(as.mcmc.list(results))==3)
  + 
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, drop.chain=1, summarise=FALSE)
  + 	stopifnot(nchain(as.mcmc.list(results2))==1)
  + 	stopifnot(identical(list.format(results$end.state[[2]])$.RNG.name, list.format(results2$end.state[[1]])$.RNG.name))
  +   
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, drop.monitor="precision", summarise=FALSE)
  + 	stopifnot(nvar(as.mcmc.list(results2))==2)
  +   
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, add.monitor="true.y", summarise=FALSE)
  + 	stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 	stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "dic"), summarise=FALSE)
  + 	stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 	stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "deviance"), summarise=FALSE)
  + 	stopifnot(nvar(as.mcmc.list(results2))==(4+N))
  + 	stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[104]=='deviance')
  + 	
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, data=datalist, inits=initfunction, method='rjparallel')
  + 	stopifnot(nvar(as.mcmc.list(results))==(3))
  + 	stopifnot(all(varnames(as.mcmc.list(results))==c('m','c','precision')))	
  + 
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, add.monitor="true.y", summarise=FALSE, method='rjp')
  + 	stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 	stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 	
  + 	cat('Running input test number', testnum, '\n'); testnum <- testnum+1
  + 	results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "deviance"), summarise=FALSE, method='rjp')
  + 	stopifnot(nvar(as.mcmc.list(results2))==(4+N))
  + 	stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[104]=='deviance')
  + 	
  + 	cat("All input checks passed\n")
  + 
  + }else{
  + 	cat("The input checks were not performed as rjags is not installed\n")
  + }
  Loading required package: rjags
  Loading required package: coda
  Linked to JAGS 4.3.2
  Loaded modules: basemod,bugs
  Running input test number 1 
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Calls: run.jags ... as.numeric_version -> numeric_version -> .make_numeric_version
  Execution halted
Running the tests in ‘tests/checkmethods.R’ failed.
Complete output:
  > # test all of the runjags dispatch methods with a toy example:
  > 
  > library(runjags)
  > 
  > runjags.options(inits.warning=FALSE, rng.warning=FALSE, blockignore.warning=FALSE, silent.jags=TRUE)
  > 
  > # Require for as.mcmc.list and niter:
  > library("coda")
  > 
  > model <- "model {
  + for(i in 1 : N){ #data# N
  + Y[i] ~ dnorm(true.y[i], precision); #data# Y
  + true.y[i] <- (m * X[i]) + c; #data# X
  + }
  + m ~ dunif(-1000,1000); #inits# m
  + c ~ dunif(-1000,1000);
  + precision ~ dexp(1);
  + #monitor# m, c, precision, dic, popt, pd
  + }"
  > 
  > model_parallel <- "model {
  + for(i in 1 : N){ #data# N
  + Y[i] ~ dnorm(true.y[i], precision); #data# Y
  + true.y[i] <- (m * X[i]) + c; #data# X
  + }
  + m ~ dunif(-1000,1000); #inits# m
  + c ~ dunif(-1000,1000);
  + precision ~ dexp(1);
  + #monitor# m, c, precision
  + }"
  > 
  > # Simulate the data
  > X <- 1:100
  > Y <- rnorm(length(X), 2*X + 10, 1)
  > N <- length(X)
  > 
  > initfunction <- function(chain) return(switch(chain, "1"=list(m=-10), "2"=list(m=10)))
  > 
  > 
  > # Get the JAGS path - rjags adds the JAGS path to the PATH in Windows...
  > try(library(rjags))
  Linked to JAGS 4.3.2
  Loaded modules: basemod,bugs
  > jagspath <- findjags()
  > 
  > # Only run the JAGS methods tests if we have found JAGS and have permission to run it:
  > if(jagspath!="JAGS not found" && testjags(jagspath)$JAGS.available){
  + 
  + 	testnum <- 1
  + 	cat('Testing the simple method\n')
  + 	# Try the simple method and if it doesn't work give a warning but don't fail (likely to be permissions problems)
  + 	success <- try({
  + 		results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='simple',temp=FALSE)
  + 	})
  + 	if(inherits(success, 'try-error')){
  + 		cat("JAGS was found but the simple method failed; it is possible that there were permissions issues or similar.  Details as follows:\n")
  + 		t <- testjags(silent=FALSE)
  + 		cat(failed.jags('output')[[1]])
  + 		print(file.info(jagspath))
  + 		print(file.info(getwd())[,1:3])
  + 		cat("All test methods (except possibly rjags) were skipped\n")
  + 	}else{
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		stopifnot(niter(as.mcmc.list(results))==1000)
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results <- run.jags(model_parallel, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='parallel')
  + 		stopifnot(niter(as.mcmc.list(results))==1000)
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='interruptible')
  + 		stopifnot(niter(as.mcmc.list(results))==1000)
  + 
  + 		# Same as in checkinputs but it's for rjags there:
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results2 <- extend.jags(results, sample=1000, add.monitor="true.y", summarise=FALSE)
  + 		stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 		stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "dic"), summarise=FALSE)
  + 		stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 		stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "deviance"), summarise=FALSE)
  + 		stopifnot(nvar(as.mcmc.list(results2))==(4+N))
  + 		stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[104]=='deviance')
  + 
  + 		# Same as in checkinputs but it's for rjags there:
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results2 <- extend.jags(results, sample=1000, add.monitor="true.y", summarise=FALSE, method='simple')
  + 		stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 		stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "dic"), summarise=FALSE)
  + 		stopifnot(nvar(as.mcmc.list(results2))==(3+N))
  + 		stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[103]=='true.y[100]')
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results2 <- extend.jags(results, sample=1000, add.monitor=c("true.y", "deviance"), summarise=FALSE)
  + 		stopifnot(nvar(as.mcmc.list(results2))==(4+N))
  + 		stopifnot(varnames(as.mcmc.list(results2))[1]=='m' && varnames(as.mcmc.list(results2))[104]=='deviance')
  + 
  + 		# Snow gives problems here ... but it does work!
  + 		#results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='snow')
  + 		#stopifnot(niter(as.mcmc.list(results))==1000)
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		info <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='background')
  + 		t <- 0
  + 		repeat{
  + 			# Change thin, chain and variables:
  + 			s <- try(results <- results.jags(info, read.monitor='m', return.samples=100, recover.chains=2, summarise=FALSE))
  + 			if(!inherits(s, 'try-error')) break
  + 			if(t==30) stop("Timed out waiting for the bgparallel method")
  + 			Sys.sleep(1)
  + 			t <- t+1
  + 		}
  + 		stopifnot(niter(as.mcmc.list(results))==100)
  + 		stopifnot(nvar(as.mcmc.list(results))==1)
  + 		stopifnot(nchain(as.mcmc.list(results))==1)
  + 
  + 
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		info <- run.jags(model_parallel, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='bgparallel')
  + 		t <- 0
  + 		repeat{
  + 			s <- try(results <- results.jags(info))
  + 			if(!inherits(s, 'try-error')) break
  + 			if(t==30) stop("Timed out waiting for the bgparallel method")
  + 			Sys.sleep(1)
  + 			t <- t+1
  + 		}
  + 		stopifnot(niter(as.mcmc.list(results))==1000)
  + 
  + 		# Check combine.mcmc does what it says on the tin:
  + 		stopifnot(niter(combine.mcmc(results, return.samples=1000, collapse.chains=TRUE))==1000)
  + 		stopifnot(niter(combine.mcmc(results, return.samples=11, collapse.chains=TRUE))==11)
  + 		stopifnot(niter(combine.mcmc(results, return.samples=100, collapse.chains=FALSE))==100)
  + 		stopifnot(niter(combine.mcmc(results, thin=1, collapse.chains=TRUE))==2000)
  + 		stopifnot(niter(combine.mcmc(results, thin=10, collapse.chains=TRUE))==200)
  + 		stopifnot((niter(combine.mcmc(results, thin=15, collapse.chains=TRUE))*15)>=2000)
  + 		stopifnot(niter(combine.mcmc(results, thin=10, collapse.chains=FALSE))==100)
  + 
  + 		# Check we can use the extend wrapper:
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		newres <- extend.jags(results, sample=0)
  + 		stopifnot(newres$burnin==results$burnin)
  + 		stopifnot(niter(as.mcmc.list(newres))==niter(as.mcmc.list(results)))
  + 
  + 		# Check a single iteration works:
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results <- run.jags(model, n.chains=2, sample=1, burnin=1000, inits=initfunction, method='interruptible', summarise=FALSE)
  + 		stopifnot(niter(as.mcmc.list(results))==1)
  + 
  + 		# And that precision can be ignored:
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		results <- run.jags(model, monitor=c('m','c'), n.chains=2, sample=10, burnin=100, inits=initfunction, method='interruptible', summarise=FALSE, noread.monitor='precision')
  + 		stopifnot(nvar(as.mcmc.list(results))==2)
  + 
  + 		# Check the version number is correct:
  + 		cat('Running method test number', testnum, '\n'); testnum <- testnum+1
  + 		stopifnot(newres$runjags.version[1]==runjags:::runjagsprivate$runjagsversion)
  + 
  + 	}
  + }else{
  + 	cat("JAGS could not be called externally at the path: ", jagspath, "\n")
  + 	cat("All test methods except possibly rjags and rjagsparallel were skipped\n")
  + }
  You are using R Under development (unstable) (2023-08-19 r84989) on a
  unix machine, with the X11 GUI
  JAGS version 4.3.2 found successfully using the command '/usr/bin/jags'
  The rjags package is installed
  Testing the simple method
  Running the simulation using the simple method... (output will be
  displayed once the simulation has termianted)
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Finished running the simulation
  Running method test number 1 
  Running method test number 2 
  Calling 2 simulations using the parallel method...
  All chains have finished
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  In addition: Warning message:
  In runjags.summaries(fullmcmclist = mcmc, thinnedmcmclist = thinnedmcmc,  :
    An unexpected error occured while calculating the mode
  Finished running the simulation
  Running method test number 3 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  In addition: Warning message:
  In runjags.summaries(fullmcmclist = mcmc, thinnedmcmclist = thinnedmcmc,  :
    An unexpected error occured while calculating the mode
  Finished running the simulation
  Running method test number 4 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 5 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 6 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 7 
  Running the simulation using the simple method... (output will be
  displayed once the simulation has termianted)
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 8 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 9 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 10 
  Starting the simulation in the background...
  The JAGS process is now running in the background
  
  JAGS model output(s):
  
  
  1   |  Welcome to JAGS 4.3.2 on Mon Aug 21 01:53:59 2023
  2   |  JAGS is free software and comes with ABSOLUTELY NO WARRANTY
  3   |  Loading module: basemod: ok
  4   |  Loading module: bugs: ok
  5   |  Loading module: dic: ok
  6   |  Reading data file data.txt
  7   |  Compiling model graph
  8   |     Resolving undeclared variables
  9   |     Allocating nodes
  10  |  Graph information:
  11  |     Observed stochastic nodes: 100
  12  |     Unobserved stochastic nodes: 3
  13  |     Total graph size: 407
  14  |  Reading parameter file inits1.txt
  15  |  Reading parameter file inits2.txt
  16  |  Initializing model
  17  |  Adapting 1000
  18  |  Adaptation successful
  19  |  Updating 1000
  20  |  Updating 1000
  
  Error in results.jags(info, read.monitor = "m", return.samples = 100,  : 
    The simulation has not finished
  In addition: Warning message:
  In runjags.summaries(fullmcmclist = mcmc, thinnedmcmclist = thinnedmcmc,  :
    An unexpected error occured while calculating the mode
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 11 
  Starting 2 simulations in the background...
  The JAGS processes are now running in the background
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Finished running the simulation
  Running method test number 12 
  Running method test number 13 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 14 
  Calling the simulation...
  
  Simulation complete.  Reading coda files...
  Coda files loaded successfully
  Finished running the simulation
  Running method test number 15 
  Warning message:
  In runjags.summaries(fullmcmclist = mcmc, thinnedmcmclist = thinnedmcmc,  :
    An unexpected error occured while calculating the mode
  > 
  > testnum <- 1
  > if(require("rjags")){
  + 	cat('Running rjags method test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='rjags')
  + 	stopifnot(niter(as.mcmc.list(results))==1000)
  + 
  + 	cat('Running rjags method test number', testnum, '\n'); testnum <- testnum+1
  + 	results <- run.jags(model, n.chains=2, sample=1, burnin=1000, inits=initfunction, method='rjags', summarise=FALSE)
  + 	stopifnot(niter(as.mcmc.list(results))==1)
  + 
  + 	cat('Running rjags method test number', testnum, '\n'); testnum <- testnum+1
  + 	runjags.options(silent.jags=TRUE, silent.runjags=TRUE, debug=FALSE)
  + 	output <- capture.output(results <- run.jags(model_parallel, n.chains=2, sample=1000, burnin=1000, inits=initfunction, method='rjparallel'))
  + 	stopifnot(length(output)==0)
  + 	stopifnot(niter(as.mcmc.list(results))==1000)
  + }else{
  + 	cat("The rjags and rjagsparallel method checks were skipped as the rjags package is not installed\n")
  + }
  Running rjags method test number 1 
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Calls: run.jags ... as.numeric_version -> numeric_version -> .make_numeric_version
  Execution halted
Running the tests in ‘tests/checkmodule.R’ failed.
Complete output:
  > library("runjags")
  > runjags.options(nodata.warning=FALSE)
  > 
  > # Checks that the runjags module distributions are correct.
  > 	
  > # Loading the dynlib requires rjags for Windows:
  > if(.Platform$OS.type != 'windows' || requireNamespace('rjags')){
  + 
  + 	loaded <- runjags:::dynloadmodule()	
  + 	if(!loaded)
  + 		stop("The internal JAGS dynlib could not be loaded - if you installed this package from CRAN, please file a bug report to the package author")
  + 
  + 	cat('Running module tests\n')
  + 
  + 	# Required for nchain etc:
  + 	library("coda")
  + 
  + 	load("moduletargets.Rsave")
  + 
  + 	checksok <- rep(TRUE, N)
  + 	for(i in 1:N){
  + 		success <- try({
  + 		obs <- runjags:::userunjagsmodule(tests[[i]]$distribution, tests[[i]]$funtype, tests[[i]]$parameters, tests[[i]]$x, tests[[i]]$uselog, tests[[i]]$lower)
  + 		expect <- results[[i]]
  + 
  + 		# Allow a bit of a larger tolerance than usual as we have saved the results from a different machine:
  + 		problem <- abs(expect-obs) > max(10^-5, .Machine$double.eps^0.5)
  + 
  + 		# Or obs is NA:
  + 		problem[is.na(problem)] <- TRUE
  + 		if(any(problem)){
  + 			cat("Error with check number ", i, " (which expected observed):  ", paste(paste(which(problem), " ", expect[problem], " ", obs[problem], ";  ", sep=""), collapse=""), "\n", sep="")
  + 			checksok[i] <- FALSE
  + 		}
  + 		})
  + 		if(inherits(success, 'try-error')){
  + 			checksok[i] <- FALSE
  + 			cat("Uncaught crash error with check number", i, "\n")
  + 		}
  + 	}
  + 
  + 	if(!all(checksok)) stop(paste("The runjags module checks failed for test number(s) ", paste(which(!checksok),collapse=","), sep=""))
  + 	
  + 	# From:  Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models. Bayesian Analysis, (3), 515–533.
  + 	# ... the half cauchy should be the same as a ratio of two gammas:
  + 	scale <- seq(1,100,length.out=10)
  + 	quantiles <- seq(0.05,0.95,length.out=10)
  + 	checksok <- rep(TRUE, 10)
  + 	set.seed(1)
  + 
  + 	for(i in 1:10){
  + 		success <- try({
  + 
  + 		xi <- rnorm(10^6, 0, sd=scale[i])
  + 		tau <- rgamma(10^6, shape=0.5, rate=0.5)  	# Chi-squared with 1 df - i.e.= rchisq(10^6, 1)
  + 		gelman <- abs(xi)/sqrt(tau)
  + 		expect <- quantile(gelman,quantiles)
  + 		obs <- runjags:::userunjagsmodule('halfcauchy', 'q', scale[i], quantiles, FALSE, TRUE)
  + 		# Allow a fairly large 5% tolerance as this is a numerical approximation:
  + 		problem <- (abs(expect-obs)/expect) > 0.05
  + 
  + 		# Or obs is NA:
  + 		problem[is.na(problem)] <- TRUE
  + 		if(any(problem)){
  + 			cat("Error with Half Cauchy check number ", i, " - scale=", scale[i], " - (which expected observed):  ", paste(paste(which(problem), " ", expect[problem], " ", obs[problem], ";  ", sep=""), collapse=""), "\n", sep="")
  + 			checksok[i] <- FALSE
  + 		}
  + 		})
  + 		if(inherits(success, 'try-error')){
  + 			checksok[i] <- FALSE
  + 			cat("Uncaught crash error with Half Cauchy check number", i, "\n")
  + 		}		
  + 	}
  + 	if(!all(checksok)) stop(paste("The runjags module Half Cauchy checks failed for test number(s) ", paste(which(!checksok),collapse=","), sep=""))
  + 	
  + 	cat("The internal module tests were passed\n")
  + }else{
  + 	cat("The internal module tests were skipped (not available on Windows)\n")
  + }
  Loading shared library from:
  /home/hornik/tmp/scratch/Rtmp2ybPyB/RLIBS_37e97f773828fe/runjags/libs/runjags.so
  Running module tests
  The internal module tests were passed
  > 
  > 
  > # Require the rjags library to run the rest of the checks:
  > dotests <- TRUE
  > if(!require("rjags")){
  + 	cat("The module checks were not performed as rjags is not installed\n")
  + 	dotests <- FALSE
  + }
  Loading required package: rjags
  Linked to JAGS 4.3.2
  Loaded modules: basemod,bugs
  > 
  > if(dotests){
  + 	
  + 	# Try to load the module:
  + 	loaded <- load.runjagsmodule(fail=FALSE)
  + 	if(!loaded){		
  + 		warning("The module checks were not performed as the internal JAGS module could not be loaded")
  + 		dotests <- FALSE
  + 	}
  + 
  + 	# Now check the JAGS implementations just to make sure the functions are found OK:
  + 
  + 	m <- "model{
  + 	
  + 		r0 ~ dpar(1,1)
  + 		f0 ~ dpar(1,1)
  + 		d0 <- dpar(0.5,1,1)
  + 		p0 <- ppar(0.5,1,1)
  + 		q0 <- qpar(0.5,1,1)
  + 	
  + 		r1 ~ dpar1(1,1)
  + 		f1 ~ dpar1(1,1)
  + 		d1 <- dpar1(0.5,1,1)
  + 		p1 <- ppar1(0.5,1,1)
  + 		q1 <- qpar1(0.5,1,1)
  + 	
  + 		r2 ~ dpar2(1,1,0)
  + 		f2 ~ dpar2(1,1,0)
  + 		d2 <- dpar2(0.5,1,1,0)
  + 		p2 <- ppar2(0.5,1,1,0)
  + 		q2 <- qpar2(0.5,1,1,0)
  + 
  + 		r3 ~ dpar3(1,0,1)
  + 		f3 ~ dpar3(1,0,1)
  + 		d3 <- dpar3(0.5,1,0,1)
  + 		p3 <- ppar3(0.5,1,0,1)
  + 		q3 <- qpar3(0.5,1,0,1)
  + 
  + 		r4 ~ dpar4(1,1,0,1)
  + 		f4 ~ dpar4(1,1,0,1)
  + 		d4 <- dpar4(0.5,1,1,0,1)
  + 		p4 <- ppar4(0.5,1,1,0,1)
  + 		q4 <- qpar4(0.5,1,1,0,1)
  + 
  + 		rl ~ dlomax(1,1)
  + 		fl ~ dlomax(1,1)
  + 		dl <- dlomax(0.5,1,1)
  + 		pl <- plomax(0.5,1,1)
  + 		ql <- qlomax(0.5,1,1)
  + 	
  + 		rm ~ dmouch(1)
  + 		fm ~ dmouch(1)
  + 		dm <- dmouch(0.5,1)
  + 		pm <- pmouch(0.5,1)
  + 		qm <- qmouch(0.5,1)
  + 	
  + 		rg ~ dgenpar(1,1,1)
  + 		fg ~ dgenpar(1,1,1)
  + 		dg <- dgenpar(0.5,1,1,1)
  + 		pg <- pgenpar(0.5,1,1,1)
  + 		qg <- qgenpar(0.5,1,1,1)
  + 
  + 		rh ~ dhalfcauchy(25)
  + 		fh ~ dhalfcauchy(25)
  + 		dh <- dhalfcauchy(25, 25) 
  + 		ph <- phalfcauchy(25, 25) 
  + 		qh <- qhalfcauchy(0.5, 25) 
  + 	
  + 		#monitor# r0,d0,p0,q0,r1,d1,p1,q1,r2,d2,p2,q2,r3,d3,p3,q3,r4,d4,p4,q4,rl,dl,pl,ql,rg,dg,pg,qg,rm,dm,pm,qm,rh,fh,dh,ph,qh
  + 		#data# f0, f1, f2, f3, f4, fl, fg, fm, fh
  + 		#inits# rg
  + 	}"
  + 	rg <- list(1,2)
  + 	f0=f1=f2=f3=f4=fl=fg=fm=fh <- 2
  + 
  + 	r <- run.jags(m, n.chains=2, burnin=100, sample=100, method='rjags')
  + 	stopifnot(nchain(as.mcmc.list(r))==2)
  + 
  + 
  + 	# Now check that my p and q functions are symmetric:
  + 
  + 	m <- "model{
  + 	
  + 		qsn <- qnorm(sp, cont1, pos1)
  + 		psn <- pnorm(qsn, cont1, pos1)
  + 
  + 		qsg <- qgamma(sp, pos1, pos2)
  + 		psg <- pgamma(qsg, pos1, pos2)
  + 	
  + 		qsl <- qlnorm(sp, cont1, pos2)
  + 		psl <- plnorm(qsl, cont1, pos2)
  + 
  + 		qsp <- qpar(sp, pos1, pos2)
  + 		psp <- ppar(qsp, pos1, pos2)
  + 	
  + 		qsp1 <- qpar1(sp, pos1, pos2)
  + 		psp1 <- ppar1(qsp1, pos1, pos2)
  + 	
  + 		qsp2 <- qpar2(sp, pos1, pos2, cont1)
  + 		psp2 <- ppar2(qsp2, pos1, pos2, cont1)
  + 	
  + 		qsp3 <- qpar3(sp, pos1, cont1, pos3)
  + 		psp3 <- ppar3(qsp3, pos1, cont1, pos3)
  + 	
  + 		qsp4 <- qpar4(sp, pos1, pos2, cont1, pos3)
  + 		psp4 <- ppar4(qsp4, pos1, pos2, cont1, pos3)
  + 	
  + 		qsgp <- qgenpar(sp, pos1, cont2, cont1)
  + 		psgp <- pgenpar(qsgp, pos1, cont2, cont1)
  + 	
  + 		qslm <- qlomax(sp, pos1, pos2)
  + 		pslm <- plomax(qslm, pos1, pos2)
  + 	
  + 		qsm <- qmouch(sp, pos1)
  + 		psm <- pmouch(qsm, pos1)
  + 	
  + 		qshc <- qhalfcauchy(sp, pos1)
  + 		pshc <- phalfcauchy(qshc, pos1)
  + 	
  + 		dummy ~ dlomax(1,1)
  + 	
  + 		#monitor# psn, psg, psl, psp1, psp2, psp3, psp4, psgp, pslm, psm, qshc, pshc, 
  + 
  + 		#  There appears to be a bug in the code for qpar:	
  + 		#psp,
  + 		#data# sp, cont1, cont2, pos1, pos2, pos3
  + 		#inits# dummy
  + 	}"
  + 
  + 	dummy <- 2
  + 	sp <- 1:9/10
  + 	set.seed(1)
  + 	cont1 <- runif(1,-10,10)
  + 	cont2 <- runif(1,-10,10)
  + 	pos1 <- rgamma(1,1,1)
  + 	pos2 <- rgamma(1,1,1)
  + 	pos3 <- rgamma(1,1,1)
  + 
  + 	r <- run.jags(m, burnin=100, sample=10, n.chains=1, method='rjags', summarise=FALSE)
  + 
  + 	sp <- rep(sp,11)
  + 	ps <- combine.mcmc(r,vars='ps')[1,]
  + 	stopifnot(length(sp)==length(ps))
  + 	if(!isTRUE(all.equal(sp,ps))){
  + 		# Reduce stringency of the test - roughly 10^7 different on linux:
  + 		problem <- abs(sp-ps) > max(10^-4, .Machine$double.eps^0.5)
  + 		if(any(problem)) stop(paste("Error with ps/sp check (which expected observed):  ", paste(paste(names(ps)[which(problem)], " ", sp[problem], " ", ps[problem], ";  ", sep=""), collapse=""), sep=""))
  + 	}
  + 	
  + 	cat("The runjags module tests were passed\n")
  + 	
  + }else{
  + 	cat("The runjags module tests were skipped (rjags not installed)\n")
  + }
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Calls: load.runjagsmodule ... as.numeric_version -> numeric_version -> .make_numeric_version
  Execution halted
  Unloading shared library from:
  /home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/runjags/libs/runjags.so
  Error in dyn.unload(slibpath) : 
    shared object '/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/runjags/libs/runjags.so' was not loaded
  Warning message:
  In dynunloadmodule() : The internal dynlib could not be unloaded
Running the tests in ‘tests/checkstudy.R’ failed.
Complete output:
  > # Requires rjags:
  > if(require('rjags')){
  + 
  + 
  + 	library('runjags')
  + 	runjags.options(inits.warning=FALSE, rng.warning=FALSE, blockignore.warning=FALSE)
  + 
  + 	library('parallel')
  + 
  + 	testnum <- 1
  + 
  + 	themodel <- "
  + 	model{
  + 
  + 		for(i in 1:N){
  + 			Y[i] ~ dnorm(true.y[i], precision)
  + 			true.y[i] <- (m * X[i]) + c
  + 		}
  + 		m ~ dunif(-1000,1000)
  + 		c ~ dunif(-1000,1000)
  + 		precision ~ dexp(1)
  + 
  + 		#data# N, X
  + 	}"
  + 
  + 	# Simulate the data
  + 	set.seed(1)
  + 	N <- 20
  + 	X <- 1:N
  + 	Y <- rnorm(length(X), 2*X + 1, 1)
  + 
  + 	# Some initial values to use for 2 chains:
  + 
  + 	initfun <- function(chain){
  + 
  + 		# data is made available within this function when it
  + 		# is evaluated for each simulation:
  + 		stopifnot(length(data$X) == data$N)
  + 
  + 		m <- c(-10,10)[chain]
  + 		c <- c(10,-10)[chain]
  + 		precision <- c(0.01,100)[chain]
  + 
  + 		.RNG.seed <- chain
  + 		.RNG.name <- c("base::Super-Duper",
  + 		"base::Wichmann-Hill")[chain]
  + 
  + 		return(list(m=m, c=c, precision=precision,
  + 		.RNG.seed=.RNG.seed, .RNG.name=.RNG.name))
  + 	}
  + 
  + 	# A simple function that removes (over-writes with NA) one datapoint at a time:
  + 	datafun <- function(s){
  + 		simdata <- Y
  + 		simdata[s] <- NA
  + 		return(list(Y=simdata))
  + 	}
  + 
  + 
  + 	# Set up a cluster to use with the parLapply method:
  + 	cat('Running study test number', testnum, '\n'); testnum <- testnum+1
  + 	cl <- makeCluster(2)
  + 	# Call the simulations over the snow cluster:
  + 	results <- run.jags.study(simulations=4, model=themodel, datafunction=datafun,
  + 	targets=list(Y=Y, m=2, c=1), n.chains=2, inits=initfun, cl=cl)
  + 
  + 
  + 	m <- 'model{
  + 	d[1] ~ dpois(mu)
  + 	d[2] ~ dpois(mu)
  + 	d[3] ~ dpois(mu)
  + 	mu ~ dgamma(1,1)
  + 	#monitor# mu
  + 	#data# d
  + 	}'
  + 
  + 	##### Can't test any more than 2 spawned processes on winbuilder #####
  + 
  + 	cat('Running study test number', testnum, '\n'); testnum <- testnum+1
  + 	mu <- list(1,1)
  + 	d <- c(5, 4, 7)
  + 	jr <- run.jags(m, method='rjags', n.chains=2, inits=list(list(mu=1), list(mu=1)), silent.jags=TRUE)
  + 	# Drop 1 (would create 3 clusters except we pass it cl):
  + 	r <- drop.k(jr, dropvars='d', cl=cl)
  + 	stopCluster(cl)
  + 
  + 	# Drop k (use lapply so we don't create a cluster with 4 nodes):
  + 	cat('Running study test number', testnum, '\n'); testnum <- testnum+1
  + 	r <- drop.k(jr, dropvars='d', simulations=4, k=2, silent.jags=TRUE, parallel.method=lapply)
  + 	
  + 	cat("All study/drop-k checks passed\n")
  + 	
  + }else{
  + 	cat("Note: the rjags package is not installed, so the study/drop-k tests were skipped\n")
  + }
  Loading required package: rjags
  Loading required package: coda
  Linked to JAGS 4.3.2
  Loaded modules: basemod,bugs
  Running study test number 1 
  
  Starting a JAGS study at 01:54
  Testing the model and data for simulation 2...
  Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
    invalid non-character version specification 'x' (type: double)
  Calls: run.jags.study ... as.numeric_version -> numeric_version -> .make_numeric_version
  Execution halted
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(runjags)
  > 
  > test_check("runjags")
  Loading required namespace: rjags
  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]
  
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Error ('test-basic_example.R:2:3'): basic example works ─────────────────────
  Error in `.make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version)`: invalid non-character version specification 'x' (type: double)
  Backtrace:
      ▆
   1. └─runjags:::example_runjags() at test-basic_example.R:2:2
   2.   └─runjags::run.jags(...)
   3.     └─runjags:::setup.jagsfile(...)
   4.       └─runjags:::setup.jags(...)
   5.         └─runjags:::loadandcheckrjags()
   6.           └─base::Ops.numeric_version(packageVersion("rjags"), 3.9)
   7.             └─base::as.numeric_version(e2)
   8.               └─base::numeric_version(x)
   9.                 └─base::.make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version)
  
  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]
  Error: Test failures
  Execution halted