How to use the quantecon.LinearStateSpace function in quantecon

To help you get started, we’ve selected a few quantecon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuantEcon / QuantEcon.lectures.code / linear_models / paths_and_stationarity.py View on Github external
phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5
sigma = 0.1

A = [[phi_1, phi_2, phi_3, phi_4],
     [1,     0,     0,     0],
     [0,     1,     0,     0],
     [0,     0,     1,     0]]
C = [[sigma], [0], [0], [0]]
G = [1, 0, 0, 0]

T0 = 10
T1 = 50
T2 = 75
T4 = 100

ar = LinearStateSpace(A, C, G, mu_0=np.ones(4))
ymin, ymax = -0.8, 1.25

fig, ax = plt.subplots(figsize=(8, 5))

ax.grid(alpha=0.4)
ax.set_ylim(ymin, ymax)
ax.set_ylabel(r'$y_t$', fontsize=16)
ax.vlines((T0, T1, T2), -1.5, 1.5)

ax.set_xticks((T0, T1, T2))
ax.set_xticklabels((r"$T$", r"$T'$", r"$T''$"), fontsize=14)

sample = []
for i in range(80):
    rcolor = random.choice(('c', 'g', 'b'))
    x, y = ar.simulate(ts_length=T4)
github QuantEcon / QuantEcon.py / examples / paths_and_hist.py View on Github external
import matplotlib.pyplot as plt
from quantecon import LinearStateSpace
import random

phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5
sigma = 0.1

A = [[phi_1, phi_2, phi_3, phi_4],
     [1,     0,     0,     0],
     [0,     1,     0,     0],
     [0,     0,     1,     0]]
C = [[sigma], [0], [0], [0]]
G = [1, 0, 0, 0]

T = 30
ar = LinearStateSpace(A, C, G, mu_0=np.ones(4))

ymin, ymax = -0.8, 1.25

fig, axes = plt.subplots(1, 2, figsize=(8, 3))

for ax in axes:
    ax.grid(alpha=0.4)

ax = axes[0]

ax.set_ylim(ymin, ymax)
ax.set_ylabel(r'$y_t$', fontsize=16)
ax.vlines((T,), -1.5, 1.5)

ax.set_xticks((T,))
ax.set_xticklabels((r'$T$',))
github QuantEcon / QuantEcon.py / examples / tsh_hg.py View on Github external
import matplotlib.pyplot as plt
from scipy.stats import norm
from quantecon import LinearStateSpace

phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5
sigma = 0.1

A = [[phi_1, phi_2, phi_3, phi_4],
     [1,     0,     0,     0],
     [0,     1,     0,     0],
     [0,     0,     1,     0]]
C = [[sigma], [0], [0], [0]]
G = [1, 0, 0, 0]

T = 30
ar = LinearStateSpace(A, C, G)

ymin, ymax = -0.8, 1.25

fig, ax = plt.subplots(figsize=(8, 4))

ax.set_xlim(ymin, ymax)
ax.set_xlabel(r'$y_t$', fontsize=16)

x, y = ar.replicate(T=T, num_reps=100000)
mu_x, mu_y, Sigma_x, Sigma_y = ar.stationary_distributions()
f_y = norm(loc=float(mu_y), scale=float(np.sqrt(Sigma_y)))

y = y.flatten()
ax.hist(y, bins=50, normed=True, alpha=0.4)

ygrid = np.linspace(ymin, ymax, 150)
github QuantEcon / QuantEcon.lectures.code / linear_models / tsh_hg.py View on Github external
import matplotlib.pyplot as plt
from scipy.stats import norm
from quantecon import LinearStateSpace

phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5
sigma = 0.1

A = [[phi_1, phi_2, phi_3, phi_4],
     [1,     0,     0,     0],
     [0,     1,     0,     0],
     [0,     0,     1,     0]]
C = [[sigma], [0], [0], [0]]
G = [1, 0, 0, 0]

T = 30
ar = LinearStateSpace(A, C, G)

ymin, ymax = -0.8, 1.25

fig, ax = plt.subplots(figsize=(8, 4))

ax.set_xlim(ymin, ymax)
ax.set_xlabel(r'$y_t$', fontsize=16)

x, y = ar.replicate(T=T, num_reps=100000)
mu_x, mu_y, Sigma_x, Sigma_y = ar.stationary_distributions()
f_y = norm(loc=float(mu_y), scale=float(np.sqrt(Sigma_y)))

y = y.flatten()
ax.hist(y, bins=50, normed=True, alpha=0.4)

ygrid = np.linspace(ymin, ymax, 150)
github QuantEcon / QuantEcon.py / examples / paths_and_stationarity.py View on Github external
phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5
sigma = 0.1

A = [[phi_1, phi_2, phi_3, phi_4],
     [1,     0,     0,     0],
     [0,     1,     0,     0],
     [0,     0,     1,     0]]
C = [[sigma], [0], [0], [0]]
G = [1, 0, 0, 0]

T0 = 10
T1 = 50
T2 = 75
T4 = 100

ar = LinearStateSpace(A, C, G, mu_0=np.ones(4))
ymin, ymax = -0.8, 1.25

fig, ax = plt.subplots(figsize=(8, 5))

ax.grid(alpha=0.4)
ax.set_ylim(ymin, ymax)
ax.set_ylabel(r'$y_t$', fontsize=16)
ax.vlines((T0, T1, T2), -1.5, 1.5)

ax.set_xticks((T0, T1, T2))
ax.set_xticklabels((r"$T$", r"$T'$", r"$T''$"), fontsize=14)

sample = []
for i in range(80):
    rcolor = random.choice(('c', 'g', 'b'))
    x, y = ar.simulate(ts_length=T4)
github QuantEcon / QuantEcon.lectures.code / linear_models / paths_and_hist.py View on Github external
import matplotlib.pyplot as plt
from quantecon import LinearStateSpace
import random

phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5
sigma = 0.1

A = [[phi_1, phi_2, phi_3, phi_4],
     [1,     0,     0,     0],
     [0,     1,     0,     0],
     [0,     0,     1,     0]]
C = [[sigma], [0], [0], [0]]
G = [1, 0, 0, 0]

T = 30
ar = LinearStateSpace(A, C, G, mu_0=np.ones(4))

ymin, ymax = -0.8, 1.25

fig, axes = plt.subplots(1, 2, figsize=(8, 3))

for ax in axes:
    ax.grid(alpha=0.4)

ax = axes[0]

ax.set_ylim(ymin, ymax)
ax.set_ylabel(r'$y_t$', fontsize=16)
ax.vlines((T,), -1.5, 1.5)

ax.set_xticks((T,))
ax.set_xticklabels((r'$T$',))