statsmodels.tsa.stattools.acf中的'missing'参数在统计上是做什么的?

问题描述 投票:0回答:1

我正在使用acf函数来计算statsmodels.tsa.stattools.acf提供的自相关。其中一个参数称为missing,并且可以采用值“ none”,“ raise”,“ conservative”和“ drop”,这些值更改了函数处理NaN值的方式。问题是,我找不到关于[[how的任何记录,正是这些值中的每一个都改变了正在执行的统计信息。

我正在使用均匀间隔的时间序列,该序列具有缺失值的散布和中间缺少测量值的较大间隙。到目前为止,我的解决方案是从时间序列中减去中位数,将其居中于零附近,然后在所有缺失值中插入0。这些参数值之一是否做类似的事情,我应该以不同的方式处理事情吗?
python statsmodels autocorrelation
1个回答
0
投票
'none'对NAN不执行任何操作,如果数据包含NAN,'raise'会引发错误。

MissingDataError("NaNs were encountered in the data")

'drop'会在进行计算之前从代码中删除NAN,据我所了解的源代码(https://www.statsmodels.org/stable/_modules/statsmodels/tsa/stattools.html),选项'保守'将所有NAN替换为0。

missing = missing.lower() if missing not in ['none', 'raise', 'conservative', 'drop']: raise ValueError("missing option %s not understood" % missing) if missing == 'none': deal_with_masked = False else: deal_with_masked = has_missing(x) if deal_with_masked: if missing == 'raise': raise MissingDataError("NaNs were encountered in the data") notmask_bool = ~np.isnan(x) # bool if missing == 'conservative': # Must copy for thread safety x = x.copy() x[~notmask_bool] = 0 else: # 'drop' x = x[notmask_bool] # copies non-missing notmask_int = notmask_bool.astype(int) # int

© www.soinside.com 2019 - 2024. All rights reserved.