Extract return codes from CmdStan — fit-method-return_codes • cmdstanr
Description: The $return_codes() method returns a vector of return codes from the CmdStan run(s). A return code of 0 indicates a successful run.

# Extract return codes from CmdStan

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

The `$return_codes()` method returns a vector of return codes from the CmdStan run(s). A return code of 0 indicates a successful run.

    return_codes()

## Value

An integer vector of return codes with length equal to the number of CmdStan runs (number of chains for MCMC and one otherwise).

## See also

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

## Examples

    # \dontrun{
    # example with return codes all zero
    fit_mcmc <- cmdstanr_example("schools", method = "sample")
    #> Warning: 258 of 4000 (6.0%) transitions ended with a divergence.
    #> See https://mc-stan.org/misc/warnings for details.
    #> Warning: 2 of 4 chains had an E-BFMI less than 0.2.
    #> See https://mc-stan.org/misc/warnings for details.
    fit_mcmc$return_codes() # should be all zero
    #> [1] 0 0 0 0

    # example of non-zero return code (optimization fails for hierarchical model)
    fit_opt <- cmdstanr_example("schools", method = "optimize")
    #> Optimization terminated with error:
    #>   Line search failed to achieve a sufficient decrease, no more progress can be made
    fit_opt$return_codes() # should be non-zero
    #> [1] 1
    # }