Thank you very much for your response @bgoodri. I think I have not explained myself clearly, so I will try to develop it a little more to see if I am able to transmit my point.
In any case, your answer has clarified me one point that I also had in mind, and generated an additional question. I understand that the way of coding the model that you propose would work for the stationary case if I use an improper prior but, would it be possible to set a proper prior? That is, may I truncate the distribution in the same way:
location ~ normal(0, 1) [ shape > 0 ? negative_infinity() : max_z + scale / shape,
shape < 0 ? positive_infinity() : min_z + scale / shape ]
Going back now to my original question, my problem is that location
is not a parameter, but a transformed parameter. That is, location
is not sampled directly but generated as a linear combination of other parameters, specifically a constant value location_base
and the product of a coefficient alfa
and time (linear trend).
data {
int<lower = 1> N;
vector[N] time;
vector[N] z;
}
transformed data {
real min_z = min(z);
real max_z = max(z);
}
parameters {
real location_base;
real scale_base_raw;
real shape_base;
vector[3] alfa;
}
transformed parameters {
vector<lower = 0>[N] scale;
vector[N] shape;
vector<lower = shape > 0 ? negative_infinity() : max_z + scale / shape,
upper = shape < 0 ? positive_infinity() : min_z + scale / shape>[N] location;
scale = exp(scale_base_raw + alfa[2] * time);
shape = shape_base + alfa[3] * time;
location = location_base + alfa[1] * time;
}
model {
z ~ gev(location, scale, shape);
}
generated quantities {
real scale_base;
scale_base = exp(scale_base_raw);
}
In some cases I am able to set a reparameterization that allows me to sample only valid values for the parameters. For instance, the scale parameter must be positive and thus I generate it as:
scale = exp(scale_base_raw + alfa[2] * time);
No matter the distribution that I use for scale_base_raw
and alfa[2]
the sampler is able to only generate valid candidates for scale.
However, in the case of the location
parameter, because of the discontinuity introduced by the value of shape
, I am not being able to formulate a proper reparameterization. I now understand how to set the lower and upper limits, which is great, but I understand that this is not enough to ensure that only valid parameters will be generated. Am I missing some point here? Is reparameterization not the proper strategy to follow here?
In essence, I believe that my question is: how do I enforce, by construction, that a linear combination of parameters (or any other function for that sake) always satisfies a constraint like the one location
has in the GEV case.
Sorry for the long message. I hoped to have been able to explain myself in less lines but I may not have acquired the proper lingo yet. Thank you very much for you help and attention.