Add Fake News Algorithm for Zeroth Column
@@ -2914,7 +2914,7 @@ class IndShockConsumerType(PerfForesightConsumerType):
# First expectation vector is the steady state policy
exp_vec_a = a_ss
exp_vec_c = c_ss
- for i in range(T - 1):
+ for i in range(T ):
exp_vecs_a.append(exp_vec_a)
exp_vec_a = np.dot(tranmat_ss.T, exp_vec_a)
@@ -2958,35 +2958,35 @@ class IndShockConsumerType(PerfForesightConsumerType):
J_A[t][s] = J_A[t - 1][s - 1] + Curl_F_A[t][s]
J_C[t][s] = J_C[t - 1][s - 1] + Curl_F_C[t][s]
- # Compute zeroth column of jacobian
- # List of transition matrices where the first transition matrix inherits the shock
- shock0_TM = [tranmat_t[params["T_cycle"] - 1]] + (T - 1) * [self.tran_matrix]
- C_list = [] # Aggrgate Consumption Values
- A_list = [] # Aggregate Asset values
+ #Zeroth Column of the Jacobian
+ dD_0_0 = np.dot(tranmat_t[-2] - tranmat_ss, D_ss)
+
+ D_curl_0_0 = dD_0_0/dx
+
+ c_first_col_without_0_0 = []
+ a_first_col_without_0_0 = []
+
+ for i in range(params['T_cycle'] ):
+
+ c_first_col_without_0_0.append(np.dot(exp_vec_c[i],D_curl_0_0))
+ a_first_col_without_0_0.append(np.dot(exp_vec_a[i],D_curl_0_0))
- A_ss = np.dot(self.a_ss, self.vec_erg_dstn)[0] # Steady State Assets
- C_ss = np.dot(self.c_ss, self.vec_erg_dstn)[0] # Steady State Consumption
- dstn = self.vec_erg_dstn
- for i in range(T): # Period in which we are computing Aggregate Consumption
+ c_first_col_without_0_0 = np.array(c_first_col_without_0_0)
+ a_first_col_without_0_0 = np.array(a_first_col_without_0_0)
- dstn = np.dot(shock0_TM[i], dstn) # Update Distribution
- C_agg_0 = np.dot(self.c_ss, dstn)[0] # Aggregate Consumption
- C_list.append(C_agg_0)
+ c_first_col_0 = np.zeros(T)
+ a_first_col_0 = np.zeros(T)
- A_agg_0 = np.dot(self.a_ss, dstn)[0] # Aggregate Assets
- A_list.append(A_agg_0)
- A_list = np.array(A_list)
- C_list = np.array(C_list)
+ c_first_col_0 = c_first_col_without_0_0
+ a_first_col_0 = a_first_col_without_0_0
- AJAC = (A_list - A_ss) / dx # Compute Impulse Response of Assets
- CJAC = (C_list - C_ss) / dx # Compute Impulse Response of Consumption
+ #Fill zeroth column of jacobian matrix
+ J_A.T[0] = a_first_col_0
+ J_C.T[0] = c_first_col_0
- # Fill first column of jacobians with computed impulse response
- J_C.T[0] = CJAC
- J_A.T[0] = AJAC
return J_C, J_A
