Python 什么是';缺失';统计上讲,参数在statsmodels.tsa.stattools.acf中的作用?
我正在使用acf函数计算statsmodels.tsa.stattools.acf提供的自相关。其中一个参数被称为missing,可以采用值“none”、“raise”、“conservative”和“drop”,这会更改函数处理NaN值的方式。问题是,我找不到任何关于这些值中的每一个到底是如何改变正在进行的统计的文档Python 什么是';缺失';统计上讲,参数在statsmodels.tsa.stattools.acf中的作用?,python,statsmodels,autocorrelation,Python,Statsmodels,Autocorrelation,我正在使用acf函数计算statsmodels.tsa.stattools.acf提供的自相关。其中一个参数被称为missing,可以采用值“none”、“raise”、“conservative”和“drop”,这会更改函数处理NaN值的方式。问题是,我找不到任何关于这些值中的每一个到底是如何改变正在进行的统计的文档 我使用一个均匀间隔的时间序列,它有丢失的值的散射和中间缺失的大的测量间隙。到目前为止,我的解决方案是从时间序列中减去中值,使其以零为中心,然后在所有缺失的值中插入0。这些参数值中
我使用一个均匀间隔的时间序列,它有丢失的值的散射和中间缺失的大的测量间隙。到目前为止,我的解决方案是从时间序列中减去中值,使其以零为中心,然后在所有缺失的值中插入0。这些参数值中有一个做了类似的事情吗?我应该以不同的方式处理吗?
'none'对NAN没有任何作用,如果数据包含NAN,“raise”会引发错误MissingDataError("NaNs were encountered in the data")
“drop”在继续计算之前从代码中删除NAN,据我对源代码()的理解,“conservative”选项将所有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
请更新您尝试过的内容谢谢!这似乎与我在手动删除NAN或将其替换为零时看到的情况一致。