-
-
Notifications
You must be signed in to change notification settings - Fork 67
initiailizing with a draws or fit object fails if the model is created without a .stan file #1088
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
If a model is created without a .stan file, that is only with an exe_file, using another fit object (or draws) as an init fails with an uninformative error message.
To Reproduce
library(cmdstanr)
model_code <- "data {
int N;
array[N] real x;
}
parameters {
real mu;
}
model {
// likelihood including constants
x ~ normal(mu, 1);
}
"
model <- cmdstan_model(write_stan_file(model_code), exe_file = "model_bin")
model_nostanfile <- cmdstan_model(exe_file = "model_bin")
d <- list(x = c(1,2,3,4,5), N = 5)
pth <- model$pathfinder(
data = d
)
# works fine
mcmcfit <- model$sample(
data = d,
init = pth
)
# fails Error: 'init' contains empty lists.
mcmcfit_nostanfile<- model_nostanfile$sample(
data = d,
init = pth
)
Expected behavior
The sampling succeeds, or a more informative error message is given.
Operating system
Linux (Ubuntu 24.04.2)
CmdStanR version number
0.9.0
Additional context
I believe this is due to model_nostanfile$variables() failing to determine which parameters are in the model, but I think passing all the variable inits without determining which variables are actually in the model should still work
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working