Generation of error matrix from AR(1) model, issue
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
VBBV
le 14 Mar 2022
Modifié(e) : VBBV
le 14 Mar 2022
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!