Run CmdStan's stansummary and diagnose utilities. These are documented in the CmdStan Guide:

  • https://mc-stan.org/docs/cmdstan-guide/stansummary.html

  • https://mc-stan.org/docs/cmdstan-guide/diagnose.html

Although these methods can be used for models fit using the $variational() method, much of the output is currently only relevant for models fit using the $sample() method.

See the $summary() for computing similar summaries in R rather than calling CmdStan's utilites.

cmdstan_summary(flags = NULL)

cmdstan_diagnose()

Arguments

flags

An optional character vector of flags (e.g. flags = c("--sig_figs=1")).

See also

Examples

# \dontrun{ fit <- cmdstanr_example("logistic")
#> Model executable is up to date!
fit$cmdstan_diagnose()
#> Processing csv files: /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-1-4d33e7.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-2-4d33e7.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-3-4d33e7.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-4-4d33e7.csv #> #> Checking sampler transitions treedepth. #> Treedepth satisfactory for all transitions. #> #> Checking sampler transitions for divergences. #> No divergent transitions found. #> #> Checking E-BFMI - sampler transitions HMC potential energy. #> E-BFMI satisfactory for all transitions. #> #> Effective sample size satisfactory. #> #> Split R-hat values satisfactory all parameters. #> #> Processing complete, no problems detected.
fit$cmdstan_summary()
#> Input files: /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-1-4d33e7.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-2-4d33e7.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-3-4d33e7.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpGraDrG/logistic-202012171338-4-4d33e7.csv #> Inference for Stan model: logistic_model #> 4 chains: each with iter=(1000,1000,1000,1000); warmup=(0,0,0,0); thin=(1,1,1,1); 4000 iterations saved. #> #> Warmup took (0.029, 0.028, 0.026, 0.043) seconds, 0.13 seconds total #> Sampling took (0.11, 0.099, 0.095, 0.17) seconds, 0.48 seconds total #> #> Mean MCSE StdDev 5% 50% 95% N_Eff N_Eff/s R_hat #> #> lp__ -6.6e+01 3.2e-02 1.5 -69 -6.6e+01 -6.4e+01 2048 4311 1.0 #> accept_stat__ 0.91 6.2e-03 0.10 0.70 0.95 1.0 2.7e+02 5.8e+02 1.0e+00 #> stepsize__ 0.74 4.6e-02 0.065 0.65 0.75 0.83 2.0e+00 4.2e+00 2.5e+13 #> treedepth__ 2.4 7.7e-02 0.52 2.0 2.0 3.0 4.6e+01 9.7e+01 1.0e+00 #> n_leapfrog__ 5.3 3.1e-01 2.0 3.0 7.0 7.0 4.1e+01 8.6e+01 1.0e+00 #> divergent__ 0.00 nan 0.00 0.00 0.00 0.00 nan nan nan #> energy__ 68 4.9e-02 2.0 65 68 72 1.7e+03 3.5e+03 1.0e+00 #> #> alpha 3.8e-01 3.5e-03 0.22 0.027 3.7e-01 7.5e-01 3858 8121 1.0 #> beta[1] -6.7e-01 4.1e-03 0.26 -1.1 -6.7e-01 -2.5e-01 3893 8195 1.0 #> beta[2] -2.7e-01 3.4e-03 0.23 -0.64 -2.6e-01 8.8e-02 4345 9148 1.00 #> beta[3] 6.8e-01 4.2e-03 0.27 0.24 6.7e-01 1.1e+00 4049 8525 1.00 #> log_lik[1] -5.1e-01 1.6e-03 0.098 -0.68 -5.1e-01 -3.6e-01 3960 8337 1.00 #> log_lik[2] -4.0e-01 2.3e-03 0.15 -0.68 -3.8e-01 -2.0e-01 4327 9110 1.00 #> log_lik[3] -4.9e-01 3.4e-03 0.22 -0.90 -4.6e-01 -2.0e-01 4235 8915 1.00 #> log_lik[4] -4.5e-01 2.4e-03 0.15 -0.74 -4.4e-01 -2.4e-01 3879 8167 1.00 #> log_lik[5] -1.2e+00 4.3e-03 0.29 -1.7 -1.2e+00 -7.5e-01 4422 9310 1.00 #> log_lik[6] -6.0e-01 3.0e-03 0.19 -0.94 -5.7e-01 -3.2e-01 4225 8895 1.0 #> log_lik[7] -6.4e-01 1.9e-03 0.12 -0.86 -6.3e-01 -4.4e-01 4341 9139 1.00 #> log_lik[8] -2.8e-01 2.1e-03 0.13 -0.53 -2.6e-01 -1.1e-01 4099 8630 1.0 #> log_lik[9] -7.0e-01 2.6e-03 0.17 -1.00 -6.8e-01 -4.5e-01 4154 8746 1.00 #> log_lik[10] -7.3e-01 3.6e-03 0.23 -1.1 -7.0e-01 -4.0e-01 4173 8786 1.00 #> log_lik[11] -2.8e-01 2.0e-03 0.13 -0.52 -2.6e-01 -1.2e-01 3979 8376 1.0 #> log_lik[12] -5.0e-01 3.8e-03 0.24 -0.99 -4.6e-01 -1.9e-01 4096 8622 1.00 #> log_lik[13] -6.5e-01 3.3e-03 0.21 -1.0 -6.3e-01 -3.5e-01 4156 8749 1.0 #> log_lik[14] -3.6e-01 2.8e-03 0.17 -0.67 -3.2e-01 -1.3e-01 3922 8257 1.00 #> log_lik[15] -2.8e-01 1.7e-03 0.11 -0.48 -2.6e-01 -1.3e-01 4228 8902 1.0 #> log_lik[16] -2.8e-01 1.4e-03 0.087 -0.43 -2.7e-01 -1.5e-01 3994 8408 1.0 #> log_lik[17] -1.6e+00 4.8e-03 0.29 -2.1 -1.6e+00 -1.2e+00 3563 7500 1.0 #> log_lik[18] -4.8e-01 1.6e-03 0.11 -0.67 -4.7e-01 -3.2e-01 4265 8978 1.0 #> log_lik[19] -2.3e-01 1.2e-03 0.075 -0.37 -2.2e-01 -1.2e-01 4039 8502 1.0 #> log_lik[20] -1.1e-01 1.3e-03 0.079 -0.26 -9.1e-02 -2.8e-02 3861 8128 1.00 #> log_lik[21] -2.1e-01 1.4e-03 0.088 -0.38 -2.0e-01 -9.6e-02 3943 8300 1.0 #> log_lik[22] -5.7e-01 2.3e-03 0.15 -0.84 -5.6e-01 -3.5e-01 4113 8658 1.0 #> log_lik[23] -3.3e-01 2.1e-03 0.14 -0.59 -3.1e-01 -1.5e-01 4448 9365 1.0 #> log_lik[24] -1.4e-01 1.1e-03 0.067 -0.26 -1.2e-01 -5.1e-02 3896 8202 1.0 #> log_lik[25] -4.6e-01 1.9e-03 0.12 -0.67 -4.4e-01 -2.7e-01 4163 8764 1.00 #> log_lik[26] -1.5e+00 5.4e-03 0.34 -2.1 -1.5e+00 -1.0e+00 4027 8478 1.0 #> log_lik[27] -3.1e-01 2.0e-03 0.12 -0.53 -2.9e-01 -1.4e-01 3970 8358 1.0 #> log_lik[28] -4.4e-01 1.3e-03 0.082 -0.59 -4.4e-01 -3.2e-01 3905 8222 1.0 #> log_lik[29] -7.3e-01 3.4e-03 0.23 -1.1 -7.0e-01 -4.0e-01 4650 9790 1.00 #> log_lik[30] -7.0e-01 2.9e-03 0.19 -1.0 -6.8e-01 -4.2e-01 4297 9046 1.00 #> log_lik[31] -4.9e-01 2.6e-03 0.16 -0.78 -4.7e-01 -2.6e-01 4043 8512 1.0 #> log_lik[32] -4.2e-01 1.7e-03 0.11 -0.62 -4.1e-01 -2.7e-01 4274 8998 1.0 #> log_lik[33] -4.1e-01 2.0e-03 0.13 -0.64 -3.9e-01 -2.2e-01 4098 8628 1.00 #> log_lik[34] -6.4e-02 8.4e-04 0.051 -0.16 -5.0e-02 -1.3e-02 3733 7860 1.0 #> log_lik[35] -5.9e-01 2.7e-03 0.19 -0.93 -5.6e-01 -3.2e-01 4732 9961 1.0 #> log_lik[36] -3.3e-01 1.9e-03 0.13 -0.57 -3.1e-01 -1.5e-01 4729 9955 1.0 #> log_lik[37] -6.9e-01 3.4e-03 0.23 -1.1 -6.7e-01 -3.8e-01 4486 9445 1.00 #> log_lik[38] -3.2e-01 2.4e-03 0.15 -0.60 -2.9e-01 -1.2e-01 4017 8457 1.00 #> log_lik[39] -1.8e-01 1.8e-03 0.11 -0.39 -1.5e-01 -5.2e-02 3948 8311 1.00 #> log_lik[40] -6.8e-01 2.0e-03 0.13 -0.90 -6.7e-01 -4.9e-01 4095 8622 1.00 #> log_lik[41] -1.1e+00 4.0e-03 0.25 -1.6 -1.1e+00 -7.5e-01 3927 8267 1.00 #> log_lik[42] -9.3e-01 3.1e-03 0.20 -1.3 -9.2e-01 -6.4e-01 4060 8548 1.00 #> log_lik[43] -4.1e-01 4.0e-03 0.26 -0.92 -3.5e-01 -1.0e-01 4264 8977 1.0 #> log_lik[44] -1.2e+00 3.2e-03 0.19 -1.5 -1.2e+00 -8.9e-01 3535 7442 1.0 #> log_lik[45] -3.6e-01 1.9e-03 0.12 -0.57 -3.4e-01 -1.8e-01 3909 8230 1.00 #> log_lik[46] -5.8e-01 1.9e-03 0.13 -0.81 -5.7e-01 -3.8e-01 4348 9153 1.00 #> log_lik[47] -3.1e-01 2.1e-03 0.13 -0.54 -2.9e-01 -1.3e-01 3879 8165 1.00 #> log_lik[48] -3.2e-01 1.3e-03 0.082 -0.47 -3.2e-01 -2.0e-01 4058 8543 1.0 #> log_lik[49] -3.2e-01 1.3e-03 0.079 -0.46 -3.1e-01 -2.0e-01 3862 8131 1.0 #> log_lik[50] -1.3e+00 5.2e-03 0.34 -1.9 -1.3e+00 -8.0e-01 4084 8598 1.0 #> log_lik[51] -2.9e-01 1.4e-03 0.093 -0.46 -2.8e-01 -1.5e-01 4280 9011 1.0 #> log_lik[52] -8.4e-01 2.3e-03 0.14 -1.1 -8.3e-01 -6.2e-01 3855 8117 1.00 #> log_lik[53] -4.0e-01 2.1e-03 0.13 -0.64 -3.9e-01 -2.2e-01 4032 8488 1.0 #> log_lik[54] -3.7e-01 2.3e-03 0.14 -0.63 -3.5e-01 -1.7e-01 3881 8171 1.00 #> log_lik[55] -3.9e-01 2.1e-03 0.14 -0.63 -3.7e-01 -1.9e-01 4199 8839 1.00 #> log_lik[56] -3.2e-01 2.8e-03 0.19 -0.69 -2.8e-01 -9.6e-02 4702 9899 1.0 #> log_lik[57] -6.5e-01 1.8e-03 0.12 -0.86 -6.5e-01 -4.8e-01 4134 8703 1.00 #> log_lik[58] -9.5e-01 5.2e-03 0.36 -1.6 -9.1e-01 -4.4e-01 4738 9974 1.00 #> log_lik[59] -1.4e+00 5.5e-03 0.34 -2.0 -1.3e+00 -8.5e-01 3911 8233 1.00 #> log_lik[60] -9.8e-01 2.6e-03 0.16 -1.3 -9.7e-01 -7.4e-01 3688 7764 1.00 #> log_lik[61] -5.4e-01 1.5e-03 0.097 -0.70 -5.3e-01 -3.9e-01 3957 8331 1.00 #> log_lik[62] -8.9e-01 5.1e-03 0.32 -1.5 -8.5e-01 -4.4e-01 3900 8210 1.00 #> log_lik[63] -1.2e-01 1.2e-03 0.074 -0.26 -1.0e-01 -3.4e-02 3706 7803 1.0 #> log_lik[64] -9.0e-01 3.7e-03 0.25 -1.3 -8.7e-01 -5.4e-01 4518 9512 1.00 #> log_lik[65] -2.0e+00 9.6e-03 0.59 -3.0 -2.0e+00 -1.1e+00 3848 8100 1.00 #> log_lik[66] -5.1e-01 2.0e-03 0.14 -0.76 -4.9e-01 -3.1e-01 4532 9541 1.00 #> log_lik[67] -2.8e-01 1.3e-03 0.081 -0.42 -2.7e-01 -1.6e-01 4172 8783 1.0 #> log_lik[68] -1.1e+00 3.6e-03 0.23 -1.5 -1.0e+00 -7.1e-01 4159 8756 1.00 #> log_lik[69] -4.4e-01 1.3e-03 0.083 -0.58 -4.3e-01 -3.1e-01 3903 8216 1.0 #> log_lik[70] -6.4e-01 3.4e-03 0.23 -1.1 -6.1e-01 -3.1e-01 4663 9818 1.00 #> log_lik[71] -6.1e-01 3.2e-03 0.21 -1.00 -5.8e-01 -3.0e-01 4420 9306 1.0 #> log_lik[72] -4.6e-01 2.7e-03 0.17 -0.78 -4.4e-01 -2.2e-01 3995 8410 1.00 #> log_lik[73] -1.5e+00 5.9e-03 0.37 -2.1 -1.5e+00 -9.3e-01 3874 8157 1.00 #> log_lik[74] -9.5e-01 3.1e-03 0.20 -1.3 -9.4e-01 -6.5e-01 4177 8793 1.00 #> log_lik[75] -1.2e+00 6.4e-03 0.40 -1.9 -1.1e+00 -5.8e-01 3846 8098 1.0 #> log_lik[76] -3.7e-01 2.2e-03 0.14 -0.62 -3.5e-01 -1.8e-01 3995 8411 1.00 #> log_lik[77] -8.8e-01 2.2e-03 0.14 -1.1 -8.7e-01 -6.6e-01 4064 8556 1.0 #> log_lik[78] -4.8e-01 2.7e-03 0.17 -0.80 -4.6e-01 -2.4e-01 4122 8677 1.00 #> log_lik[79] -7.6e-01 2.9e-03 0.19 -1.1 -7.4e-01 -4.8e-01 4267 8983 1.00 #> log_lik[80] -5.4e-01 2.9e-03 0.20 -0.91 -5.1e-01 -2.7e-01 4700 9894 1.00 #> log_lik[81] -1.6e-01 1.6e-03 0.10 -0.36 -1.4e-01 -4.8e-02 3848 8101 1.0 #> log_lik[82] -2.2e-01 2.2e-03 0.14 -0.49 -1.9e-01 -6.3e-02 4165 8769 1.00 #> log_lik[83] -3.4e-01 1.3e-03 0.081 -0.49 -3.4e-01 -2.2e-01 3873 8155 1.0 #> log_lik[84] -2.7e-01 1.4e-03 0.092 -0.44 -2.6e-01 -1.5e-01 4079 8588 1.0 #> log_lik[85] -1.3e-01 1.2e-03 0.075 -0.28 -1.1e-01 -4.0e-02 3907 8225 1.0 #> log_lik[86] -1.1e+00 4.9e-03 0.32 -1.7 -1.1e+00 -6.5e-01 4192 8826 1.00 #> log_lik[87] -8.2e-01 2.0e-03 0.13 -1.0 -8.2e-01 -6.3e-01 4067 8562 1.00 #> log_lik[88] -7.7e-01 3.8e-03 0.24 -1.2 -7.4e-01 -4.2e-01 4159 8755 1.00 #> log_lik[89] -1.3e+00 5.1e-03 0.32 -1.8 -1.3e+00 -8.0e-01 3946 8308 1.00 #> log_lik[90] -2.6e-01 2.1e-03 0.14 -0.53 -2.4e-01 -9.3e-02 4130 8694 1.0 #> log_lik[91] -3.9e-01 2.0e-03 0.13 -0.62 -3.7e-01 -2.0e-01 4115 8663 1.0 #> log_lik[92] -1.5e+00 5.5e-03 0.35 -2.1 -1.5e+00 -9.7e-01 4068 8564 1.00 #> log_lik[93] -7.5e-01 3.6e-03 0.22 -1.1 -7.3e-01 -4.3e-01 3814 8029 1.00 #> log_lik[94] -3.2e-01 1.4e-03 0.088 -0.47 -3.1e-01 -1.9e-01 3945 8305 1.0 #> log_lik[95] -3.9e-01 1.7e-03 0.11 -0.59 -3.8e-01 -2.3e-01 4064 8555 1.0 #> log_lik[96] -1.6e+00 4.9e-03 0.29 -2.1 -1.6e+00 -1.1e+00 3451 7265 1.0 #> log_lik[97] -4.3e-01 1.5e-03 0.099 -0.61 -4.3e-01 -2.8e-01 4403 9269 1.0 #> log_lik[98] -1.0e+00 5.5e-03 0.38 -1.7 -1.0e+00 -5.1e-01 4727 9951 1.00 #> log_lik[99] -6.9e-01 2.1e-03 0.14 -0.94 -6.8e-01 -4.8e-01 4346 9149 1.00 #> log_lik[100] -3.9e-01 1.5e-03 0.096 -0.56 -3.8e-01 -2.4e-01 4036 8496 1.0 #> #> Samples were drawn using hmc with nuts. #> For each parameter, N_Eff is a crude measure of effective sample size, #> and R_hat is the potential scale reduction factor on split chains (at #> convergence, R_hat=1).
# }