Generation of error matrix from AR(1) model, issue
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to generate a (t by n) matrix of errors (ε) , row by row, which are drawn from an AR(1) model ε_t = ρ*ε_t-1 + u_t. The problem I encountered is that from row t=3 until row t=T I get the same errors as is shown in the picture, which is odd. I get this for any t and n. Any help is appreciated! Thank you very much for your time! :)
t=5; n=10;
u_t = randn(1,n); %innovation term
epsilon = zeros(t,n); %preallocation
rho=0.5; %parameter ρ for the AR(1) model
epsilon(1,:) = randn(1,n)*sqrt(1/(1-rho^2)); %starting value of epsilon
%Draw epsilon in a vectorized way
T=2:t;
epsilon(T,:)=rho*epsilon(T-1,:) + u_t; %AR(1) model
댓글 수: 4
채택된 답변
VBBV
2022년 3월 14일
편집: VBBV
2022년 3월 14일
t=5; n=10;
u_t = randn(1,n) %innovation term
epsilon = zeros(t,n); %preallocation
rho=0.5; %parameter ρ for the AR(1) model
epsilon(1,:) = randn(1,n)*sqrt(1/(1-rho^2)) %starting value of epsilon
%Draw epsilon in a vectorized way
for k = 2 :t
epsilon(k,:)=rho*epsilon(k-1,:) + u_t ;%AR(1) model
end
epsilon
% in vectorized way
T = 2:t;
epsilon(2:t,:) = rho*epsilon(T-1,:) + u_t
one approach is to use loop and test it ,
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!