Skip to content

Commit d6e8c80

Browse files
author
Bob Carpenter
committed
added alternative parameterization of ARMA(1,1) model
1 parent 6faa10e commit d6e8c80

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

misc/moving-avg/arma11_alt.stan

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ARMA(1,1) with Wayne Folta-style err encoding
2+
3+
data {
4+
int<lower=1> T; // number of observations
5+
real y[T]; // observed outputs
6+
}
7+
parameters {
8+
real mu; // mean term
9+
real phi; // autoregression coeff
10+
real theta; // moving avg coeff
11+
real<lower=0> sigma; // noise scale
12+
}
13+
model {
14+
real err;
15+
mu ~ normal(0,10);
16+
phi ~ normal(0,2);
17+
theta ~ normal(0,2);
18+
sigma ~ cauchy(0,5);
19+
err <- y[1] - mu + phi * mu;
20+
err ~ normal(0,sigma);
21+
for (t in 2:T) {
22+
err <- y[t] - (mu + phi * y[t-1] + theta * err);
23+
err ~ normal(0,sigma);
24+
}
25+
}

0 commit comments

Comments
 (0)