pandas MovingOLS不支持NA值吗? [英] pandas MovingOLS doesn't support NA values?

查看:93
本文介绍了 pandas MovingOLS不支持NA值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用版本0.7.3中的pandas.ols函数.我对进行移动回归很感兴趣,例如:

I am using the pandas.ols function from version 0.7.3. I am interested in doing a moving regression, such as:

model = pandas.ols(y = realizedData, x = pastData, intercept = 0, window_type="rolling", window = 80, min_periods = 80)

输入包含大约600个日期的数据,其中15个是NA值.但是输出仅包含约120个日期的回归结果.问题是,每当窗口包含一个NA值时,该窗口就没有输出.如果将window_type更改为expanding,并且按预期获得了约500个输出点,则问题消失了,但是我不想进行扩展的回归.

The inputs contain data for about 600 dates, of which 15 are NA values. But the output only contains regression results for about 120 dates. The issue is that whenever the window contains even one NA value, there is no output for that window. The problem disappears if I change window_type to expanding and I get about 500 output points as expected, but I don't want to do an expanding regression.

你能告诉我如何解决这个问题吗?

Can you tell me how to fix this?

推荐答案

尝试将min_periods设置为小于窗口大小(例如70).这意味着非NA期间的最小数量-只要窗口中有NA,结果将为NA.

Try setting min_periods to be less than the window size (like 70, say). That means the minimum number of non-NA periods-- whenever you have an NA in the window the result will be NA.

这篇关于 pandas MovingOLS不支持NA值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆