Problem with simulating an AR(2) process

9 visualizaciones (últimos 30 días)
Ferry el 12 de Oct. de 2021
Respondida: Ferry el 21 de Oct. de 2021
I'm new in Matlab. I‘m trying to simulate a second-order autoregressive process which is stationary, but end up with an explosive pattern. I don't know why I cannot get it right. The process I simulate is
I made the following programm to simulate it for 200 periods, with initial values
rng(1);
% parameters
rhho2 = [30, 1.2, -0.5];
% preallocation
N = 200 ;
y = zeros(N, 1);
y(1:2, :) = [100; 100];
% innovation
innovation = randn(200, 1);
for t = 3 : N
y(t, :) = rhho2 * [1; y([t-2, t-1], :)]+ innovation(t, 1);
end
The plot for the simulated resut shows an explosve pattern, being contradictary to the expection of a stationary process
% plot
plot(y, "-r")
yline(100)
By using the econometric toolbox, this simulated results is stationary. So what is problem with my simulation program?
rng(1)
model2 = arima("constant", 30, "AR", [1.2, -0.5], "Variance", 1);
Y2 = simulate(model2, 200);
plot(Y2, "-r")
yline(100)
0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Ferry el 21 de Oct. de 2021
It's true! Thanks a lot!
0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Más respuestas (1)

Pavan Guntha el 20 de Oct. de 2021
Hello Ferry,
The reason for mismatch in the outputs is due to the misordering in the following equation:
y(t, :) = rhho2 * [1; y([t-2, t-1], :)]+ innovation(t, 1);
This is supposed to be as follows as per the equation presented in the question:
y(t, :) = rhho2 * [1; y([t-1, t-2], :)]+ innovation(t, 1);
Hope this helps!
1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Ferry el 21 de Oct. de 2021
It's true! Thanks a lot!

Iniciar sesión para comentar.

Categorías

Más información sobre Conditional Mean Models en Help Center y File Exchange.

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by