So I think I have similar issues as this post from a few years ago; a random walk on the positive line for small numbers.
There it was suggested to do the walk in log-space. I must confess it is not super obvious to me how to do the walk in log space (even though I thought it would be somewhat straight forward).
I have the following model that I am trying to change into log space (due to the large number of divergent transitions + large Rhat + low ESS):
data {
int<lower = 1> N; // Number of walks
}
transformed data {
vector<lower=0>[N] sqrtn; // Normalization constant
for (i in 1:N) {
sqrtn[i] = 1/sqrt(i);
}
}
parameters {
vector[N] eta; // Random steps
real<lower = 0> sigma; // Random step size
}
transformed parameters {
vector<lower = 0>[N] Rw = 1e-4*sigma*sqrtn.*cumulative_sum(eta); // Wiener process
}
model {
eta ~ normal(0, 1);
sigma ~ gamma(10, 10);
}
I thought the transformation would be something like:
\log\left(\frac{R_T}{10^{-4}\sigma\sqrt{T^{-1}}}\right) = \sum_{i=1}^T\eta_i
Giving:
R_T=10^{-4}\sigma\sqrt{T^{-1}}\exp\left({\sum_{i=1}^T\eta_i}\right)
But this givings nothing even remotely close to the original dynamics.
Any hints or help would be super appreciated (I’m guessing I’m missing a Jacobian correction?).