在STATSOLS回归模型中是否有指定滞后自变量的方法?下面是一个示例数据帧和ols模型规范。我想在模型中加入一个滞后变量
df = pd.DataFrame({
"y": [2,3,7,8,1],
"x": [8,6,2,1,9],
"v": [4,3,1,3,8]
})
Current model:
model = sm.ols(formula = 'y ~ x + v', data=df).fit()
Desired model:
model_lag = sm.ols(formula = 'y ~ (x-1) + v', data=df).fit()
我不认为你可以在公式中称之为即时。也许使用shift方法?如果这不是您需要的,请务必澄清
这已经有了一个公认的答案,但再加上我的2美分:
一些示例代码:
相关问题 更多 >
编程相关推荐