Independent MH
Gamma distribution
Robert and Casella (2013) presents the following algorithm:

If there exists a constant M such that
the algorithm produces a uniformly ergodic chain (Theorem), and the expected acceptance probability associated with the algorithm is at least 1/M when the chain is stationary, and in that sense, the IMH is more efficient than the Accept-Reject algorithm.
Let's illustrate this algorithm with Ga(α,1). We have introduced how to sample from Gamma distribution via Accept-Reject algorithm in Special Distributions, and it is straightforward to get the Gamma Metropolis-Hastings based on the ratio of f/g,

And we can implement this algorithm with the Julia code:
To sample Ga(2.43,1), and estimate Ef(X2)=2.43+2.432=8.33.

Logistic Regression
We observe (xi,yi),i=1,…,n according to the model
The likelihood is
and let π(eα)∼Exp(1/b) and put a flat prior on β, i.e.,
Note that
where
is the Euler's Constant.
Choose the data-dependent value that makes Eα=α^, where α^ is the MLE of α, so b^=exp(α^+γ).
We can use MLE to estimate the coefficient in the logistical model (see my post for the derivation), and the following Julia code can help us fit the model quickly.

The estimates of the parameters are α^=15.0479,β^=−0.232163 and σ^β=0.108137.
Wrote the following Julia code to implement the independent MH algorithm,

Saddlepoint tail area approximation
If K(τ)=log(Eexp(τX)) is the cumulant generating function, solving the saddlepoint equation K′(τ)=x yields the saddlepoint. For noncentral chi squared random variable X, the moment generating function is
where p is the number of degrees of freedom and λ is the noncentrality parameter, and its saddlepoint is
The saddlepoint can be used to approximate the tail area of a distribution. We have the approximation
where Zi is the sample from the saddlepoint distribution. Using a Taylor series approximation,
so the instrumental density can be chosen as N(0,nKX′′(0)1), where
I implemented the independent MH algorithm via the following code to produce random variables from the saddlepoint distribution.
I can successfully reproduce the results.
If n=1,
Interval
1 - pchisq(x, 6, 9*2)
IMH
(36.225,∞)
0.1000076
0.1037
(40.542,∞)
0.05000061
0.0516
(49.333,∞)
0.01000057
0.0114
For n=100, note that if Xi∼χp2(λ), then nXˉ=∑Xi∼χnp2(nλ), then we can use the following R code to figure out the cutpoints.
Then use these cutpoints to estimate the probability by using samples produced from independent MH algorithm.
Interval
1 - pchisq(x*100, 6*100, 9*2*100)
IMH
(25.18054,∞)
0.10
0.1045
(25.52361,∞)
0.05
0.0516
(26.17395,∞)
0.01
0.0093
Last updated