JohannesBuchner / UltraNest

Fit and compare complex models reliably and rapidly. Advanced nested sampling.
https://johannesbuchner.github.io/UltraNest/
Other
142 stars 30 forks source link

Unexpected results for PredictionBand #90

Closed JorisDeRidder closed 1 year ago

JorisDeRidder commented 1 year ago

Description

Given its name, I expected UltraNest's PredictionBand to give a band derived from the posterior predictive distribution, but this is not what it seems to compute. The following example illustrates this.

figure

Am I correct in concluding that PredictionBand does not use the posterior predictive distribution, and if so, could this feature be added to UltraNest?

JohannesBuchner commented 1 year ago

I am not sure I understand your question. PredictionBand plots quantiles of whatever you feed it with .add()

It seems here you gave it the lines. From your question I guess you want to give it newly sampled data?

JorisDeRidder commented 1 year ago

Thanks for the very quick answer. That's indeed the cause of the discrepancy, which I should have seen but which I overlooked when copying the examples given in the documentation. You might want to consider changing the example about "Time series fitting" in UltraNest's documentation. The line

band = PredictionBand(t_grid)

suggests you want to construct a prediction band, which I suspect many users relate to the posterior predictive distribution. But in the end that's not what is computed in that example, so this could be confusing.

JohannesBuchner commented 1 year ago

As far as I understand, "posterior predictive distribution" is a concept not restricted to the data, indeed, https://en.wikipedia.org/wiki/Posterior_predictive_distribution says "posterior predictive distribution of x" (where x is the data) and suggests that other unobserved quantities also have a posterior predictive distribution.

JohannesBuchner commented 1 year ago

Possibly related: https://en.wikipedia.org/wiki/Prediction_interval#Bayesian_statistics

JorisDeRidder commented 1 year ago

Both PyMC and PyStan implement the PPD of new data, hence the reason I was assuming too quickly that PredictionBand was meant to do the same. It's absolutely fine that PredictionBand is a general QuantileBand generator, but I'm sure that PyMC/Stan users would find it clarifying if the Time Series Fitting example of UltraNest would show that it can serve both to generate a quantile band of the mean response as well as a prediction band for new observations.