1

Classical and Bayesian approaches to parameter estimation are often compared. See, for example What's the difference between a confidence interval and a credible interval?

What I cannot find is "the Bayesian version" of the following result. Consider a prediction interval for the next sample drawn from a normal distribution, and the probability of being wrong is alpha. No assumptions about the mean and the variance are needed.

Here is a proof. After observing $z_1$, ..., $z_n$, the sample mean and the sample variance are

$$m = \frac{1}{n}\sum_{i = 1}^{n} z_i, \quad s^2 = \frac{1}{n} \sum_{n = 1}^{n} (z_i - m)^2$$.

The random variable $$ \frac{z_{n + 1} - m}{s} \sqrt{\frac{n + 1}{n}} $$

has $t$-distribution with $n - 1$ degrees of freedom and $z_{n + 1}$ will be in the interval

$$m \pm t^{\alpha/2}_{n - 1} s\sqrt{\frac{n}{n + 1}}$$.

with probably $1 - \alpha$, where $t^{\alpha/2}$ is the value of percent point function (inverse of cdf) for $t$-distribution.

And a demonstration in python

#!/usr/bin/python3
import math
import random
import scipy.stats
import statistics
mu = 1.0
sigma = 1.0
alpha = 0.20
N = 1000
def rnd():
    return random.gauss(mu, sigma)
def interval(z):
    n = len(z) + 1
    m = statistics.mean(z)
    s = statistics.stdev(z)
    t = scipy.stats.t.ppf(1 - alpha/2, n - 2)
    d = t * s * math.sqrt(n/(n - 1))
    return m - d, m + d
z = [rnd(), rnd()]
wrong = 0
for i in range(N):
    x, y = interval(z)
    z0 = rnd()
    wrong += not x < z0 <= y
    z.append(z0)
print(wrong/N)

References

Fisher, R. A. (1935). The fiducial argument in statistical inference. Annals of eugenics, 6(4), 391-398. https://doi.org/10.1111/j.1469-1809.1935.tb02120.x

Shafer, G., & Vovk, V. (2008). A Tutorial on Conformal Prediction. Journal of Machine Learning Research, 9(3) (section 2.1)

Jaynes, E. T., & Kempthorne, O. (1976). Confidence intervals vs Bayesian intervals. In Foundations of probability theory, statistical inference, and statistical theories of science (pp. 175-257). Springer, Dordrech. https://doi.org/10.1007/978-94-010-1436-6_6

slitvinov
  • 125
  • 9
  • 1
    The "result" you quote is incorrect: that's not what a confidence interval means. See https://stats.stackexchange.com/questions/16493. – whuber May 09 '21 at 15:43
  • @whuber Could you, please, elaborate. I added a prof of the results which is one step from a definition of a confidence interval. – slitvinov May 09 '21 at 17:20
  • Doesn't the link provide sufficient elaboration of the distinction between confidence and prediction intervals? The interval in your code is a prediction interval, not a confidence interval. – whuber May 09 '21 at 17:54
  • @whubber the link you give is about regression. – slitvinov May 09 '21 at 17:55
  • The concept is the same, regardless of the application. We have many threads about this: see https://stats.stackexchange.com/search?tab=votes&q=%20confidence%20prediction%20interval. – whuber May 09 '21 at 17:57
  • Could you point me to the definition of CI you use? How I see it, what I compute is CI according to Fisher's paper and according to https://en.wikipedia.org/wiki/Confidence_interval. – slitvinov May 09 '21 at 18:01
  • @whuber > interval in your code is a prediction interval, not a confidence interval....... Is it only about terminology? I wrote that I use it for prediction and I gave a formula which is the same as for a textbooks confidence interval. – slitvinov May 09 '21 at 18:26
  • 1
    What you describe is the [prediction interval](https://en.wikipedia.org/wiki/Prediction_interval) for $z_{n+1}$. It's equal to the corresponding Bayesian credible interval for the same quantity if using an improper uniform prior on $\mu$ and an independent improper scale prior $\propto 1/\sigma^2$ on $\sigma^2$. – Jarle Tufto May 09 '21 at 19:14
  • @JarleTufto I think that's it. If you care you can post this comment as an answer and I will accept it. – slitvinov May 12 '21 at 08:52
  • @slitvinov Ok, done. – Jarle Tufto May 12 '21 at 09:52

1 Answers1

1

What you describe is a prediction interval for $z_{n+1}$. This prediction interval happen to be equal to the corresponding Bayesian credible interval for the same quantity based on the predictive posterior density of $z_{n+1}$ (a scaled, shifted $t$-distribution) if using an improper uniform prior on $\mu$ and an improper scale prior $\propto 1/\sigma^2$ on $\sigma^2$.

Jarle Tufto
  • 7,989
  • 1
  • 20
  • 36