Extract metadata from CmdStan CSV files — fit-method-metadata • cmdstanr
Description: The $metadata() method returns a list of information gathered from the CSV output files, including the CmdStan configuration used when fitting the model. See Examples and read_cmdstan_csv().

# Extract metadata from CmdStan CSV files

Source: `R/fit.R`
`fit-method-metadata.Rd`

The `$metadata()` method returns a list of information gathered from the CSV output files, including the CmdStan configuration used when fitting the model. See Examples and `read_cmdstan_csv()`.

    metadata()

## See also

`CmdStanMCMC`, `CmdStanMLE`, `CmdStanVB`, `CmdStanGQ`

## Examples

    # \dontrun{
    fit_mcmc <- cmdstanr_example("logistic", method = "sample")
    str(fit_mcmc$metadata())
    #> List of 40
    #>  $ stan_version_major  : num 2
    #>  $ stan_version_minor  : num 32
    #>  $ stan_version_patch  : num 2
    #>  $ start_datetime      : chr "2023-07-25 20:36:00 UTC"
    #>  $ method              : chr "sample"
    #>  $ save_warmup         : num 0
    #>  $ thin                : num 1
    #>  $ gamma               : num 0.05
    #>  $ kappa               : num 0.75
    #>  $ t0                  : num 10
    #>  $ init_buffer         : num 75
    #>  $ term_buffer         : num 50
    #>  $ window              : num 25
    #>  $ algorithm           : chr "hmc"
    #>  $ engine              : chr "nuts"
    #>  $ metric              : chr "diag_e"
    #>  $ stepsize_jitter     : num 0
    #>  $ num_chains          : num 1
    #>  $ id                  : num [1:4] 1 2 3 4
    #>  $ init                : num [1:4] 2 2 2 2
    #>  $ seed                : num 49669263
    #>  $ refresh             : num 100
    #>  $ sig_figs            : num -1
    #>  $ profile_file        : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpFBtN6X/logistic-profile-202307251436-1-352ddc.csv"
    #>  $ stanc_version       : chr "stanc3 v2.32.2"
    #>  $ sampler_diagnostics : chr [1:6] "accept_stat__" "stepsize__" "treedepth__" "n_leapfrog__" ...
    #>  $ variables           : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
    #>  $ step_size_adaptation: num [1:4] 0.702 0.797 0.751 0.804
    #>  $ model_name          : chr "logistic_model"
    #>  $ adapt_engaged       : num 1
    #>  $ adapt_delta         : num 0.8
    #>  $ max_treedepth       : num 10
    #>  $ step_size           : num [1:4] 1 1 1 1
    #>  $ iter_warmup         : num 1000
    #>  $ iter_sampling       : num 1000
    #>  $ threads_per_chain   : num 1
    #>  $ time                :'data.frame':	4 obs. of  4 variables:
    #>   ..$ chain_id: num [1:4] 1 2 3 4
    #>   ..$ warmup  : num [1:4] 0.022 0.022 0.021 0.022
    #>   ..$ sampling: num [1:4] 0.068 0.065 0.073 0.067
    #>   ..$ total   : num [1:4] 0.09 0.087 0.094 0.089
    #>  $ stan_variable_sizes :List of 4
    #>   ..$ lp__   : num 1
    #>   ..$ alpha  : num 1
    #>   ..$ beta   : num 3
    #>   ..$ log_lik: num 100
    #>  $ stan_variables      : chr [1:4] "lp__" "alpha" "beta" "log_lik"
    #>  $ model_params        : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...

    fit_mle <- cmdstanr_example("logistic", method = "optimize")
    str(fit_mle$metadata())
    #> List of 31
    #>  $ stan_version_major : num 2
    #>  $ stan_version_minor : num 32
    #>  $ stan_version_patch : num 2
    #>  $ start_datetime     : chr "2023-07-25 20:36:01 UTC"
    #>  $ method             : chr "optimize"
    #>  $ algorithm          : chr "lbfgs"
    #>  $ init_alpha         : num 0.001
    #>  $ tol_obj            : num 1e-12
    #>  $ tol_rel_obj        : num 10000
    #>  $ tol_grad           : num 1e-08
    #>  $ tol_rel_grad       : num 1e+07
    #>  $ tol_param          : num 1e-08
    #>  $ history_size       : num 5
    #>  $ jacobian           : num 0
    #>  $ iter               : num 2000
    #>  $ save_iterations    : num 0
    #>  $ id                 : num 1
    #>  $ init               : num 2
    #>  $ seed               : num 1.74e+09
    #>  $ refresh            : num 100
    #>  $ sig_figs           : num -1
    #>  $ profile_file       : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpFBtN6X/logistic-profile-202307251436-1-4f11df.csv"
    #>  $ stanc_version      : chr "stanc3 v2.32.2"
    #>  $ sampler_diagnostics: chr(0)
    #>  $ variables          : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...
    #>  $ model_name         : chr "logistic_model"
    #>  $ threads            : num 1
    #>  $ time               :'data.frame':	0 obs. of  0 variables
    #>  $ stan_variable_sizes:List of 4
    #>   ..$ lp__   : num 1
    #>   ..$ alpha  : num 1
    #>   ..$ beta   : num 3
    #>   ..$ log_lik: num 100
    #>  $ stan_variables     : chr [1:4] "lp__" "alpha" "beta" "log_lik"
    #>  $ model_params       : chr [1:105] "lp__" "alpha" "beta[1]" "beta[2]" ...

    fit_vb <- cmdstanr_example("logistic", method = "variational")
    str(fit_vb$metadata())
    #> List of 29
    #>  $ stan_version_major : num 2
    #>  $ stan_version_minor : num 32
    #>  $ stan_version_patch : num 2
    #>  $ start_datetime     : chr "2023-07-25 20:36:01 UTC"
    #>  $ method             : chr "variational"
    #>  $ algorithm          : chr "meanfield"
    #>  $ iter               : num 50
    #>  $ grad_samples       : num 1
    #>  $ elbo_samples       : num 100
    #>  $ eta                : num 1
    #>  $ tol_rel_obj        : num 0.01
    #>  $ eval_elbo          : num 100
    #>  $ output_samples     : num 1000
    #>  $ id                 : num 1
    #>  $ init               : num 2
    #>  $ seed               : num 2.97e+08
    #>  $ refresh            : num 100
    #>  $ sig_figs           : num -1
    #>  $ profile_file       : chr "/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpFBtN6X/logistic-profile-202307251436-1-5bbf54.csv"
    #>  $ stanc_version      : chr "stanc3 v2.32.2"
    #>  $ sampler_diagnostics: chr(0)
    #>  $ variables          : chr [1:106] "lp__" "lp_approx__" "alpha" "beta[1]" ...
    #>  $ model_name         : chr "logistic_model"
    #>  $ adapt_engaged      : num 1
    #>  $ threads            : num 1
    #>  $ time               :'data.frame':	0 obs. of  0 variables
    #>  $ stan_variable_sizes:List of 5
    #>   ..$ lp__       : num 1
    #>   ..$ lp_approx__: num 1
    #>   ..$ alpha      : num 1
    #>   ..$ beta       : num 3
    #>   ..$ log_lik    : num 100
    #>  $ stan_variables     : chr [1:5] "lp__" "lp_approx__" "alpha" "beta" ...
    #>  $ model_params       : chr [1:106] "lp__" "lp_approx__" "alpha" "beta[1]" ...
    # }