📜  滚动半衰期均值回归 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:12.451000             🧑  作者: Mango

代码示例1
z_lag = np.roll(z_array,1)
z_lag[0] = 0
z_ret = z_array - z_lag
z_ret[0] = 0

#adds intercept terms to X variable for regression
z_lag2 = sm.add_constant(z_lag)

model = sm.OLS(z_ret,z_lag2)
res = model.fit()

halflife = -log(2) / res.params[1]