# This program shows the simulation results for the log-linearlized version of the basic RBC model
'''
the utility function is u(c_t, h_t) = log c_t + A log(1 - h_t),
the production function is f(k_t,h_t) = lamda_t k_t^theta h_t^(1-theta).
This version includes the programs to find the stationary states
and computes the matrices for the equilibrium law of motion
also, shows the graphs for the impulse response functions
and computes the variance ratio of the state variables to technology shock
'''
theta=.36; delta=.025; beta=.99; gamma=0.95
from numpy import *
import matplotlib.pyplot as plt
def varratio(ax,bw,cx,dw,roe,tol):
'''
compute the ratio of the variance of a jump variables to the variance of the shock.
The interation limit is 1000.
The dynamical system:x_(t+1)=a x_t + b w_t, y_t = c x_t + d w_t,
shock is w_(t+1)=roe w_t + epsilon_t
function name: varratio(a,b,c,d,roe,tol)
'''
vr=0
for i in range(1000):
shortsum=0
if i == 1:
shortsum=1
else:
for j in range(i+1):
shortsum=shortsum+ax**(j-1)*roe**(i+1-j)
increment=cx*bw*shortsum+dw*roe**i
vr=vr+increment*increment
if abs(increment)