This issue was reported to me by @spinkney and it seems to have made its way to the 2.28.0 release.
The model:
data {
int<lower=0> K;
vector[10] y;
}
parameters {
simplex[K] s;
real<lower=0> lambda;
}
model {
y ~ exponential(lambda);
}
If you sample without specifying any initial values, it samples fine, but if you specify the initial value only for lambda it outputs:
Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: stan::math::simplex_free: Simplex variable is not a valid simplex. sum(Simplex variable) = 2.384263259, but should be 1 (found before start of program)
Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: stan::math::simplex_free: Simplex variable is not a valid simplex. sum(Simplex variable) = 2.274321496, but should be 1 (found before start of program)
This however works fine with 2.27.0 (sampling finishes with 0 warnings or errors).
It also fails with cmdstan 2.27.0 and the 2.28.0 stanc3 binary which leads me to believe this is a stanc3 issue.
Here is a folder with all the required files to reproduce:
reprex.zip
Reproduce simply by running:
./model sample data file=data.json init=init.json
You can also run with cmdstanr:
library(cmdstanr)
code <- "
data {
int<lower=0> K;
vector[10] y;
}
parameters {
simplex[K] s;
real<lower=0> lambda;
}
model {
y ~ exponential(lambda);
}
"
stan_file <- write_stan_file(code)
mod_test <- cmdstan_model(stan_file)
fit_opt <- mod_test$sample(
data = list(K = 3, y = rexp(n = 10, 4)),
init = list(list(lambda = 2)),
chains = 1
)
This issue was reported to me by @spinkney and it seems to have made its way to the 2.28.0 release.
The model:
If you sample without specifying any initial values, it samples fine, but if you specify the initial value only for
lambdait outputs:This however works fine with 2.27.0 (sampling finishes with 0 warnings or errors).
It also fails with cmdstan 2.27.0 and the 2.28.0 stanc3 binary which leads me to believe this is a stanc3 issue.
Here is a folder with all the required files to reproduce:
reprex.zip
Reproduce simply by running:
You can also run with cmdstanr: