I have data the height of a human (y_i) at time points (t_i), i = 1, \dots, n, with t_1 < t_2 < \dots < t_{n - 1} < t_n. The model is
Y_i | \mu_i, \sigma^2 \sim N(\mu_i, \sigma^2), i = 1, \dots, n
\mu_i = h_1 - \dfrac{2(h_1 - h_{\theta})}{\exp(s_0(t_i - \theta)) + \exp(s_1(t_i - \theta))}
The model has the following 6 parameters:
- The height h_1 is the adult height of the individual (i.e. when t becomes large).
- The time point \theta, and the (expected) height h_\theta at that time point. Note, we would expect h_\theta \le h_1 or, in other words, 0 \le \theta < t_n.
- Two rate parameters s_0 and s_1, which should be positive. Note that these are actually not distinguishable, i.e. (s_0, s_1) = (0.4, 0.8) and (s_0, s_1) = (0.8, 0.4) will yield the same fits (if all other parameters are set to the same value). To make these rate parameters identifiable, it would be natural to impose constraints of the form 0 < s_0 < s_1.
- The error variability \sigma^2.
My Stan code is as follows:
data {
int<lower=1> n;
ordered[n] t; // age
ordered[n] y; // height of human
}
parameters {
positive_ordered[2] h;
real<lower=0, upper=t[n-1]>theta;
positive_ordered[2] s; // we will put flat priors on these rate parameters
real<lower=0>sigma;
}
model {
theta ~ uniform(0, 1);
h[1] ~ uniform(0, y[n]);
h[2] ~ normal(180, 20);
sigma ~ cauchy(0, 5);
y ~ normal(h[2] - (2*(h[2] - h[1]) / (exp(s[1]*(t - theta)) + exp(s[2]*(t - theta)))), sigma);
}
I am getting the following error when I try to compile this model:
I’ve reviewed the code, but I’m unable to find where the error is. I would appreciate it if people could please take the time to help me with this error.