Oh alright, that explains why the summation was confusing to me.
This code is from another post, with different purpose, but if a simple example of a latent variable will help, this may be a starting point. Linear regression with data-dependent error variances - #6 by cmcd
Does that help at all?
It sounds like the difficult part is building the data itself, and probably the indexing inside the model will be a little challenging.
data {
int n;
vector[n] z; // observations or estimates
vector[n] se; // standard errors of the observations
vector[n] x; // covariate
}
parameters {
vector[n] y;
real alpha;
real beta;
real<lower=0> sigma;
}
model {
// data model
z ~ normal(y, se);
// process model
y ~ normal(alpha + x * beta, sigma);
// parameter models
// put priors on your parameters
}