@@ -116,7 +116,7 @@ def __init__(
116116 curve ,
117117 curve_m = None , # TODO Documentation
118118 n_factors = 5 ,
119- selected_maturities = None ,
119+ selected_maturities = None , # TODO may select if you trust representativeness / liquidity
120120 ):
121121 """
122122 Runs the baseline varsion of the ACM term premium model. Works for data
@@ -157,10 +157,10 @@ def __init__(
157157 # ===== ACM Three-Step Regression =====
158158 # 1st Step - Factor VAR
159159 self .mu , self .phi , self .Sigma , self .v , self .s0 = self ._estimate_var ()
160- # TODO EVERYTHING RIGHT UP TO HERE
161160
162161 # 2nd Step - Excess Returns
163162 self .beta , self .omega , self .beta_star = self ._excess_return_regression ()
163+ # TODO EVERYTHING RIGHT UP TO HERE
164164
165165 # 3rd Step - Convexity-adjusted price of risk
166166 self .lambda0 , self .lambda1 , self .mu_star , self .phi_star = self ._retrieve_lambda ()
@@ -221,9 +221,10 @@ def _get_excess_returns(self):
221221 rf = - log_prices .iloc [:, 0 ].shift (1 )
222222 rx = (log_prices - log_prices .shift (1 , axis = 0 ).shift (- 1 , axis = 1 )).subtract (rf , axis = 0 )
223223 # rx = rx.shift(1, axis=1) # TODO is this needed?
224+ rx = rx .shift (1 , axis = 1 )
224225
225- rx = rx .dropna (how = 'all' , axis = 0 ). dropna ( how = 'all' , axis = 1 )
226- # rf = rf.dropna() # TODO Do I need to keep track of this?
226+ rx = rx .dropna (how = 'all' , axis = 0 )
227+ rx [ 1 ] = 0
227228 return rx
228229
229230 def _get_pcs (self , curve_m , curve_d ):
@@ -300,7 +301,7 @@ def _excess_return_regression(self):
300301 rx = self .rx_m .values
301302
302303 X = self .pc_factors_m .copy ().T .values [:, :- 1 ]
303- Z = np .vstack ((np .ones ((1 , self .t )), X , self .v )).T # Innovations and lagged X
304+ Z = np .vstack ((np .ones ((1 , self .t_m )), X , self .v )).T # Lagged X and Innovations
304305 abc = inv (Z .T @ Z ) @ (Z .T @ rx )
305306 E = rx - Z @ abc
306307 omega = np .var (E .reshape (- 1 , 1 )) * np .eye (len (self .selected_maturities ))
0 commit comments