Skip to content

Add a timeout option for individual model fits #157

@beckyfisher

Description

@beckyfisher

I have come across some cases where some individual models are taking a long time to fit, typically with highly divergent chains. It would be helpful to add a timeout option in [R/fit_bayesnec.R] at line 61 to allow the user to set a maximum limit for fitting any one model, such that the rest of the models are still fit. The withTimout function from R.utils seems like a good option, wrapped in try. Testing suggests this does still kill the models on any workers when multiple cores are used.

library(R.utils)
library(brms)
options(brms.backend = 'cmdstanr')
require(bayesnec)
data("nec_data")

tt <- try(withTimeout(
  bnec(formula = y ~ crf(x, model = "nec3param"),
        iter = 200000, warmup = 150, chains = 3, cores = 3,
       seed = 10, data = nec_data), 
timeout = 70, onTimeout = "error")) 

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions