charlesm93 / example-models

Example models for Stan
http://mc-stan.org/
5 stars 1 forks source link

cmt should be ignored when it is not relevant #2

Closed billgillespie closed 7 years ago

billgillespie commented 7 years ago

Currently the Torsten functions issue an exception when cmt < 1:

Exception: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0__] is 0, but must be greater than or equal to 1 Diagnostic information:

For observation records, e.g., evid = 0, this is an unnecessary restriction. Please change this so that the exception only occurs for dosing records.

charlesm93 commented 7 years ago

Could you send me the full error message?

billgillespie commented 7 years ago

Here is the call using cmdstan and the resulting messages. The model, script and data files are attached. In this case I deliberately changed the cmt values to produce the error. It runs fine if I leave the cmt values at 2.

mclapply(chains,

  • function(chain, model, data, iter, warmup, thin, init, tempDir = "temp"){
  • tempDir <- file.path(tempDir, chain)
  • dir.create(tempDir)
  • with(data, stan_rdump(ls(data), file = file.path(tempDir, "data.R")))
  • inits <- init()
  • with(inits, stan_rdump(ls(inits), file = file.path(tempDir, "init.R")))
  • runModel(model = model, data = file.path(tempDir, "data.R"),
  • iter = iter, warmup = warmup, thin = thin,
  • init = file.path(tempDir, "init.R"), seed = sample(1:999999, 1),
  • chain = chain, refresh = 100)
  • ,

  • adapt_delta = 0.95, stepsize = 0.01)

  • },
  • model = file.path(modelDir, modelName),
  • data = data,
  • init = init,
  • iter = nIter, warmup = nBurnin, thin = nThin,
  • mc.cores = min(nChains, detectCores()))

Exception: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0__] is 0, but must be greater than or equal to 1 Diagnostic information:

Exception: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0__] is 0, but must be greater than or equal to 1Exception: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0__] is 0, but must be greater than or equal to 1Diagnostic information:

Diagnostic information: Dynamic exception type: std::domain_error std::exception::what: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0] is 0, but must be greater than or equal to 1 Dynamic exception type: std::domain_error std::exception::what: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0] is 0, but must be greater than or equal to 1 Dynamic exception type: std::domain_error std::exception::what: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0__] is 0, but must be greater than or equal to 1

Exception: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0] is 0, but must be greater than or equal to 1 Diagnostic information: Dynamic exception type: std::domain_error std::exception::what: TwoCptModel_model_namespace::TwoCptModel_model: cmt[k0] is 0, but must be greater than or equal to 1

[[1]] [1] 255

[[2]] [1] 255

[[3]] [1] 255

[[4]] [1] 255

TwoCptModelFiles.zip

charlesm93 commented 7 years ago

The stan model had a constrained on cmt (int cmt), which caused the error. No fix in Torsten required.