# Truncation in a parameter based on other parameters

Hi,
I can’t figure out what I’m doing wrong here. I’m pretty sure I did this already and worked fine.
I have a regression based on a gamma likelihood without any link. So the first parameter has to be positive.

The first parameter is the regression:
\alpha_1 - log(freq)\cdot \alpha_2 - freq \cdot \alpha_3,
where freq and pred are vectors.

So I want to force \alpha_1 to be larger than 0 or the absolute value of - log(freq)\cdot \alpha_2 - freq \cdot \alpha_3.

To force this, I do this:
 real<lower = fmax(0, -min(- alpha_2 * log(freq) - alpha_3 * pred)) > alpha_1;

But now I also need to truncate the distribution of the prior, because the truncation depends on two parameters.
I was pretty sure it needs to be like this:

 target += normal_lpdf(alpha_1 | .122, .1)
-    normal_lccdf(fmax(0, -min(- alpha_2 * log(freq) - alpha_3 * pred)) | .122, .1);


But the model doesn’t even start, even when I’m not including the likelihood! (only_prior=1).

Please help! It’s probably something stupid due to the lack of sleep, but my newborn is not going to sleep better any time soon :/

Full model below

data {
int N_obs;
vector<lower = 0>[N_obs] RT;
vector<lower = 0>[N_obs] pred;
vector<lower = 0>[N_obs] freq;
int only_prior; // for prior predictive checks
}
parameters {
real<lower = 0> alpha_2;
real<lower = 0> alpha_3;
real<lower = fmax(0, -min(- alpha_2 * log(freq) - alpha_3 * pred)) > alpha_1;
real<lower = 0> rate;
}
transformed parameters {
vector<lower = 0>[N_obs] mL1 = alpha_1 - alpha_2 * log(freq) - alpha_3 * pred;
}
model {
//priors:
target += normal_lpdf(sigma | .22, .1);
target += normal_lpdf(alpha_1 | .122, .1)
-    normal_lccdf(fmax(0, -min(- alpha_2 * log(freq) - alpha_3 * pred)) | .122, .1);
target += normal_lpdf(alpha_2 | .004, .1);
target += normal_lpdf(alpha_3 | .010, .1);

if(!only_prior)
target += gamma_lpdf(RT | mL1, rate);
}


ok, this is my old enemy overflow to -infinity of the lccdf!

I think that the solutions are either initial values or some approximation to the lccdf like Phi_approx. Any suggestions?

Would it be easier to exponentiate this whole expression and then use the resulting term in your likelihood?

probably, but then it wouldn’t be additive anymore.
This is a part of a computation model, and I’m trying to respect it as much as possible.

I have a bunch of situations like that and for now, I’m setting initial values very close to zero, and then it works fine.

1 Like