/// <summary>
        /// Prosedur untuk menghitung nilai pemulusan, prediksi, dan residual
        /// </summary>
        private void Smoothing()
        {
            //Menghitung pemulusan pertama
            sma1 = new SingleMovingAverage(this.y, this.t);

            Vector ma1 = new Vector(n);

            for (this.index = t - 1; this.index < n; ++this.index)
            {
                ma1[this.index] = this.sma1.Smoothed1[index];
            }

            //Menghitung pemulusan kedua
            sma2 = new SingleMovingAverage(ma1, this.t);

            Vector ma2 = new Vector(n);

            for (this.index = 2 * t - 2; this.index < n; ++this.index)
            {
                ma2[this.index] = this.sma2.Smoothed1[index];
                at[this.index]  = 2 * ma1[index] - ma2[index];
                bt[this.index]  = 2 * (ma1[index] - ma2[index]) / (this.t - 1);
            }

            for (this.index = 2 * t - 1; this.index < n; ++this.index)
            {
                this.predicted[this.index] = this.at[index - 1] + this.bt[index - 1];
                residual[this.index]       = y[index] - predicted[index];
            }

            //mengkonversi vector ke array double
            for (int i = 0; i < y.Tuples; i++)
            {
                this.smoothing1[i] = ma1[i];
                this.smoothing2[i] = ma2[i];
            }

            //inisialisasi nilai null
            for (int i = 0; i < this.t - 1; i++)
            {
                this.smoothing1[i] = double.NaN;
            }

            for (int i = 0; i < 2 * this.t - 2; i++)
            {
                this.smoothing2[i] = double.NaN;
            }

            for (int i = 0; i < 2 * this.t - 1; i++)
            {
                this.predicted[i] = double.NaN;
                this.residual[i]  = double.NaN;
            }
        }
Exemple #2
0
        /// <summary>
        /// Mengestimasi parameter
        /// </summary>
        private void EstimateParameters()
        {
            if (this.smaRadio.Checked == true)
            {
                //get Orde
                try { this.maProperties.orde = int.Parse(this.OrdeBox.Text); }
                catch { this.maProperties.orde = 2; }

                sma = new SingleMovingAverage(this.variable, this.maProperties.orde);

                this.maProperties.isSingleMA = true;

                this.maTable.singleSmoothed = sma.Smoothed1;
                this.maTable.predicted      = sma.Predicted;
                this.maTable.residual       = sma.Residual;

                this.maProperties.includedObservations = sma.IncludedObservations;
                this.maProperties.sseMA  = sma.SSE;
                this.maProperties.mseMA  = sma.MSE;
                this.maProperties.maeMA  = sma.MAE;
                this.maProperties.mpeMA  = sma.MPE;
                this.maProperties.mapeMA = sma.MAPE;
            }

            if (this.dmaRadio.Checked == true)
            {
                try { this.maProperties.orde = int.Parse(this.OrdeBox.Text); }
                catch { this.maProperties.orde = 2; }

                dma = new DoubleMovingAverage(this.variable, this.MaProperties.orde);

                this.maProperties.isSingleMA = false;

                this.maTable.singleSmoothed = dma.Smoothed1;
                this.maTable.doubleSmoothed = dma.Smoothed2;
                this.maTable.predicted      = dma.Predicted;
                this.maTable.residual       = dma.Residual;

                this.maProperties.includedObservations = dma.IncludedObservations;
                this.maProperties.sseMA  = dma.SSE;
                this.maProperties.mseMA  = dma.MSE;
                this.maProperties.maeMA  = dma.MAE;
                this.maProperties.mpeMA  = dma.MPE;
                this.maProperties.mapeMA = dma.MAPE;
            }
        }
        /// <summary>
        /// Mengestimasi parameter
        /// </summary>
        private void EstimateParameters()
        {
            if (this.smaRadio.Checked == true)
            {
                //get Orde
                try { this.maProperties.orde = int.Parse(this.OrdeBox.Text); }
                catch { this.maProperties.orde = 2; }

                sma = new SingleMovingAverage(this.variable, this.maProperties.orde);

                this.maProperties.isSingleMA = true;

                this.maTable.singleSmoothed = sma.Smoothed1;
                this.maTable.predicted = sma.Predicted;
                this.maTable.residual = sma.Residual;

                this.maProperties.includedObservations = sma.IncludedObservations;
                this.maProperties.sseMA = sma.SSE;
                this.maProperties.mseMA = sma.MSE;
                this.maProperties.maeMA = sma.MAE;
                this.maProperties.mpeMA = sma.MPE;
                this.maProperties.mapeMA = sma.MAPE;
            }

            if (this.dmaRadio.Checked == true)
            {
                try { this.maProperties.orde = int.Parse(this.OrdeBox.Text); }
                catch { this.maProperties.orde = 2; }

                dma = new DoubleMovingAverage(this.variable, this.MaProperties.orde);

                this.maProperties.isSingleMA = false;

                this.maTable.singleSmoothed = dma.Smoothed1;
                this.maTable.doubleSmoothed = dma.Smoothed2;
                this.maTable.predicted = dma.Predicted;
                this.maTable.residual = dma.Residual;

                this.maProperties.includedObservations = dma.IncludedObservations;
                this.maProperties.sseMA = dma.SSE;
                this.maProperties.mseMA = dma.MSE;
                this.maProperties.maeMA = dma.MAE;
                this.maProperties.mpeMA = dma.MPE;
                this.maProperties.mapeMA = dma.MAPE;
            }
        }
        /// <summary>
        /// Prosedur untuk menghitung nilai pemulusan, prediksi, dan residual
        /// </summary>
        private void Smoothing()
        {
            //Menghitung pemulusan pertama
            sma1 = new SingleMovingAverage(this.y, this.t);

            Vector ma1 = new Vector(n);
            for (this.index = t - 1; this.index < n; ++this.index)
                ma1[this.index] = this.sma1.Smoothed1[index];

            //Menghitung pemulusan kedua
            sma2 = new SingleMovingAverage(ma1, this.t);

            Vector ma2 = new Vector(n);
            for (this.index = 2 * t - 2; this.index < n; ++this.index)
            {
                ma2[this.index] = this.sma2.Smoothed1[index];
                at[this.index] = 2 * ma1[index] - ma2[index];
                bt[this.index] = 2 * (ma1[index] - ma2[index]) / (this.t - 1);
            }

            for (this.index = 2 * t - 1; this.index < n; ++this.index)
            {
                this.predicted[this.index] = this.at[index - 1] + this.bt[index - 1];
                residual[this.index] = y[index] - predicted[index];
            }

            //mengkonversi vector ke array double
            for (int i = 0; i < y.Tuples; i++)
            {
                this.smoothing1[i] = ma1[i];
                this.smoothing2[i] = ma2[i];
            }

            //inisialisasi nilai null
            for (int i = 0; i < this.t - 1; i++)
            {
                this.smoothing1[i] = double.NaN;
            }

            for (int i = 0; i < 2 * this.t - 2; i++)
            {
                this.smoothing2[i] = double.NaN;
            }

            for (int i = 0; i < 2 * this.t - 1; i++)
            {
                this.predicted[i] = double.NaN;
                this.residual[i] = double.NaN;
            }
        }