Exemplo n.º 1
0
        /// <summary>
        /// Constructor for ArimaParams
        /// </summary>
        /// <param name="p"> ARIMA parameter, the order (number of time lags) of the autoregressive model </param>
        /// <param name="d"> ARIMA parameter, the degree of differencing </param>
        /// <param name="q"> ARIMA parameter, the order of the moving-average model </param>
        /// <param name="P"> ARIMA parameter, autoregressive term for the seasonal part </param>
        /// <param name="D"> ARIMA parameter, differencing term for the seasonal part </param>
        /// <param name="Q"> ARIMA parameter, moving average term for the seasonal part </param>
        /// <param name="m"> ARIMA parameter, the number of periods in each season </param>
        public ArimaParams(int p, int d, int q, int P, int D, int Q, int m)
        {
            this.p = p;
            this.d = d;
            this.q = q;
            this.P = P;
            this.D = D;
            this.Q = Q;
            this.m = m;

            // dependent states
            this._opAR = NewOperatorAR;
            this._opMA = NewOperatorMA;
            _opAR.initializeParams(false);
            _opMA.initializeParams(false);
            this._dp = _opAR.Degree;
            this._dq = _opMA.Degree;
            this._np = _opAR.numParams();
            this._nq = _opMA.numParams();
            //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
            //ORIGINAL LINE: this._init_seasonal = (D > 0 && m > 0) ? new double[D][m] : null;
            this._init_seasonal = (D > 0 && m > 0) ? RectangularArrays.ReturnRectangularDoubleArray(D, m) : null;
            //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
            //ORIGINAL LINE: this._init_non_seasonal = (d > 0) ? new double[d][1] : null;
            this._init_non_seasonal      = (d > 0) ? RectangularArrays.ReturnRectangularDoubleArray(d, 1) : null;
            this._diff_seasonal          = (D > 0 && m > 0) ? new double[D][] : null;
            this._diff_non_seasonal      = (d > 0) ? new double[d][] : null;
            this._integrate_seasonal     = (D > 0 && m > 0) ? new double[D][] : null;
            this._integrate_non_seasonal = (d > 0) ? new double[d][] : null;
        }
Exemplo n.º 2
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        //ORIGINAL LINE: private static double[] applyYuleWalkerAndGetInitialErrors(final double[] data, final int r, final int length, final double[] errors)
        private static double[] applyYuleWalkerAndGetInitialErrors(double[] data, int r, int length, double[] errors)
        {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final double[] yuleWalker = YuleWalker.fit(data, r);
            double[] yuleWalker = YuleWalker.fit(data, r);
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final TimeSeries.Forecast.TimeSeries.Arima.struct.BackShift bsYuleWalker = new TimeSeries.Forecast.TimeSeries.Arima.struct.BackShift(r, true);
            BackShift bsYuleWalker = new BackShift(r, true);

            bsYuleWalker.initializeParams(false);
            // return array from YuleWalker is an array of size r whose
            // 0-th index element is lag 1 coefficient etc
            // hence shifting lag index by one and copy over to BackShift operator
            for (int j = 0; j < r; ++j)
            {
                bsYuleWalker.setParam(j + 1, yuleWalker[j]);
            }
            int m = 0;

            // populate error array
            while (m < r)
            {
                errors[m++] = 0;
            } // initial r-elements are set to zero
            while (m < length)
            {
                // from then on, initial estimate of error terms are
                // Z_t = X_t - \phi_1 X_{t-1} - \cdots - \phi_r X_{t-r}
                errors[m] = data[m] - bsYuleWalker.getLinearCombinationFrom(data, m);
                ++m;
            }
            return(yuleWalker);
        }
Exemplo n.º 3
0
        private BackShift mergeSeasonalWithNonSeasonal(int nonSeasonalLag, int seasonalLag, int seasonalStep)
        {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final BackShift nonSeasonal = new BackShift(nonSeasonalLag, true);
            BackShift nonSeasonal = new BackShift(nonSeasonalLag, true);
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final BackShift seasonal = new BackShift(seasonalLag * seasonalStep, false);
            BackShift seasonal = new BackShift(seasonalLag * seasonalStep, false);

            for (int s = 1; s <= seasonalLag; ++s)
            {
                seasonal.setIndex(s * seasonalStep, true);
            }
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final BackShift merged = seasonal.apply(nonSeasonal);
            BackShift merged = seasonal.apply(nonSeasonal);

            return(merged);
        }