Why Transform a Parameter?
Some parameters are restricted by their meaning: a rate or scale must be positive, and a probability must lie between zero and one. A proposal made directly on the parameter scale can leave the allowed region. One alternative is to transform the parameter to an unconstrained variable, run a Metropolis–Hastings (MH) chain there, and map each state back. The target density must change under this map. In particular, the Jacobian is part of the transformed target, and therefore part of the acceptance probability.
Work on a probability space \((\Omega,\mathcal{F},\mathbb{P})\). Let \(\theta\) be a scalar parameter in a domain \(\Theta\), with target density \(f_\theta\) relative to Lebesgue measure. A density known only up to a positive normalizing constant is sufficient for MH calculations. Let \(T:\Theta\to\mathcal{X}\) be a differentiable bijection with differentiable inverse, and write \(x=T(\theta)\). The transformed state space is \(\mathcal{X}\), and its target density is the density of \(x=T(\theta)\), not simply \(f_\theta\) with its argument changed.
For a positive parameter, use \(x=\log\theta\), so \(\theta=e^x\), \(x\in\mathbb{R}\), and \(d\theta/dx=e^x\). Thus $$ f_x(x)=f_\theta(e^x)e^x. $$ For a parameter in \((0,1)\), the logit transformation is \(x=\log(\theta/(1-\theta))\), with inverse \(\theta=e^x/(1+e^x)\). Its derivative is \(d\theta/dx=\theta(1-\theta)\), so the transformed density is \(f_\theta(\theta)\theta(1-\theta)\), with \(\theta\) evaluated at the inverse transform.
Proof. For any interval \((a,b)\subseteq\mathcal{X}\), the probability that \(x\) lies in that interval equals the probability that \(\theta\) lies between \(T^{-1}(a)\) and \(T^{-1}(b)\), with endpoints ordered according to the direction of the map. By the one-dimensional change-of-variables formula, this probability is the integral over \((a,b)\) of \(f_\theta(T^{-1}(x))|dT^{-1}(x)/dx|\). Since this holds for every such interval, that integrand is a density for \(x\). \(\square\)
Metropolis–Hastings on the Transformed Scale
Let the transformed state space be \(\mathcal{X}\), let its target density be \(f_x\), and let \(q(y\mid x)\) be a proposal density for a move from \(x\) to \(y\). Given current state \(X_n=x\), draw \(Y\) from this proposal and accept it with probability $$ \alpha(x,y)=\min\left\{1,\frac{f_x(y)q(x\mid y)}{f_x(x)q(y\mid x)}\right\}. $$ If the proposal is rejected, the next state remains \(x\). The ratio is used where the current target density and forward proposal density are positive. For the examples below these densities are positive at every proposed pair. A proposal with zero reverse density has acceptance probability zero when its forward density and target at the proposed point are positive.
More formally, the resulting Markov chain \((X_n)_{n\ge0}\) has state space \(\mathcal{X}\) and discrete time \(n=0,1,\ldots\). At each step, conditional on the past, it draws the proposal and an independent uniform random variable \(U_{n+1}\) on \((0,1)\), accepting when \(U_{n+1}\le\alpha(X_n,Y_{n+1})\). One may take \(\mathcal{F}_n\) to contain the initial state and all proposals and uniforms through step \(n\). The chain is Markov with respect to this filtration. Its target density is stationary if the transition kernel leaves that density unchanged; the next result verifies this property under the stated positivity assumptions. It does not assert convergence from every starting state.
Proof. For distinct states \(x\) and \(y\), the density of accepted moves from \(x\) to \(y\), multiplied by the target density at \(x\), is $$ f_x(x)q(y\mid x)\alpha(x,y) =\min\{f_x(x)q(y\mid x),f_x(y)q(x\mid y)\}. $$ The expression is unchanged when \(x\) and \(y\) are interchanged. This proves detailed balance off the diagonal. Rejected proposals contribute only transitions from a state to itself, for which detailed balance is an equality of a quantity with itself. Thus detailed balance holds for all transitions. Integrating it over the starting state shows stationarity: the incoming target-weighted transition mass at \(y\) equals \(f_x(y)\) times the total transition probability out of \(y\), which is \(f_x(y)\). The total is one because the kernel includes both accepted moves and rejection. \(\square\)
For the log transformation, the same algorithm can be expressed on the original positive parameter scale. If \(q_x(x'\mid x)\) is the proposal density in log coordinates, its induced proposal density for \(\theta'\), given \(\theta\), is $$ q_\theta(\theta'\mid\theta)=q_x(\log\theta'\mid\log\theta)\frac{1}{\theta'},\qquad \theta'>0. $$ The factor \(1/\theta'\) is the derivative of \(\log\theta'\). Substituting this density and the original target \(f_\theta\) into the MH ratio gives $$ \frac{f_\theta(\theta')q_\theta(\theta\mid\theta')} {f_\theta(\theta)q_\theta(\theta'\mid\theta)} = \frac{f_\theta(\theta')\theta'}{f_\theta(\theta)\theta} \frac{q_x(\log\theta\mid\log\theta')}{q_x(\log\theta'\mid\log\theta)}. $$ This is exactly the transformed-scale ratio, since \(f_x(x)=f_\theta(e^x)e^x\). The proposal and target factors must both be transformed consistently.
Worked Acceptance Calculations
Worked Example: A Positive Gamma-Form Target with a Log-Scale Walk
Suppose the target density for \(\theta>0\) is \(f_\theta(\theta)=4\theta^2e^{-2\theta}\), a Gamma density with shape \(3\) and rate \(2\). Use a symmetric random walk on the log scale, proposing \(y=x+\varepsilon\), where the density of \(\varepsilon\) is symmetric about zero. From \(\theta=2\), consider the proposal \(\theta'=4\), so \(x=\log 2\) and \(y=\log 4\). Find the acceptance probability.
The transformed target is \(f_x(x)=f_\theta(e^x)e^x=4e^{3x}e^{-2e^x}\). The proposal is symmetric in \(x\), so the proposal-density ratio is one. Since \(y-x=\log 2\), the target ratio is $$ \frac{f_x(y)}{f_x(x)} =\frac{4(4)^3e^{-2(4)}}{4(2)^3e^{-2(2)}} =2^3e^{-4} =8e^{-4}. $$ Consequently, \(\alpha(x,y)=\min\{1,8e^{-4}\}=8e^{-4}\), since \(e^4>1+4=5\) is not enough to compare with \(8\), but \(e^4>1+4+4^2/2=13>8\).
Check in the original parameter. The target ratio is \(f_\theta(4)/f_\theta(2)=4^2e^{-8}/(2^2e^{-4})=4e^{-4}\). The induced lognormal proposal has reverse-to-forward ratio \(\theta'/\theta=4/2=2\), because the log-scale proposal is symmetric and the proposal density includes the factor \(1/\theta'\). Their product is \(4e^{-4}\cdot2=8e^{-4}\), as above.
Worked Example: A Probability Parameter with a Logit Transform
Let \(\theta\in(0,1)\) have a Beta\((2,3)\) target density \(f_\theta(\theta)=12\theta(1-\theta)^2\). Use the logit coordinate \(x=\log(\theta/(1-\theta))\) and a symmetric random-walk proposal in \(x\). From \(\theta=1/2\), propose \(\theta'=3/4\), which corresponds to \(x=0\) and \(y=\log 3\). Calculate the acceptance probability.
The inverse logit has derivative \(\theta(1-\theta)\), so the transformed target is $$ f_x(x)=12\theta(1-\theta)^2\theta(1-\theta) =12\theta^2(1-\theta)^3. $$ The proposal is symmetric in logit coordinates, and hence its ratio cancels. The target ratio is $$ \frac{f_x(y)}{f_x(x)} =\frac{(3/4)^2(1/4)^3}{(1/2)^2(1/2)^3} =\frac{9}{16}\frac{1}{64}\frac{32}{1} =\frac{9}{32}. $$ This is less than one, so the acceptance probability is \(9/32\).
Check. The proposed value is strictly inside \((0,1)\), and the transformed-density factors at the two points are \(12(1/2)^2(1/2)^3=3/8\) and \(12(3/4)^2(1/4)^3=27/256\). Their ratio is \((27/256)/(3/8)=27/96=9/32\), confirming the calculation.
Worked Example: An Asymmetric Proposal on the Log Scale
Let the target density be \(f_\theta(\theta)=e^{-\theta}\) for \(\theta>0\). In log coordinates, propose \(Y\mid X=x\sim N(x+1,1)\). From \(\theta=1\), so \(x=0\), consider \(y=1\), corresponding to \(\theta'=e\). Find the MH acceptance probability.
The transformed target is \(f_x(x)=e^xe^{-e^x}\). Its ratio at \(y=1\) and \(x=0\) is $$ \frac{f_x(1)}{f_x(0)} =\frac{e e^{-e}}{e^{-1}} =e^{2-e}. $$ The forward proposal density is the standard normal density evaluated at \(1-(0+1)=0\); the reverse proposal density is the normal density with mean \(1+1=2\), evaluated at \(0\), or the standard normal density at \(-2\). Their ratio is \(e^{-2}/1=e^{-2}\), since the standard normal density at \(z\) is proportional to \(e^{-z^2/2}\). Thus the full ratio is \(e^{2-e}e^{-2}=e^{-e}\), and the acceptance probability is \(e^{-e}\).
Check in \(\theta\)-coordinates. The target ratio is \(e^{-e}/e^{-1}=e^{1-e}\). The reverse-to-forward proposal ratio on the positive scale is the log-coordinate ratio \(e^{-2}\) multiplied by \(\theta'/\theta=e/1\), giving \(e^{-1}\). The product is \(e^{1-e}e^{-1}=e^{-e}\), matching the transformed calculation.
Common Mistake: Changing the Argument but Not the Density
A frequent error is to use \(f_\theta(e^x)\) as the target density for \(x\) and omit the Jacobian \(e^x\). That expression is generally not a density for the transformed variable: it assigns the wrong amount of probability to intervals on the \(x\)-scale. For the Gamma-form target in the first example, the incorrect transformed target would be proportional to \(e^{2x}e^{-2e^x}\), while the correct one is proportional to \(e^{3x}e^{-2e^x}\). For the proposal from \(\theta=2\) to \(\theta'=4\), the incorrect symmetric-log proposal ratio would be \(4e^{-4}\), because it omits the additional factor \(4/2=2\). The correct ratio is \(8e^{-4}\). The same missing factor appears if one works directly on the positive scale but forgets the \(1/\theta'\) in the induced proposal density.
Transformations make constraints convenient, but they do not remove the constraint from the probability model: they encode it through the map and its Jacobian. A log transform covers positive values \((0,\infty)\), not zero; a logit transform covers the open interval \((0,1)\), not its endpoints. If a target assigns probability to a boundary point, a bijection from an open interval does not represent that point, and the model must handle the boundary separately. Finally, detailed balance verifies that the target is stationary for the constructed kernel; stationarity alone is not a claim that a chain started elsewhere converges to that target.
Check Your Understanding
For each question, state which density is being used and include every Jacobian or proposal-ratio factor that applies.
- If \(x=\log\theta\) and \(f_\theta(\theta)\propto\theta^{a-1}e^{-b\theta}\) for \(\theta>0\), what is the transformed target up to proportionality?
- For a symmetric random walk in \(x=\log\theta\), what is the reverse-to-forward proposal ratio when the proposed value is \(\theta'=c\theta\), with \(c>0\)?
- For a logit transformation, derive \(d\theta/dx\) from \(\theta=e^x/(1+e^x)\).
- In the asymmetric normal proposal example, identify separately the transformed-target ratio and the proposal ratio.
- Why does detailed balance imply stationarity, and why does that conclusion alone not establish convergence from every initial state?