python的ols回归,Python-滚动窗口OLS回归估计

本文展示了如何使用statsmodels库进行滚动窗口OLS回归分析。通过读取CSV数据,建立并应用滚动回归模型,预测下一个时间点的Y值,并计算均方误差(MSE)。代码中给出了详细的步骤,包括数据预处理、模型拟合、参数存储以及预测值的计算。
摘要由CSDN通过智能技术生成

For my evaluation, I have a dataset found in this link (https://drive.google.com/drive/folders/0B2Iv8dfU4fTUMVFyYTEtWXlzYkk) as in the following format. The third column (Y) in my dataset is my true value - that's what I wanted to predict (estimate).

time X Y

0.000543 0 10

0.000575 0 10

0.041324 1 10

0.041331 2 10

0.041336 3 10

0.04134 4 10

...

9.987735 55 239

9.987739 56 239

9.987744 57 239

9.987749 58 239

9.987938 59 239

I want to run a rolling of for example 5 window OLS regression estimation, and I have tried it with the following script.

# /usr/bin/python -tt

import numpy as np

import matplotlib.pyplot as plt

import pandas as pd

df = pd.read_csv('estimated_pred.csv')

model = pd.stats.ols.MovingOLS(y=d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值