时间序列分析之ARIMA——Java实现

通过ADF检验计算出p值,如果p值大于0.05,则说明数据不平稳,需要进行差分处理,差分后的数据,再次进行p值计算,如果不满足条件,则继续差分,最后得出总共进行了几次差分,差分次数即为ARIMA的参数d。
本文主要参考:
https://blog.csdn.net/u013201628/article/details/62236654
但是进行了修改,取消了季节性差分,而是转换为通过d值进行差分数据,然后进行预测的过程。

public double [] preDealDiff(int period)
{
    switch (period)
    {
        case 0:
            return this.originalData;
        case 1:
            this.dataFirDiff = this.preFirDiff(this.originalData);
            return this.dataFirDiff;
        case 2:
            this.dataFirDiff = this.preFirDiff(this.originalData);
            this.dataFirDiff = this.preFirDiff(this.dataFirDiff);
            return this.dataFirDiff;

        default:
            this.dataFirDiff = this.preFirDiff(this.originalData);
            this.dataFirDiff = this.preFirDiff(this.dataFirDiff);
            this.dataFirDiff = this.preFirDiff(this.dataFirDiff);
            return this.dataFirDiff;
    }
}
public int aftDeal(int predictValue, int period)
{

    switch (period) {
    case 0:
        return (int)predictValue;
    case 1:
        return (int)(predictValue + originalData[originalData.length - 1]);
    case 2:
        return (int)(predictValue + originalData[originalData.length - 1]  + preDealDiff(1)[preDealDiff(1).length -1]);
    default:
        return (int)(predictValue + originalData[originalData.length - 1] +  preDealDiff(2)[preDealDiff(2).length - 1]  + preDealDiff(1)[preDealDiff(1).length -1]);
    }
}

你可能感兴趣的:(进阶)