-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obtain data and parameter names from the model + checks for data and init arguments #430
Comments
Thanks! Other uses of this are:
|
The required stanc3 code is now in develop.
WIll close this issue once we make a "prepare stuff for 2.27" issue. |
Update for this issue. Once you compile a model (example model used -> https://github.com/stan-dev/cmdstanr/blob/master/inst/logistic.stan): library(cmdstanr)
stan_file <- file.path(path.package("cmdstanr"), "logistic.stan")
data_file <- file.path(path.package("cmdstanr"), "logistic.data.json")
mod <- cmdstan_model(stan_file)
you can get the list of parameters, transformed parameters and generated quantities as well as data with
> names(mod$variables()$parameters)
[1] "alpha" "beta"
> fit$summary(names(mod$variables()$parameters))
# A tibble: 4 × 10
variable mean median sd mad q5 q95 rhat ess_bulk ess_tail
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 alpha 0.380 0.379 0.218 0.215 0.0266 0.739 1.00 4422. 3049.
2 beta[1] -0.665 -0.662 0.241 0.242 -1.06 -0.273 1.00 3502. 3056.
3 beta[2] -0.279 -0.274 0.224 0.227 -0.654 0.0894 1.00 4122. 2992.
4 beta[3] 0.680 0.676 0.272 0.267 0.231 1.15 1.00 3749. 2856.
This is now improved by not starting the cmdstan exe and rather stopping earlier with at least to me a more informative message. > fit <- mod$sample(data = list("N" = 100, "K" = 3))
Error: Missing input data for the following data variables: y, X. |
The only thing missing before we close this issue is adding checks to inits:
|
There is an issue for cmdstan to provide functionality to get list of data and parameter names stan-dev/cmdstan#887
When that functionality is available it would be useful to have
The text was updated successfully, but these errors were encountered: