Computes credible interval(s) directly from a vector (or row-major matrix) of the posterior(s) obtained by bayesian bootstrap. -- Function File: CI = credint (BOOTSTAT) -- Function File: CI = credint (BOOTSTAT, PROB) 'CI = credint (BOOTSTAT)' computes 95% credible intervals directly from the vector, or rows* of the matrix in BOOTSTAT, where BOOTSTAT contains posterior (or Bayesian bootstrap) statistics, such as those generated using the `bootbayes` function (or the `bootlm` function with the method set to 'bayesian'). The credible intervals are shortest probability intervals (SPI), which represent a more computationally stable version of the highest posterior density interval [1,2]. * The matrix should have dimensions P * NBOOT, where P corresponds to the number of parameter estimates and NBOOT corresponds to the number of posterior (or Bayesian bootstrap) samples. 'CI = credint (BOOTSTAT, PROB)' returns credible intervals, where PROB is numeric and sets the lower and upper bounds of the credible interval(s). The value(s) of PROB must be between 0 and 1. PROB can either be: <> scalar: To set the central mass of shortest probability intervals to 100*PROB% <> vector: A pair of probabilities defining the lower and upper percentiles of the credible interval(s) as 100*(PROB(1))% and 100*(PROB(2))% respectively. The default value of PROB is the scalar: 0.95, for a 95% shortest posterior credible interval. Bibliography: [1] Liu, Gelman & Zheng (2015). Simulation-efficient shortest probability intervals. Statistics and Computing, 25(4), 809–819. [2] Gelman (2020) Shortest Posterior Intervals. https://discourse.mc-stan.org/t/shortest-posterior-intervals/16281/16 credint (version 2023.09.03) Author: Andrew Charles Penn https://www.researchgate.net/profile/Andrew_Penn/ Copyright 2019 Andrew Charles Penn This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/
The following code
% Input univariate dataset y = [5.18 2.71 2.69 6.09 4.23 10.7 3.71 13.13 19.28 6.61].'; % 95% credible interval for the mean [stats, bootstat] = bootbayes (y); CI = credint (bootstat,0.95) % 95% shortest probability interval CI = credint (bootstat,[0.025,0.975]) % 95% equal-tailed interval % Please be patient, the calculations will be completed soon...
Produces the following output
CI = 4.5724 10.951 CI = 4.7304 11.208
Package: statistics-resampling