VAR(1) process - In an assignment A(I) = B, the number of elements in B and I must be the same.
Show older comments
I am very new to Matlab and I have to simulate the following var(1) process for 100 periods, starting from g(0) and f(0) = 0
[Circular brackets will indicate time subscript]
[g(t); f(t)] = [0.7 0.2; 0.2 0.7]*[g(t-1); f(t-1)] + [u1(t); u2(t)]
E[u1(t).u2(t)] = sigma where sigma = [1 0.8; 0.8 1] for every period I am meant to take [u1(t); u2(t)] from a RNG. [i.e. mvnrnd(0, sigma)]
I cannot seem to get the loop to work even with hours of changing (I am new to all programming).
My code so far looks like this:
A = [0.7 0.2; 0.2 0.7];
sigma = [1 0.8; 0.8 1];
mu = [0 0; 0 0];
g0 = 0;
f0 = 0;
R = mvnrnd(mu, sigma);
X = [g0; f0];
X(1) = mu + R;
for t = 1:100
X(t+1) = A*X(t) + R;
end
From here, I obtain "In an assignment A(I) = B, the number of elements in B and I must be the same." Any guidance would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!