# How to make a stan model as a linear Gaussian system

Hi everyone,

I’m pretty new to the amazing Stan world. I need to make a model similar the following attached file. This model relates casually theta[t+1] to e[t+1] and theta[t].

Considering the fact that we only have values of 1) theta[t+1] 2 )theta[t] and 3) e[t+1]. On the other hand, alpha [et+1], beta[et+1] and two different sigmas (sigma[et+1] and sigma) are UNKNOWN.

In the paper, it’s mentioned that this model was generated as a linear Gaussian system where full bayesian was performed through HMC sampling with Stan. My main question is, most of the tutorials have equations for fitting of a mode for one variable like y. In my case though, it’s the probability of getting theta[t+1] given theta[t] and e[t+1]. How can I write a model like the attached file where on the left hand side I have the probability instead of one variable? Also, are the defined variables correct? what are the problems of my written model?

``````  data {
int < lower = 1 > N; // Sample size
vector[N] x; // Predictor
vector[N] y; // Outcome
}

parameters {
real alpha;    //  Slope (regression coefficients)
real beta;    //  Intercept
real < lower = 0 > sigmaet; // sigma of et+1
real < lower = 0 > sigma;   // sigma for theta dist
}

model {
for( t in 2:N)
x[t] ~ normal(x[t],sigma);
for( t in 2:N-1)
y[t+1] ~ normal(y[t+1],sigma);
for (t in 2:N)
y[t] ~ normal(beta + x[t] * alpha , sigmaet);

}``````