Graduate Quantitative Economics and Datascience
Iterate \(x_{t+1} = A x_t\) from \(x_0\) for \(t=100\)
rho(A) = 1.079128784747792
x_200 = [3406689.32410673 6102361.18640516]
rho(A) = 0.9449489742783178
x_200 = [6.03450418e-06 2.08159603e-05]
A = np.array([[0.9, 0.1],
[0.5, 0.8]]) # rho(A) > 1
Lambda, Q = eig(A)
Lambda = [1.0, 0.8]
A = Q @ np.diag(Lambda) @ inv(Q)
x_t = np.linalg.matrix_power(A, t) @ x_0
print(f"Q =\n{Q}")
print(f"A =\n{A}")
print(f"rho(A) = {np.max(np.abs(eigvals(A)))}")
print(f"x_{t} = {x_t}")
print(f"||x_0|| = {norm(x_0)}")
print(f"||x_{t}|| = {norm(x_t)}")
Q =
[[ 0.48744474 -0.33726692]
[ 0.87315384 0.94140906]]
A =
[[0.92182179 0.04364358]
[0.21821789 0.87817821]]
rho(A) = 1.0
x_200 = [0.82732684 1.48198051]
||x_0|| = 1.4142135623730951
||x_200|| = 1.6972730813998493
x_0 = [2.04726791 3.66724612]
x_200 = [2.04726791 3.66724612]
||x_0|| = 4.199999999999999
||x_200|| = 4.20000000000001
x_0 = [-1.41652108 3.95391806]
x_200 = [5.53682082e-16 8.72332377e-16]
||x_0|| = 4.2
||x_200|| = 1.0332122842102235e-15
\[ \begin{aligned} E_{t+1} &= (1-\alpha) E_t + \phi U_t\\ U_{t+1} &= \alpha E_t + (1-\phi) U_t \end{aligned} \]
\[ \underbrace{\begin{bmatrix} E_{t+1}\\U_{t+1}\end{bmatrix}}_{X_{t+1}} = \underbrace{\begin{bmatrix} 1-\alpha & \phi \\ \alpha & 1-\phi \end{bmatrix}}_{ A} \underbrace{\begin{bmatrix} E_{t}\\U_{t}\end{bmatrix}}_{X_t} \]
Simulate by iterating \(X_{t+1} = A X_t\) from \(X_0\) until \(T=100\)
Find \(X_{\infty}\) by iterating \(X_{t+1} = A X_t\) many times from a \(X_0\)?
Alternatively, note that this expression is the same as
\[ 1 \times \bar{X} = A \bar{X} \]
real eigenvalues = [1. 0.85]
eigenvectors in columns of =
[[ 0.89442719 -0.70710678]
[ 0.4472136 0.70710678]]
first eigenvalue = 1? True
X_bar = [666666.66666667 333333.33333333]
X_100 = [666666.6870779 333333.31292209]
Lambda_fast = np.array([1.0, 0.4])
A_fast = Q @ np.diag(Lambda_fast) @ inv(Q) # same eigenvectors
print("A_fast =\n", A_fast)
print(f"alpha_fast/alpha = {A_fast[1,0]/A[1,0]:.2g}, \
phi_fast/phi = {A_fast[0,1]/A[0,1]:.2g}")
X_fast = simulate(A_fast, X_0, T)
print(f"X_{T} = {X_fast[:,T]}")
A_fast =
[[0.8 0.4]
[0.2 0.6]]
alpha_fast/alpha = 4, phi_fast/phi = 4
X_100 = [666666.66666667 333333.33333333]
Here is an example with \(1 < \rho(A) < 1/\beta\). Try with different \(A\)
beta = 0.9
A = np.array([[0.85, 0.1],
[0.2, 0.9]])
G = np.array([[1.0, 1.0]]) # row vector
x_0 = np.array([1.0, 1.0])
p_t = G @ solve(np.eye(2) - beta * A, x_0)
#p_t = G @ inv(np.eye(2) - beta * A) @ x_0 # alternative
rho_A = np.max(np.abs(np.real(eigvals(A))))
print(f"p_t = {p_t[0]:.4g}, spectral radius = {rho_A:.4g}, 1/beta = {1/beta:.4g}")
p_t = 24.43, spectral radius = 1.019, 1/beta = 1.111