以下の差分方程式を考える.
$$ \begin{eqnarray} X_{t+1} = AX_t + b + \Sigma W_{t + 1}\\ \\ \end{eqnarray} $$$$ \begin{eqnarray} where \hspace{5pt} && X_t : n \times 1, \ A: n \times n, \ b: n \times 1, \ \Sigma: n \times n, \ W_t: n \times 1 \\[10pt] && W_t \hspace{5pt} \ i.i.d. \sim F, \ E[W_t] = \left( \begin{array}{c} 0 \\ 0 \\ \vdots \\ 0 \end{array} \right), \ Var(W_t) = \left( \begin{array}{c} 1, 0, 0, \ldots, 0 \\ 0, 1, 0, \ldots, 0 \\ \ddots \\ 0, 0, 0, \ldots, 1 \end{array} \right) \\ \end{eqnarray} $$
In [1]:
using QuantEcon
using Distributions
In [2]:
EPSILON = 1e-12
function compute_asymptotic_var(A, Sigma, loop_max=1e^5)
V = Sigma * Sigma'
S = V
i = 0
while i < loop_max
next_S = A * S * A' + V
if norm(S - next_S) < EPSILON
break
end
S = next_S
i += 1
end
return S
end
Out[2]:
In [9]:
A = [0.8 -0.2; -0.1 0.7]
Sigma = [0.5 0.4; 0.4 0.6]
less_than_1 = all(abs(eigvals(A)) .< 1)
println("固有値: ", eigs)
println("最大固有値は1未満か: ", less_than_1)
In [12]:
s = compute_asymptotic_var(A, Sigma)
println("漸近分散: ", s)
In [13]:
println(solve_discrete_lyapunov(A, Sigma * Sigma'))
両者は一致.