创建OLS Beta参数估计值的滚动平均值
我正在尝试创建一个从单个数据集的OLS Beta参数估算的滚动平均值的时间序列图。我需要用OLS回归数据的第1-36行,找到Beta参数估计,然后以2-37行再次进行此操作,依此类推。完成此操作后,我需要在图中绘制这些点。我找不到一种自动化此过程的方法,以找到每个数据小节的OLS Beta估计值。有人有想法吗?
谢谢!
I am trying to create a time series graph of the rolling average of the OLS Beta parameter estimates from a single data set. I need to regress rows 1-36 of the data with OLS, find the Beta parameter estimate, and then do so again with rows 2-37, and so on. Once that is done, I need to plot these points in a graph. I can't find a way to automate this process of finding the OLS Beta estimates for each subsection of data. Does anyone have any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个快速的例子,但是我可以澄清一下您是否看到了您的数据示例?
假设您有一个1000行帧
df
,带有结果y
和predivorx
,并且您希望在每个36行滑动窗口(行1-36、2-37、3-38等)。首先,运行964个回归模型并保存系数。将它们添加到数据中。表
输出:
输入:
Here is a quick example, but I could perhaps clarify if I saw an example of your data?
Let's say you have a 1000 row frame
df
, with outcomey
and predictorx
, and you want the intercept and slope of a regression done in every 36-row sliding window (rows 1-36, 2-37, 3-38, etc). First, run the 964 regression models and save the coefficients.Add them to the data.table
Output:
Input: