N = 100
P.b = 2
mu = rep(0.3, P.b)
phi = rep(0.95, P.b)
W = rep(0.1, P.b)
m0 = rep(0, P.b)
C0 = rep(1, P.b)
beta0 = m0 + sqrt(C0) * rnorm(P.b, 0, 1)
beta = matrix(0, nrow=P.b, ncol=N+1)
beta[,1] = beta0
for (i in 2:(N+1)) {
beta[,i] = mu + phi * (beta[,i-1] - mu) + sqrt(W) * rnorm(P.b, 0, 1);
}
W.vec = diag(W)
mu = draw.mu.ar1.ind (beta, phi, W.vec, rep(0, P.b), rep(0, P.b))
phi = draw.phi.ar1.ind(beta, mu , W.vec, rep(0.9, P.b), rep(0, P.b), 0.5)
W = draw.W.ar1.ind (beta, mu, phi, rep(2, P.b), rep(2, P.b))
Run the code above in your browser using DataLab