@@ -626,7 +626,46 @@ cdef class StanFit4Model:
626
626
def __getitem__ (self , key ):
627
627
extr = self .extract(pars = (key,))
628
628
return extr[key]
629
+
630
+ def stansummary (self , pars = None , probs = (0.025 , 0.25 , 0.5 , 0.75 , 0.975 ), digits_summary = 2 ):
631
+ """
632
+ Summary statistics table.
629
633
634
+ Parameters
635
+ ----------
636
+ fit : StanFit4Model object
637
+ pars : str or sequence of str, optional
638
+ Parameter names. By default use all parameters
639
+ probs : sequence of float, optional
640
+ Quantiles. By default, (0.025, 0.25, 0.5, 0.75, 0.975)
641
+ digits_summary : int, optional
642
+ Number of significant digits. By default, 2
643
+ Returns
644
+ -------
645
+ summary : string
646
+ Table includes mean, se_mean, sd, probs_0, ..., probs_n, n_eff and Rhat.
647
+
648
+ Examples
649
+ --------
650
+ >>> model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
651
+ >>> m = StanModel(model_code=model_code, model_name="example_model")
652
+ >>> fit = m.sampling()
653
+ >>> print(fit.stansummary())
654
+ Inference for Stan model: example_model.
655
+ 4 chains, each with iter=2000; warmup=1000; thin=1;
656
+ post-warmup draws per chain=1000, total post-warmup draws=4000.
657
+
658
+ mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
659
+ y 0.01 0.03 1.0 -2.01 -0.68 0.02 0.72 1.97 1330 1.0
660
+ lp__ -0.5 0.02 0.68 -2.44 -0.66 -0.24 -0.05-5.5e-4 1555 1.0
661
+
662
+ Samples were drawn using NUTS at Thu Aug 17 00:52:25 2017.
663
+ For each parameter, n_eff is a crude measure of effective sample size,
664
+ and Rhat is the potential scale reduction factor on split chains (at
665
+ convergence, Rhat=1).
666
+ """
667
+ return pystan.misc.stansummary(fit = self , pars = pars, probs = probs, digits_summary = digits_summary)
668
+
630
669
def summary (self , pars = None , probs = None ):
631
670
return pystan.misc._summary(self , pars, probs)
632
671
0 commit comments