# How do I check in practice if a posterior is proper?

I know that improper priors sometimes lead to improper posteriors and that I shouldn't be doing inference with an improper posterior. But short of computing $$\int \pi(\theta\mid x)\,\text d\theta$$ what's a principled way to check if I've accidentally chosen improper priors that led to an improper posterior? Can I do this with just my posterior samples when I don't even know the functional form of $$\pi(\theta\mid x)$$?

• If the posterior is improper, you cannot get posterior samples, you cannot run a converging MCMC, &tc. Thus checking $$\int \pi(\theta) f(x|\theta) \text{d}\theta<\infty$$is the only solution! – Xi'an Apr 16 at 19:03
• @Xi'an thank you for the comment! Is it correct then that it's completely sufficient to check for this by the usual MCMC diagnostics, and if my sampler is convergent then I don't need to worry about an improper posterior? – alfalfa Apr 16 at 19:10
• No I do not think this is correct as I do not know of foolproof diagnostics for improper posteriors. These diagnostics only apply to proper posteriors and convergent MCMC chains. – Xi'an Apr 16 at 19:41
• If you suspect that the posterior is flat in some direction, one way to obtain an indication of this is to do run several mcmc chains, each restricted to different subintervals (such that they converge), and then align density estimates based on these mcmc runs to obtain an estimate of the overall possibly improper posterior. I used this method in this paper, see Figure S5. – Jarle Tufto Apr 17 at 13:49
• @JarleTufto thank you, i will look into that – alfalfa Apr 19 at 14:44

The fundamental issue with improper posteriors $$\mu$$ is that Markov chains associated with them are either transient (reaching almost surely and definitely some infinite region of the state space) or null recurrent (revisiting past places but in an infinite time). In the later case, there is a form of ergodic theorem, namely that for $$g,h\in\mathcal L¹(\mu)$$, $$\dfrac{\sum_{t=1}^T g(\theta^t)}{\sum_{t=1}^T h(\theta^t)}\longrightarrow\dfrac{\int g(\theta)\,\text{d}\mu)\theta)}{\int h(\theta)\,\text{d}\mu(\theta)}$$ which means that some form of stability occurs and in consequence turns detection of infinite mass difficult, especially when the improper nature of the posterior occurs near a finite boundary. This happened for instance for an ANOVA model analysed in one of the first Gibbs sampling papers in 1990, namely that the Gibbs sampler did not produce detectable signals of the issue...

Here is a toy example based on the improper target $$\mu(\theta)=e^{-\theta}/\theta$$ over $$\Bbb R^*_+$$:

   targ=function(x) ifelse(x>0,1/x/exp(x),0)
T=1e6
mark=rep(1,T)
for (t in 2:T){
prop=rnorm(1,mark[t-1],.1)
mark[t]=ifelse(runif(1)<targ(prop)/targ(mark[t-1]),prop,mark[t-1])}


with an output that looks not that great but still moving around: • thank you, this has proved to be a more nuanced issue than i first guessed – alfalfa Apr 22 at 15:19