Thank you for your very thorough reply. I read your blogpost and it was one of the most enlightening explanations I could find. Sorry for pushing the argument. I logically understand I am wrong, but the intuition evades me. I guess I was still confused about the following:

In the first model, if we rewrite it in the `target+=`

format, my Rayleigh prior makes contribution to the likelihood

```
model {
target+= rayleigh_lpdf(Theta | 0.1);
for (n in 1:N)
target+=exponential_lpdf(y[n] | Theta);
}
```

In the second model, since the prior is now uniform, the contribution of the prior to the total likelihood is a constant 0, so the prior contributes nothing. Yes, the values of `QTheta`

are different from the values of `Theta`

, but that should not affect how the total likelihood is distributed between the data and the prior (or should it?).

```
model {
target+= uniform_lpdf(u | 0,1);
for (n in 1:N)
target+=exponential_lpdf(y[n] | QTheta);
}
```

I am, at the end of the day, changing the left side of the `~`

: it is `Theta`

in the first and `u`

in the second model. I guess I expected something like this to be balancing out the transformation.

```
model {
target+= uniform_lpdf(u | 0,1); // equal 0
target+= something_based_on_rayleigh_icdf();
for (n in 1:N)
target+=exponential_lpdf(y[n] | QTheta);
}
```

And if my ICDF transformation does not in fact change the “left side of tilde”, then what you’re saying is that the only way I would require a Jacobian in this example, is if my transformation would affect the data, `y[i]`

? [1]

I have made an example of that as well and again the posteriors look very similar. Here’s my Rayleight/Exponential model where likelihood is DQF-defined (i.e. `f(Q(u))`

-defined) . DQF is density quantile function and it is the reciprocal to the first derivative of ICDF [2].

```
stanmodelcode3 <- '
functions{
real exponential_ldqf_lpdf(real p, real Theta){
return log(Theta)+log1m(p);
}
}
data {
int<lower=0> N;
int<lower=0> y[N];
}
parameters {
real<lower=0.00001> Theta;
}
transformed parameters{
real u[N];
for (n in 1:N){
u[n] = exponential_cdf(y[n], Theta);
}
}
model {
target += rayleigh_lpdf(Theta | 0.1);
for (n in 1:N)
target += exponential_ldqf_lpdf( u[n] | Theta);
}
generated quantities{
real y_pred;
y_pred = exponential_rng(Theta);
}
'
init_f <- function() list(Theta = runif(1, 0.001, 0.005))
# fit the model with DQF likelihood
stanDso3 <- stan_model(model_code = stanmodelcode3)
fit3 <- sampling(stanDso3, data = dat, iter = 10000, warmup=2000,
init=init_f, control=list(adapt_delta=0.9))
pairs(fit3)
d_idx <- rstan::get_divergent_iterations(fit3)
# share of divergent
mean(d_idx)
# [1] 0
# extract divergent iterations
fit3 %>% as.matrix() %>% .[d_idx,]
draws3 <- posterior::as_draws_array(fit3) %>%
posterior::subset_draws(variable="Theta") %>%
posterior::rename_variables("PTheta"="Theta")
#useless for comparing densities
#posterior::bind_draws(draws1, draws3) %>%
# bayesplot::mcmc_dens()
library(ggplot2)
posterior::bind_draws(draws1, draws3) %>%
posterior::as_draws_df() %>%
tidyr::pivot_longer(-c(.iteration, .chain, .draw)) %>%
ggplot()+
geom_density(aes(x=value, color=name, fill=name), alpha=0.2)+
theme_minimal()
```

I just want to be dead sure I am not missing any Jacobians here. Sorry folks for picking your brain like that, but isn’t it what the forums are made for? ))

###
Footnotes:

[1] I know I could transform `Theta`

as well, but let’s set it aside for now.

[2] Here’s a bit of math to support my quantile likelihood:

F^{-1}(u)=Q(u)=x, so I can drop in Q(u) for x into the likelihood, where x is my data

f(x)=f(Q(u))=\frac{dF(Q(u))}{dQ(u)} = \frac{dF(Q(u))/du}{dQ(u)/du}=\frac{dF(F^{-1}(u))/du}{q(u)}=\frac{du/du}{q(u)}=[q(u)]^{-1}

Exponential QF: Q(u)=-\ln(1-u)/\Theta

Exponential QDF:q(u)=Q'(u)=1/(\Theta(1-u))

Exponential DQF: f(Q(u))=[q(u)]^{-1}=\Theta(1-u)