python - 用 Python : x12a and x13as not found on path 进行 ARIMA 季节性预测

标签 python statsmodels

我正在使用 Statsmodels 来实现时间序列的季节性 ARIMA 预测。这是我的代码:

import statsmodels.api  as sm
from statsmodels.tsa.x13 import x13_arima_select_order, _find_x12
import pandas
import scipy
import numpy
import imp
data_source = imp.load_source('data_source', '/mypath/')
def main():
    data=data_source.getdata()
    res = x13_arima_select_order(data)
    print (res.order, res.sorder)

main()

运行代码时,我得到这个异常:

X13NotFoundError("x12a 和 x13as 未在路径中找到。给出 " statsmodels.tools.sm_exceptions.X13NotFoundError:在路径上找不到 x12a 和 x13as。给出路径,将它们放在 PATH 上,或者设置 X12PATH 或 X13PATH 环境变量。

最佳答案

从查看 source code for statsmodels.tsa.x13您需要在系统上安装 x12ax13as 二进制应用程序。 除此之外,必须在用户的 PATH 环境变量中设置这些二进制文件所在文件夹的路径。 你没有提到你运行的是什么操作系统,所以这里有一个页面,在左侧有一个指向操作系统特定下载页面的链接,可以帮助你安装所需的软件。 https://www.census.gov/srd/www/x13as/

这是我引用的来源链接,用于找出您的环境中缺少的内容: http://statsmodels.sourceforge.net/devel/_modules/statsmodels/tsa/x13.html

def x13_arima_analysis(endog, maxorder=(2, 1), maxdiff=(2, 1), diff=None,
                       exog=None, log=None, outlier=True, trading=False,
                       forecast_years=None, retspec=False,
                       speconly=False, start=None, freq=None,
                       print_stdout=False, x12path=None, prefer_x13=True):
...
    x12path = _check_x12(x12path)

    if not isinstance(endog, (pd.DataFrame, pd.Series)):
        if start is None or freq is None:
            raise ValueError("start and freq cannot be none if endog is not "
                             "a pandas object")
        endog = pd.Series(endog, index=pd.DatetimeIndex(start=start,
                                                        periods=len(endog),
                                                        freq=freq))

...

def _check_x12(x12path=None):
    x12path = _find_x12(x12path)
    if not x12path:
        raise X13NotFoundError("x12a and x13as not found on path. Give the "
                               "path, put them on PATH, or set the "
                               "X12PATH or X13PATH environmental variable.")
    return x12path

...

def _find_x12(x12path=None, prefer_x13=True):
    """
    If x12path is not given, then either x13as[.exe] or x12a[.exe] must
    be found on the PATH. Otherwise, the environmental variable X12PATH or
    X13PATH must be defined. If prefer_x13 is True, only X13PATH is searched
    for. If it is false, only X12PATH is searched for.
    """ 

关于python - 用 Python : x12a and x13as not found on path 进行 ARIMA 季节性预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32053770/

相关文章:

python - 在 SymPy 中创建和使用精确微分

python - ARIMA 模型 : plot_diagnostics, 我们模型的残差是什么意思

python - statsmodels tsa AR 和 ARMA 模型中的频率参数选项

python - 如何使用Python dict获得类(class)前10名的学生

python - Pandas dataframe 使用 pd.concat 将字符串替换为 NaN

python - 在Python中调用带有额外括号的对象

linear-regression - 在 Python 中比较线性模型的对比(比如 Rs 对比库?)

python - NumPy C API 扩展导致内存使用过多

python - 使用 statsmodels 进行时间序列分析

python - 金字塔和统计模型 fit() 和 ARIMA() 之间的区别?