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/RtmpEmZKF5/logistic-202104151125-1-903743.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpEmZKF5/logistic-202104151125-2-903743.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpEmZKF5/logistic-202104151125-3-903743.csv, /var/folders/h6/14xy_35x4wd2tz542dn0qhtc0000gn/T/RtmpEmZKF5/logistic-202104151125-4-903743.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()
#> 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.043, 0.030, 0.036) seconds, 0.14 seconds total #> Sampling took (0.11, 0.12, 0.12, 0.11) seconds, 0.45 seconds total #> #> Mean MCSE StdDev 5% 50% 95% N_Eff N_Eff/s R_hat #> #> lp__ -6.6e+01 3.0e-02 1.4 -69 -6.6e+01 -6.4e+01 2125 4681 1.0 #> accept_stat__ 0.90 3.5e-03 0.11 0.67 0.94 1.0 1.0e+03 2.2e+03 1.0e+00 #> stepsize__ 0.77 6.1e-02 0.086 0.68 0.76 0.91 2.0e+00 4.4e+00 2.9e+13 #> treedepth__ 2.4 8.9e-02 0.52 2.0 2.0 3.0 3.4e+01 7.4e+01 1.0e+00 #> n_leapfrog__ 5.0 2.9e-01 2.0 3.0 7.0 7.0 4.8e+01 1.0e+02 1.0e+00 #> divergent__ 0.00 nan 0.00 0.00 0.00 0.00 nan nan nan #> energy__ 68 4.5e-02 1.9 65 68 72 1.8e+03 4.1e+03 1.0e+00 #> #> alpha 3.8e-01 3.1e-03 0.22 0.021 3.8e-01 7.4e-01 5045 11113 1.00 #> beta[1] -6.6e-01 3.9e-03 0.25 -1.1 -6.6e-01 -2.7e-01 3969 8743 1.00 #> beta[2] -2.7e-01 3.4e-03 0.22 -0.64 -2.8e-01 9.6e-02 4241 9342 1.00 #> beta[3] 6.8e-01 4.3e-03 0.27 0.26 6.8e-01 1.1e+00 3836 8448 1.00 #> log_lik[1] -5.2e-01 1.5e-03 0.10 -0.69 -5.1e-01 -3.6e-01 4666 10278 1.00 #> log_lik[2] -4.0e-01 2.3e-03 0.15 -0.67 -3.9e-01 -2.0e-01 4112 9056 1.00 #> log_lik[3] -5.0e-01 3.4e-03 0.22 -0.92 -4.6e-01 -2.0e-01 4271 9406 1.00 #> log_lik[4] -4.5e-01 2.4e-03 0.15 -0.73 -4.3e-01 -2.3e-01 3841 8461 1.00 #> log_lik[5] -1.2e+00 4.2e-03 0.28 -1.7 -1.2e+00 -7.6e-01 4532 9982 1.00 #> log_lik[6] -5.9e-01 2.8e-03 0.18 -0.92 -5.7e-01 -3.2e-01 4357 9597 1.0 #> log_lik[7] -6.4e-01 1.8e-03 0.12 -0.85 -6.3e-01 -4.5e-01 4531 9980 1.0 #> log_lik[8] -2.8e-01 2.0e-03 0.13 -0.53 -2.5e-01 -1.1e-01 4204 9260 1.00 #> log_lik[9] -6.9e-01 2.5e-03 0.16 -0.99 -6.8e-01 -4.4e-01 4450 9802 1.0 #> log_lik[10] -7.4e-01 3.6e-03 0.23 -1.2 -7.2e-01 -4.0e-01 4166 9176 1.00 #> log_lik[11] -2.8e-01 1.9e-03 0.12 -0.51 -2.6e-01 -1.1e-01 3999 8809 1.00 #> log_lik[12] -4.9e-01 3.8e-03 0.23 -0.93 -4.5e-01 -1.9e-01 3880 8545 1.00 #> log_lik[13] -6.6e-01 3.0e-03 0.20 -1.0 -6.4e-01 -3.7e-01 4411 9717 1.0 #> log_lik[14] -3.6e-01 2.8e-03 0.18 -0.70 -3.3e-01 -1.4e-01 4089 9006 1.00 #> log_lik[15] -2.8e-01 1.7e-03 0.11 -0.48 -2.6e-01 -1.3e-01 4291 9452 1.00 #> log_lik[16] -2.7e-01 1.4e-03 0.086 -0.43 -2.7e-01 -1.5e-01 3986 8780 1.00 #> log_lik[17] -1.6e+00 4.7e-03 0.29 -2.1 -1.6e+00 -1.1e+00 3899 8588 1.00 #> log_lik[18] -4.8e-01 1.5e-03 0.11 -0.67 -4.7e-01 -3.2e-01 4922 10841 1.00 #> log_lik[19] -2.3e-01 1.2e-03 0.076 -0.37 -2.2e-01 -1.2e-01 3968 8741 1.00 #> log_lik[20] -1.1e-01 1.3e-03 0.080 -0.27 -9.4e-02 -2.7e-02 3698 8146 1.0 #> log_lik[21] -2.1e-01 1.4e-03 0.087 -0.37 -2.0e-01 -9.3e-02 3848 8475 1.00 #> log_lik[22] -5.7e-01 2.2e-03 0.15 -0.83 -5.5e-01 -3.5e-01 4382 9652 1.0 #> log_lik[23] -3.3e-01 2.1e-03 0.14 -0.59 -3.1e-01 -1.4e-01 4397 9685 1.00 #> log_lik[24] -1.4e-01 1.1e-03 0.067 -0.26 -1.2e-01 -5.1e-02 3750 8261 1.00 #> log_lik[25] -4.6e-01 1.8e-03 0.12 -0.67 -4.5e-01 -2.8e-01 4092 9014 1.0 #> log_lik[26] -1.5e+00 5.2e-03 0.34 -2.1 -1.5e+00 -1.0e+00 4281 9430 1.00 #> log_lik[27] -3.0e-01 1.9e-03 0.12 -0.53 -2.9e-01 -1.4e-01 3971 8747 1.00 #> log_lik[28] -4.4e-01 1.2e-03 0.084 -0.59 -4.4e-01 -3.2e-01 4819 10614 1.00 #> log_lik[29] -7.3e-01 3.3e-03 0.22 -1.1 -7.0e-01 -4.0e-01 4645 10231 1.00 #> log_lik[30] -6.9e-01 2.7e-03 0.19 -1.0 -6.7e-01 -4.2e-01 4909 10813 1.00 #> log_lik[31] -4.8e-01 2.5e-03 0.16 -0.78 -4.7e-01 -2.6e-01 4132 9102 1.0 #> log_lik[32] -4.2e-01 1.6e-03 0.11 -0.62 -4.1e-01 -2.6e-01 4530 9978 1.00 #> log_lik[33] -4.1e-01 2.0e-03 0.12 -0.64 -4.0e-01 -2.3e-01 4072 8969 1.0 #> log_lik[34] -6.3e-02 8.7e-04 0.050 -0.16 -5.0e-02 -1.3e-02 3314 7299 1.0 #> log_lik[35] -5.9e-01 2.6e-03 0.18 -0.91 -5.7e-01 -3.3e-01 4522 9959 1.0 #> log_lik[36] -3.2e-01 1.9e-03 0.13 -0.57 -3.0e-01 -1.5e-01 4510 9935 1.00 #> log_lik[37] -7.0e-01 3.4e-03 0.23 -1.1 -6.7e-01 -3.7e-01 4422 9740 1.00 #> log_lik[38] -3.1e-01 2.3e-03 0.14 -0.59 -2.9e-01 -1.2e-01 3864 8510 1.0 #> log_lik[39] -1.8e-01 1.8e-03 0.11 -0.40 -1.6e-01 -5.0e-02 3965 8733 1.00 #> log_lik[40] -6.8e-01 1.8e-03 0.13 -0.90 -6.7e-01 -4.9e-01 4994 10999 1.00 #> log_lik[41] -1.1e+00 4.0e-03 0.25 -1.6 -1.1e+00 -7.6e-01 3961 8724 1.0 #> log_lik[42] -9.3e-01 2.9e-03 0.20 -1.3 -9.1e-01 -6.3e-01 4536 9992 1.00 #> log_lik[43] -4.1e-01 3.9e-03 0.26 -0.93 -3.5e-01 -1.1e-01 4369 9623 1.00 #> log_lik[44] -1.2e+00 2.9e-03 0.19 -1.5 -1.2e+00 -8.8e-01 4348 9577 1.00 #> log_lik[45] -3.6e-01 1.8e-03 0.12 -0.58 -3.5e-01 -1.9e-01 4245 9351 1.00 #> log_lik[46] -5.8e-01 1.9e-03 0.13 -0.80 -5.7e-01 -3.9e-01 4482 9872 1.00 #> log_lik[47] -3.0e-01 2.0e-03 0.13 -0.54 -2.8e-01 -1.3e-01 3834 8446 1.0 #> log_lik[48] -3.2e-01 1.3e-03 0.083 -0.47 -3.2e-01 -2.0e-01 4330 9538 1.00 #> log_lik[49] -3.2e-01 1.2e-03 0.080 -0.46 -3.1e-01 -2.0e-01 4154 9151 1.00 #> log_lik[50] -1.3e+00 5.0e-03 0.33 -1.9 -1.3e+00 -7.9e-01 4296 9463 1.00 #> log_lik[51] -2.9e-01 1.5e-03 0.094 -0.46 -2.8e-01 -1.5e-01 4210 9273 1.00 #> log_lik[52] -8.4e-01 2.2e-03 0.14 -1.1 -8.3e-01 -6.1e-01 4521 9959 1.00 #> log_lik[53] -4.0e-01 2.0e-03 0.13 -0.63 -3.8e-01 -2.2e-01 4095 9020 1.0 #> log_lik[54] -3.7e-01 2.2e-03 0.14 -0.63 -3.5e-01 -1.7e-01 4242 9344 1.00 #> log_lik[55] -3.9e-01 2.1e-03 0.13 -0.63 -3.7e-01 -2.0e-01 4050 8920 1.00 #> log_lik[56] -3.2e-01 2.8e-03 0.19 -0.69 -2.7e-01 -9.5e-02 4489 9888 1.00 #> log_lik[57] -6.6e-01 1.7e-03 0.12 -0.86 -6.5e-01 -4.8e-01 4617 10170 1.00 #> log_lik[58] -9.5e-01 5.2e-03 0.35 -1.6 -9.0e-01 -4.6e-01 4492 9894 1.0 #> log_lik[59] -1.4e+00 5.3e-03 0.34 -2.0 -1.3e+00 -8.4e-01 4071 8968 1.00 #> log_lik[60] -9.8e-01 2.4e-03 0.16 -1.3 -9.7e-01 -7.3e-01 4501 9914 1.00 #> log_lik[61] -5.4e-01 1.4e-03 0.100 -0.71 -5.3e-01 -3.9e-01 4903 10800 1.00 #> log_lik[62] -8.7e-01 4.9e-03 0.31 -1.4 -8.4e-01 -4.3e-01 3985 8778 1.00 #> log_lik[63] -1.2e-01 1.2e-03 0.072 -0.26 -9.9e-02 -3.3e-02 3663 8068 1.00 #> log_lik[64] -9.0e-01 3.5e-03 0.25 -1.3 -8.9e-01 -5.4e-01 5033 11086 1.00 #> log_lik[65] -2.0e+00 9.8e-03 0.59 -3.1 -2.0e+00 -1.1e+00 3588 7904 1.0 #> log_lik[66] -5.1e-01 1.9e-03 0.14 -0.75 -4.9e-01 -3.1e-01 4811 10598 1.00 #> log_lik[67] -2.8e-01 1.3e-03 0.082 -0.42 -2.7e-01 -1.6e-01 4237 9332 1.00 #> log_lik[68] -1.1e+00 3.5e-03 0.23 -1.5 -1.0e+00 -7.0e-01 4540 10000 1.00 #> log_lik[69] -4.3e-01 1.2e-03 0.085 -0.58 -4.3e-01 -3.1e-01 4633 10205 1.00 #> log_lik[70] -6.4e-01 3.3e-03 0.24 -1.1 -6.0e-01 -3.2e-01 5122 11281 1.00 #> log_lik[71] -6.1e-01 3.0e-03 0.20 -0.98 -5.9e-01 -3.3e-01 4350 9582 1.0 #> log_lik[72] -4.6e-01 2.6e-03 0.17 -0.77 -4.4e-01 -2.3e-01 4195 9240 1.0 #> log_lik[73] -1.5e+00 5.9e-03 0.36 -2.1 -1.5e+00 -9.5e-01 3754 8270 1.00 #> log_lik[74] -9.5e-01 2.9e-03 0.20 -1.3 -9.3e-01 -6.5e-01 4552 10025 1.00 #> log_lik[75] -1.1e+00 6.1e-03 0.39 -1.8 -1.1e+00 -5.8e-01 4041 8900 1.00 #> log_lik[76] -3.7e-01 2.2e-03 0.14 -0.64 -3.5e-01 -1.8e-01 4181 9210 1.00 #> log_lik[77] -8.8e-01 2.0e-03 0.14 -1.1 -8.7e-01 -6.7e-01 4829 10636 1.0 #> log_lik[78] -4.9e-01 2.6e-03 0.17 -0.81 -4.7e-01 -2.5e-01 4408 9708 1.00 #> log_lik[79] -7.6e-01 2.9e-03 0.19 -1.1 -7.4e-01 -4.8e-01 4220 9295 1.00 #> log_lik[80] -5.4e-01 2.9e-03 0.19 -0.90 -5.2e-01 -2.7e-01 4403 9698 1.00 #> log_lik[81] -1.6e-01 1.6e-03 0.096 -0.35 -1.4e-01 -4.8e-02 3591 7910 1.0 #> log_lik[82] -2.2e-01 2.3e-03 0.14 -0.50 -1.9e-01 -6.3e-02 3669 8081 1.0 #> log_lik[83] -3.4e-01 1.3e-03 0.083 -0.50 -3.4e-01 -2.2e-01 4299 9470 1.00 #> log_lik[84] -2.7e-01 1.5e-03 0.094 -0.45 -2.6e-01 -1.4e-01 4137 9112 1.00 #> log_lik[85] -1.3e-01 1.2e-03 0.076 -0.28 -1.1e-01 -4.1e-02 3802 8374 1.00 #> log_lik[86] -1.1e+00 4.7e-03 0.32 -1.7 -1.1e+00 -6.6e-01 4645 10232 1.00 #> log_lik[87] -8.3e-01 1.8e-03 0.13 -1.0 -8.2e-01 -6.2e-01 4975 10958 1.00 #> log_lik[88] -7.8e-01 3.6e-03 0.23 -1.2 -7.6e-01 -4.3e-01 4315 9503 1.0 #> log_lik[89] -1.3e+00 4.9e-03 0.32 -1.8 -1.2e+00 -8.0e-01 4121 9076 1.00 #> log_lik[90] -2.6e-01 2.1e-03 0.13 -0.51 -2.4e-01 -9.4e-02 3909 8611 1.0 #> log_lik[91] -3.9e-01 2.0e-03 0.13 -0.62 -3.7e-01 -2.1e-01 4013 8840 1.0 #> log_lik[92] -1.5e+00 5.4e-03 0.34 -2.1 -1.5e+00 -9.7e-01 4089 9006 1.00 #> log_lik[93] -7.4e-01 3.5e-03 0.22 -1.1 -7.1e-01 -4.2e-01 4056 8934 1.00 #> log_lik[94] -3.2e-01 1.4e-03 0.090 -0.48 -3.1e-01 -1.9e-01 4198 9247 1.00 #> log_lik[95] -3.9e-01 1.7e-03 0.11 -0.58 -3.8e-01 -2.2e-01 4187 9222 1.0 #> log_lik[96] -1.6e+00 4.6e-03 0.29 -2.1 -1.6e+00 -1.1e+00 3851 8482 1.00 #> log_lik[97] -4.3e-01 1.4e-03 0.10 -0.61 -4.2e-01 -2.8e-01 4867 10721 1.00 #> log_lik[98] -1.0e+00 5.5e-03 0.36 -1.7 -1.0e+00 -5.3e-01 4408 9709 1.0 #> log_lik[99] -7.0e-01 2.0e-03 0.14 -0.94 -6.9e-01 -4.8e-01 4785 10540 1.00 #> log_lik[100] -3.9e-01 1.5e-03 0.099 -0.57 -3.8e-01 -2.4e-01 4517 9949 1.00 #> #> 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).
# }