Open spinkney opened 1 year ago
Thanks for reporting!
The underlying problem is that if you look at datasets_flat$variables
, you'll notice that it treats x
as 2D array, so the variables are called x[1,1], x[1,2]
... , while the variables in Stan fit are called x[1], x[2]
. SBC then finds no shared variables and this leads to problems. This deserves a better error message.
However, you can get the code to work by changing to:
generate_one_dataset <- function(N, K, prior_alpha = 1) {
x <- as.numeric(rdirichlet(1, alpha = rep(prior_alpha, K)))
observed <- as.integer(rmultinom(1, size = N, prob = x))
list(
variables = list(x = x),
generated = list(K = K, observed = observed, prior_alpha = prior_alpha)
)
}
Also note that the $generated
element of datasets is already in format to be pushed to Stan, so you can simplify your test with:
y_out <- m$sample(
data = y$generated,
parallel_chains = 4
)
I'll try to inform messages around this issue...
Thanks for the quick response @martinmodrak!
I'm not sure how to proceed after getting this error
With this code
and Stan model