@@ -148,16 +148,16 @@ def __init__(
148148 self .curve_monthly = curve_m
149149
150150 self .t_d = self .curve .shape [0 ]
151- self .t_m = self .curve_monthly .shape [0 ]
151+ self .t_m = self .curve_monthly .shape [0 ] - 1
152152 self .n = self .curve .shape [1 ]
153153 self .pc_factors_m , self .pc_factors_d , self .pc_loadings_m , self .pc_explained_m = self ._get_pcs (self .curve_monthly , self .curve )
154154
155155 self .rx_m = self ._get_excess_returns ()
156- # TODO EVERYTHING RIGHT UP TO HERE
157156
158157 # ===== ACM Three-Step Regression =====
159158 # 1st Step - Factor VAR
160159 self .mu , self .phi , self .Sigma , self .v , self .s0 = self ._estimate_var ()
160+ # TODO EVERYTHING RIGHT UP TO HERE
161161
162162 # 2nd Step - Excess Returns
163163 self .beta , self .omega , self .beta_star = self ._excess_return_regression ()
@@ -271,7 +271,7 @@ def _get_pcs(self, curve_m, curve_d):
271271 def _estimate_var (self ):
272272 X = self .pc_factors_m .copy ().T
273273 X_lhs = X .values [:, 1 :] # X_t+1. Left hand side of VAR
274- X_rhs = np .vstack ((np .ones ((1 , self .t )), X .values [:, 0 :- 1 ])) # X_t and a constant.
274+ X_rhs = np .vstack ((np .ones ((1 , self .t_m )), X .values [:, 0 :- 1 ])) # X_t and a constant.
275275
276276 var_coeffs = (X_lhs @ np .linalg .pinv (X_rhs ))
277277
@@ -286,7 +286,7 @@ def _estimate_var(self):
286286
287287 # Residuals
288288 v = X_lhs - var_coeffs @ X_rhs
289- Sigma = v @ v .T / (self .t - 1 )
289+ Sigma = v @ v .T / (self .t_m - 1 )
290290
291291 s0 = np .cov (v ).reshape ((- 1 , 1 ))
292292
0 commit comments