Solutions for http://quant-econ.net/jl/julia_arrays.html
Here's the iterative approach
In [1]:
function compute_asymptotic_var(A, Sigma, tolerance=1e-6)
V = Sigma * Sigma'
S = V
err = tolerance + 1
while err > tolerance
next_S = A * S * A' + V
err = norm(S - next_S)
S = next_S
end
return S
end
Out[1]:
In [2]:
A = [0.8 -0.2;
-0.1 0.7]
Sigma = [0.5 0.4;
0.4 0.6]
Out[2]:
Note that all eigenvalues of $A$ lie inside the unit disc:
In [3]:
eigmax(A)
Out[3]:
Let's compute the asymptotic variance:
In [4]:
compute_asymptotic_var(A, Sigma)
Out[4]:
Now let's do the same thing using QuantEcon's solve_discrete_lyapunov()
function and check we get the same result
In [6]:
using QuantEcon
In [7]:
solve_discrete_lyapunov(A, Sigma * Sigma')
Out[7]: