Revision 3a0684e0b08c3f968d21e6adc132def13c0405da authored by Mitzi Morris on 04 May 2020, 00:40:12 UTC, committed by Mitzi Morris on 04 May 2020, 00:40:12 UTC
1 parent 8487a15
ma2.stan
data {
int<lower=3> T; // number of observations
vector[T] y; // observation at time T
}
parameters {
real mu; // mean
real<lower=0> sigma; // error scale
vector[2] theta; // lag coefficients
}
transformed parameters {
vector[T] epsilon; // error terms
epsilon[1] <- y[1] - mu;
epsilon[2] <- y[2] - mu - theta[1] * epsilon[1];
for (t in 3:T)
epsilon[t] <- ( y[t] - mu
- theta[1] * epsilon[t - 1]
- theta[2] * epsilon[t - 2] );
}
model {
mu ~ cauchy(0,2.5);
theta ~ cauchy(0,2.5);
sigma ~ cauchy(0,2.5);
for (t in 3:T)
y[t] ~ normal(mu
+ theta[1] * epsilon[t - 1]
+ theta[2] * epsilon[t - 2],
sigma);
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...