Running ‘bym.R’ [24s/56s]
  Running ‘cancerRates.R’ [11s/36s]
  Running ‘getRates.R’ [15s/46s]
  Running ‘getSMR.R’ [16s/43s]
Running the tests in ‘tests/bym.R’ failed.
Complete output:
  > havePackages = c(
  +   'INLA' = requireNamespace('INLA', quietly=TRUE)
  + )
  The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
  which was just loaded, will retire in October 2023.
  Please refer to R-spatial evolution reports for details, especially
  https://r-spatial.org/r/2023/05/15/evolution4.html.
  It may be desirable to make the sf package available;
  package maintainers should consider adding sf to Suggests:.
  The sp package is now running under evolution status 2
       (status 2 uses the sf package in place of rgdal)
  > 
  > print(havePackages)
  INLA 
  TRUE 
  > 
  > library('diseasemapping')
  > data('kentucky')
  > kentucky = terra::unwrap(kentucky)
  > 
  > 
  > 
  > 
  > 
  > kentucky = getSMR(kentucky, larynxRates, larynx,
  + 		regionCode="County")
  > 
  > kentuckyAdjMat = terra::adjacent(kentucky)
  > attributes(kentuckyAdjMat)$region.id = kentucky$County
  > 
  > if(all(havePackages)){
  + 
  +   kBYM = bym(
  + 			formula = observed ~ offset(logExpected) + poverty,
  +       data=terra::values(kentucky),
  + 			adjMat = kentuckyAdjMat,
  +       prior = list(sd=c(0.1, 0.5), propSpatial=c(0.5, 0.5)),
  + 			region.id='County',
  + 			control.predictor=list(compute=TRUE)
  +   )
  + 	kBYM$parameters$summary
  + 
  + 	if(!interactive()) pdf("priorPostKentucky.pdf")
  + 	plot(kBYM$parameters$sd$posterior, type='l', xlim = c(0, 1), lwd=2)
  + 	lines(kBYM$parameters$sd$prior, col='blue')
  + 	legend('topright', lty=1, col=c('black','blue'), legend=c('posterior','prior'))
  + 	if(!interactive()) dev.off()
  + 
  + 	
  + 	
  + 
  + 
  + # also try no covariate or adj mat
  + 
  + kBYM = bym(
  + 		formula = observed ~ offset(logExpected),
  + 		prior = list(sd = 0.5, propSpatial = 0.5),
  + 		data=kentucky)
  + 
  + 
  + 
  +  	kBYM$data$exc1 =  unlist(lapply(kBYM$inla$marginals.fitted.bym, INLA::inla.pmarginal, q=log(1.2)))
  + 
  + kBYM$par$summary
  + 
  + if(require('mapmisc', quietly=TRUE)) {
  + 
  + colFit = colourScale(kBYM$data$fitted.exp,
  + 		breaks=6, dec=3)
  + 	
  + plot(kBYM$data, col=colFit$plot)
  + legendBreaks('topleft', colFit)
  + 
  + colExc = colourScale(kBYM$data$exc1 ,
  + 		style='fixed',
  + 		breaks=c(0, 0.2, 0.8,0.9, 1), 
  + 		col=rainbow, rev=TRUE
  + 	)
  + 
  + 	plot(kBYM$data, col=colExc$plot)
  + 	legendBreaks('topleft', colExc)
  +  		
  + }
  + 
  + 	
  + # subtract a few regions
  + 
  + kBYM = bym(
  +     formula=observed ~ offset(logExpected) + poverty,
  +     data=terra::values(kentucky)[-(1:4),],  
  +  	  adjMat = kentuckyAdjMat, region.id="County",
  + 		prior = list(sd=0.1, propSpatial = 0.1))
  +  
  + 
  + kBYM$par$summary
  + 
  + # intercept only, no offset
  + 
  + 
  + kBYM = bym(data=kentucky,  formula=observed ~ 1,
  + 		prior = list(sd=1, propSpatial=0.9))
  + 
  + kBYM$par$summary
  + 
  + 
  + if(require('mapmisc', quietly=TRUE)) {
  + 	
  + 	colFit = colourScale(kBYM$data$fitted.exp,
  + 			breaks=6, dec=1)
  + 	
  + 	plot(kBYM$data, col=colFit$plot)
  + 	legendBreaks('topleft', colFit)
  + 	
  + }
  + 
  +  
  + 
  + # give spdf but some regions have no data
  + # but keep the 'county' column as is
  + kentucky[1:2,-grep("County", names(kentucky))] = NA 
  + 
  + kBYM = bym(observed ~ offset(logExpected) + poverty,
  + 		kentucky, 
  + 		region.id="County",
  + 		prior = list(sd=0.1, propSpatial = 0.5))
  + 
  +  
  + kBYM$par$summary
  + 
  + 
  + # missing value in a categorical variable
  + 
  + pCuts = quantile(kentucky$poverty, na.rm=TRUE)
  + kentucky$povertyFac = cut(kentucky$poverty, 
  + 		breaks = pCuts,
  + 		labels = letters[seq(1,length(pCuts)-1)])
  + kentucky$povertyFac[c(2,34,100)] = NA
  + 
  + kBYM = bym(
  + 		formula = observed ~ offset(logExpected) + povertyFac,
  + 		data = kentucky, 
  + 		region.id="County",
  + 		prior = list(sd=c(0.1, 0.5), propSpatial=c(0.1, 0.5))
  + )
  + 
  + 
  + kBYM$par$summary
  + }
  Error in .check_ncores(cores) : 24 simultaneous processes spawned
  
   *** inla.core.safe:  inla.program has crashed: rerun to get better initial values. try=1/2 
  Error in .check_ncores(cores) : 24 simultaneous processes spawned
  
   *** inla.core.safe:  inla.program has crashed: rerun to get better initial values. try=2/2 
  Error in .check_ncores(cores) : 24 simultaneous processes spawned
  Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts,  : 
    *** Fail to get good enough initial values. Maybe it is due to something else.
  Calls: bym -> bym -> .local -> <Anonymous> -> inla.core.safe
  Execution halted