Ejemplo n.º 1
0
        public void ExponentialSmoothing()
        {
            SelectAnalyzedVariable dlg = new SelectAnalyzedVariable(this.data.SeriesVariables);
            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                ExponentialSmoothingForm esForm = new ExponentialSmoothingForm();
                esForm.SetVariable(dlg.SelectedVariable);
                esForm.ShowDialog();
                if (esForm.DialogResult == DialogResult.Yes)
                {

                    if (esForm.IsStoreSmoothed)
                    {
                        SeriesVariable var = new SeriesVariable(esForm.SmoothedName, "Smoothed Value of exponential smoothing of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - esForm.EsTable.predicted.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < esForm.EsTable.smoothed.Length; i++) var[i + lag] = esForm.EsTable.smoothed[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }

                    if (esForm.IsStorePredicted)
                    {
                        SeriesVariable var = new SeriesVariable(esForm.PredictedName, "Predicted Value of exponential smoothing of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - esForm.EsTable.predicted.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < esForm.EsTable.predicted.Length; i++) var[i + lag] = esForm.EsTable.predicted[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }

                    if (esForm.IsStoreResidual)
                    {
                        SeriesVariable var = new SeriesVariable(esForm.ResidualName, "Residual Value of exponential smoothing of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - esForm.EsTable.residual.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < esForm.EsTable.residual.Length; i++) var[i + lag] = esForm.EsTable.residual[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }

                    ESResultTabPage esTabPage = new ESResultTabPage();

                    if (esForm.EsProperties.initialModel == 1)
                        esTabPage.Title = "Single ES : '" + dlg.SelectedVariable.VariableName + "'";
                    if (esForm.EsProperties.initialModel == 2)
                        esTabPage.Title = "Double ES (Brown) : '" + dlg.SelectedVariable.VariableName + "'";
                    if (esForm.EsProperties.initialModel == 3)
                        esTabPage.Title = "Double ES (Holt) : '" + dlg.SelectedVariable.VariableName + "'";
                    if (esForm.EsProperties.initialModel == 4)
                        esTabPage.Title = "Triple ES (Winter) : '" + dlg.SelectedVariable.VariableName + "'";

                    if (esForm.IsForecastedDataGridChecked)
                    {
                        if (esForm.EsProperties.initialModel == 1)
                        {
                            esTabPage.SetData(this.data, dlg.SelectedVariable, esForm.EsProperties,
                                esForm.EsTable, esForm.SesForecast(esForm.ForecastingStep));
                        }
                        if (esForm.EsProperties.initialModel == 2)
                        {
                            esTabPage.SetData(this.data, dlg.SelectedVariable, esForm.EsProperties,
                                esForm.EsTable, esForm.BrownForecast(esForm.ForecastingStep));
                        }
                        if (esForm.EsProperties.initialModel == 3)
                        {
                            esTabPage.SetData(this.data, dlg.SelectedVariable, esForm.EsProperties,
                                esForm.EsTable, esForm.HoltForecast(esForm.ForecastingStep));
                        }
                        if (esForm.EsProperties.initialModel == 4)
                        {
                            esTabPage.SetData(this.data, dlg.SelectedVariable, esForm.EsProperties,
                                esForm.EsTable, esForm.WinterForecast(esForm.ForecastingStep));
                        }
                    }

                    else
                    {
                        esTabPage.SetData(this.data, dlg.SelectedVariable, esForm.EsProperties,
                            esForm.EsTable, null);
                    }
                    esTabPage.IsEsModelSummaryVisible = esForm.IsEsModelSummaryChecked;

                    esTabPage.IsExponentialSmoothingDataGridVisible = esForm.IsExponentialSmoothingDataGridChecked;
                    esTabPage.IsSmoothingVisible = esForm.IsSmoothingChecked;
                    esTabPage.IsTrendVisible = esForm.IsTrendChecked;
                    esTabPage.IsSeasonalVisible = esForm.IsSeasonalChecked;
                    esTabPage.IsForecastedDataGridVisible = esForm.IsForecastedDataGridChecked;
                    esTabPage.IsActualAndPredictedGraphVisible = esForm.IsActualAndPredictedGraphChecked;
                    esTabPage.IsActualAndSmoothedGraphVisible = esForm.IsActualAndSmoothedGraphChecked;
                    esTabPage.IsActualAndForecastedGraphVisible = esForm.IsActualAndForecastedGraphChecked;
                    esTabPage.IsActualVsPredictedGraphVisible = esForm.IsActualVsPredictedGraphChecked;
                    esTabPage.IsResidualGraphVisible = esForm.IsResidualGraphChecked;
                    esTabPage.IsResidualVsActualGraphVisible = esForm.IsResidualVsActualGraphChecked;
                    esTabPage.IsResidualVsPredictedGraphVisible = esForm.IsResidualVsPredictedGraphChecked;

                    esTabPage.DrawControl();

                    esTabPage.IsDrawn = true;
                    this.tabControlResult.AddTab(esTabPage);
                    this.tabControlResult.SelectedItem = esTabPage;

                    this.tabControlData.SelectedTab = this.tabPageResult;

                }
            }
        }
Ejemplo n.º 2
0
        public void MovingAverage()
        {
            SelectAnalyzedVariable dlg = new SelectAnalyzedVariable(this.data.SeriesVariables);
            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                MovingAverageForm maForm = new MovingAverageForm();
                maForm.SetVariable(dlg.SelectedVariable);
                maForm.ShowDialog();
                if (maForm.DialogResult == DialogResult.Yes)
                {

                    if (maForm.MaProperties.isSingleMA)
                    {
                        if (maForm.IsStoreSmoothed)
                        {
                            SeriesVariable var = new SeriesVariable(maForm.SmoothedName, "Smoothed Value of MA(" + maForm.MaProperties.orde +
                                ") analysis of variable '" + dlg.SelectedVariable.VariableName + "'");
                            int lag = dlg.SelectedVariable.SeriesValues.Count - maForm.MaProperties.includedObservations;
                            var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                            for (int i = 0; i < lag; i++) var[i] = double.NaN;
                            for (int i = lag; i < lag + maForm.MaProperties.orde; i++) var[i] = double.NaN;
                            for (int i = lag + maForm.MaProperties.orde; i < maForm.MaProperties.includedObservations + lag; i++) var[i] = maForm.MaTable.singleSmoothed[i - lag];
                            this.data.SeriesVariables.Add(var);
                            this.seriesDataList.Refresh();
                        }

                        if (maForm.IsStorePredicted)
                        {
                            SeriesVariable var = new SeriesVariable(maForm.PredictedName, "Predicted Value of MA(" + maForm.MaProperties.orde +
                                ") analysis of variable '" + dlg.SelectedVariable.VariableName + "'");
                            int lag = dlg.SelectedVariable.SeriesValues.Count - maForm.MaProperties.includedObservations;
                            var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                            for (int i = 0; i < lag; i++) var[i] = double.NaN;
                            for (int i = lag; i < lag + maForm.MaProperties.orde; i++) var[i] = double.NaN;
                            for (int i = lag + maForm.MaProperties.orde; i < maForm.MaProperties.includedObservations + lag; i++) var[i] = maForm.MaTable.predicted[i - lag];
                            this.data.SeriesVariables.Add(var);
                            this.seriesDataList.Refresh();
                        }

                        if (maForm.IsStoreResidual)
                        {
                            SeriesVariable var = new SeriesVariable(maForm.ResidualName, "Residual Value of MA(" + maForm.MaProperties.orde +
                                ") analysis of variable '" + dlg.SelectedVariable.VariableName + "'");
                            int lag = dlg.SelectedVariable.SeriesValues.Count - maForm.MaProperties.includedObservations;
                            var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                            for (int i = 0; i < lag; i++) var[i] = double.NaN;
                            for (int i = lag; i < lag + maForm.MaProperties.orde; i++) var[i] = double.NaN;
                            for (int i = lag + maForm.MaProperties.orde; i < maForm.MaProperties.includedObservations + lag; i++) var[i] = maForm.MaTable.residual[i - lag];
                            this.data.SeriesVariables.Add(var);
                            this.seriesDataList.Refresh();
                        }
                    }
                    else
                    {
                        if (maForm.IsStoreSmoothed)
                        {
                            SeriesVariable var = new SeriesVariable(maForm.SmoothedName, "Smoothed Value of MA(" + maForm.MaProperties.orde +
                                "X" + maForm.MaProperties.orde + ") analysis of variable '" + dlg.SelectedVariable.VariableName + "'");
                            int lag = dlg.SelectedVariable.SeriesValues.Count - maForm.MaProperties.includedObservations;
                            var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                            for (int i = 0; i < lag; i++) var[i] = double.NaN;
                            for (int i = lag; i < lag + (2 * (maForm.MaProperties.orde - 1)); i++) var[i] = double.NaN;
                            for (int i = lag + (2 * (maForm.MaProperties.orde - 1)); i < maForm.MaProperties.includedObservations + lag; i++) var[i] = maForm.MaTable.doubleSmoothed[i - lag];
                            this.data.SeriesVariables.Add(var);
                            this.seriesDataList.Refresh();
                        }
                        if (maForm.IsStorePredicted)
                        {
                            SeriesVariable var = new SeriesVariable(maForm.PredictedName, "Predicted Value of MA(" + maForm.MaProperties.orde +
                                "X" + maForm.MaProperties.orde + ") analysis of variable '" + dlg.SelectedVariable.VariableName + "'");
                            int lag = dlg.SelectedVariable.SeriesValues.Count - maForm.MaProperties.includedObservations;
                            var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                            for (int i = 0; i < lag; i++) var[i] = double.NaN;
                            for (int i = lag; i < lag + (2 * (maForm.MaProperties.orde - 1)); i++) var[i] = double.NaN;
                            for (int i = lag + (2 * (maForm.MaProperties.orde - 1)); i < maForm.MaProperties.includedObservations + lag; i++) var[i] = maForm.MaTable.predicted[i - lag];
                            this.data.SeriesVariables.Add(var);
                            this.seriesDataList.Refresh();
                        }
                        if (maForm.IsStoreResidual)
                        {
                            SeriesVariable var = new SeriesVariable(maForm.ResidualName, "Residual Value of MA(" + maForm.MaProperties.orde +
                                "," + maForm.MaProperties.orde + ") analysis of variable '" + dlg.SelectedVariable.VariableName + "'");
                            int lag = dlg.SelectedVariable.SeriesValues.Count - maForm.MaProperties.includedObservations;
                            var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                            for (int i = 0; i < lag; i++) var[i] = double.NaN;
                            for (int i = lag; i < lag + (2 * (maForm.MaProperties.orde - 1)); i++) var[i] = double.NaN;
                            for (int i = lag + (2 * (maForm.MaProperties.orde - 1)); i < maForm.MaProperties.includedObservations + lag; i++) var[i] = maForm.MaTable.residual[i - lag];
                            this.data.SeriesVariables.Add(var);
                            this.seriesDataList.Refresh();
                        }
                    }

                    MAResultTabPage maTabPage = new MAResultTabPage();

                    maTabPage.Title = "Moving Average : '" + dlg.SelectedVariable.VariableName + "'";

                    if (maForm.IsForecastedDataGridChecked)
                    {
                        if (maForm.MaProperties.isSingleMA)
                        {
                            maTabPage.SetData(this.data, dlg.SelectedVariable, maForm.MaProperties,
                                maForm.MaTable, maForm.SmaForecast(maForm.ForecastingStep));
                        }
                        else
                        {
                            maTabPage.SetData(this.data, dlg.SelectedVariable, maForm.MaProperties,
                                maForm.MaTable, maForm.DmaForecast(maForm.ForecastingStep));
                        }
                    }
                    else
                    {
                        maTabPage.SetData(this.data, dlg.SelectedVariable, maForm.MaProperties,
                            maForm.MaTable, null);
                    }
                    maTabPage.IsMaModelSummaryVisible = maForm.IsMaModelSummaryChecked;
                    maTabPage.IsSmoothingVisible = maForm.IsSmoothingChecked;
                    maTabPage.IsMovingAverageDataGridVisible = maForm.IsMovingAverageDataGridChecked;
                    maTabPage.IsForecastedDataGridVisible = maForm.IsForecastedDataGridChecked;
                    maTabPage.IsActualAndPredictedGraphVisible = maForm.IsActualAndPredictedGraphChecked;
                    maTabPage.IsActualAndPredictedGraphVisible = maForm.IsActualAndPredictedGraphChecked;
                    maTabPage.IsActualAndSmoothedGraphVisible = maForm.IsActualAndSmoothedGraphChecked;
                    maTabPage.IsActualAndForecastedGraphVisible = maForm.IsActualAndForecastedGraphChecked;
                    maTabPage.IsActualVsPredictedGraphVisible = maForm.IsActualVsPredictedGraphChecked;
                    maTabPage.IsResidualGraphVisible = maForm.IsResidualGraphChecked;
                    maTabPage.IsResidualVsActualGraphVisible = maForm.IsResidualVsActualGraphChecked;
                    maTabPage.IsResidualVsPredictedGraphVisible = maForm.IsResidualVsPredictedGraphChecked;

                    maTabPage.DrawControl();

                    maTabPage.IsDrawn = true;
                    this.tabControlResult.AddTab(maTabPage);
                    this.tabControlResult.SelectedItem = maTabPage;

                    this.tabControlData.SelectedTab = this.tabPageResult;

                }
            }
        }
Ejemplo n.º 3
0
        public void Decomposition()
        {
            SelectAnalyzedVariable dlg = new SelectAnalyzedVariable(this.data.SeriesVariables);
            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                DecompositionForm decForm = new DecompositionForm();
                decForm.SetVariable(dlg.SelectedVariable);
                decForm.ShowDialog();
                if (decForm.DialogResult == DialogResult.Yes)
                {

                    if (decForm.IsStoreTrend)
                    {
                        SeriesVariable var = new SeriesVariable(decForm.TrendName, "Trend Value of Decomposition Classic analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - decForm.DecTable.trend.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < decForm.DecTable.trend.Length; i++) var[i + lag] = decForm.DecTable.trend[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }
                    if (decForm.IsStoreDetrend)
                    {
                        SeriesVariable var = new SeriesVariable(decForm.DetrendName, "Detrended Value of Decomposition Classic analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - decForm.DecTable.detrend.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < decForm.DecTable.detrend.Length; i++) var[i + lag] = decForm.DecTable.detrend[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }
                    if (decForm.IsStoreDeseasonal)
                    {
                        SeriesVariable var = new SeriesVariable(decForm.DeseasonalName, "Seasonally Adj. Value of Decomposition Classic analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - decForm.DecTable.deseasonal.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < decForm.DecTable.deseasonal.Length; i++) var[i + lag] = decForm.DecTable.deseasonal[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }

                    if (decForm.IsStorePredicted)
                    {
                        SeriesVariable var = new SeriesVariable(decForm.PredictedName, "Predicted Value of Decomposition Classic analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - decForm.DecTable.predicted.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < decForm.DecTable.predicted.Length; i++) var[i + lag] = decForm.DecTable.predicted[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }

                    if (decForm.IsStoreResidual)
                    {
                        SeriesVariable var = new SeriesVariable(decForm.ResidualName, "Residual Value of Decomposition Classic analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - decForm.DecTable.residual.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < decForm.DecTable.residual.Length; i++) var[i + lag] = decForm.DecTable.residual[i];
                        this.data.SeriesVariables.Add(var);
                        this.seriesDataList.Refresh();
                    }

                    DECResultTabPage decTabPage = new DECResultTabPage();

                    decTabPage.Title = "Decomposition : '" + dlg.SelectedVariable.VariableName + "'";

                    if (decForm.IsForecastedDataGridChecked)
                    {
                        decTabPage.SetData(this.data, dlg.SelectedVariable, decForm.DecProperties,
                            decForm.DecTable, decForm.Forecast(decForm.ForecastingStep));
                    }
                    else
                    {
                        decTabPage.SetData(this.data, dlg.SelectedVariable, decForm.DecProperties,
                            decForm.DecTable, null);
                    }
                    decTabPage.IsDecModelSummaryVisible = decForm.IsDecModelSummaryChecked;

                    decTabPage.IsDecompositionDataGridVisible = decForm.IsDecompositionDataGridChecked;
                    decTabPage.IsTrendVisible = decForm.IsTrendChecked;
                    decTabPage.IsDetrendVisible = decForm.IsDetrendChecked;
                    decTabPage.IsSeasonalVisible = decForm.IsSeasonalChecked;
                    decTabPage.IsDeseasonalVisible = decForm.IsDeseasonalChecked;
                    decTabPage.IsForecastedDataGridVisible = decForm.IsForecastedDataGridChecked;
                    decTabPage.IsActualPredictedAndTrendGraphVisible = decForm.IsActualPredictedAndTrendGraphChecked;
                    decTabPage.IsActualAndForecastedGraphVisible = decForm.IsActualAndForecastedGraphChecked;
                    decTabPage.IsActualVsPredictedGraphVisible = decForm.IsActualVsPredictedGraphChecked;
                    decTabPage.IsResidualGraphVisible = decForm.IsResidualGraphChecked;
                    decTabPage.IsResidualVsActualGraphVisible = decForm.IsResidualVsActualGraphChecked;
                    decTabPage.IsResidualVsPredictedGraphVisible = decForm.IsResidualVsPredictedGraphChecked;
                    decTabPage.IsDetrendGraphVisible = decForm.IsDetrendGraphChecked;
                    decTabPage.IsDeseasonalGraphVisible = decForm.IsDeseasonalGraphChecked;

                    decTabPage.DrawControl();

                    decTabPage.IsDrawn = true;
                    this.tabControlResult.AddTab(decTabPage);
                    this.tabControlResult.SelectedItem = decTabPage;

                    this.tabControlData.SelectedTab = this.tabPageResult;

                }
            }
        }
Ejemplo n.º 4
0
 private void cmdAddVariable_Click(object sender, EventArgs e)
 {
     SeriesVariables var = this.data.SeriesVariables;
     zaitun.GUI.CreateSeriesVariable ser = new zaitun.GUI.CreateSeriesVariable();
     ser.ShowDialog();
     if (ser.DialogResult == DialogResult.OK)
     {
         try
         {
             SeriesVariable tmp = new SeriesVariable(ser.VariableName, ser.VariableDescription);
             tmp.InitializeItem(this.data.NumberObservations);
             var.Add(tmp);
             this.seriesDataList.Refresh();
         }
         catch (DuplicateVariableException)
         {
             MessageBox.Show("Variable '" + ser.VariableName + "' already exist", "Duplicate Variable Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Ejemplo n.º 5
0
        public void TrendAnalysis()
        {
            SelectAnalyzedVariable dlg = new SelectAnalyzedVariable(this.data.SeriesVariables);
            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                TrendAnalysisForm trendForm = new TrendAnalysisForm();
                trendForm.SetVariable(dlg.SelectedVariable);
                trendForm.ShowDialog();
                if (trendForm.DialogResult == DialogResult.OK)
                {

                    if (trendForm.IsStorePredicted)
                    {
                        SeriesVariable var = new SeriesVariable(trendForm.PredictedName, "Predicted Value of trend analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - trendForm.Predicted.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < trendForm.Predicted.Length; i++) var[i + lag] = trendForm.Predicted[i];
                        try
                        {
                            this.data.SeriesVariables.Add(var);
                        }
                        catch (DuplicateVariableException)
                        {
                            MessageBox.Show("Variable '" + var.VariableName + "' already exist", "Duplicate Variable Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        this.seriesDataList.Refresh();
                    }

                    if (trendForm.IsStoreResidual)
                    {
                        SeriesVariable var = new SeriesVariable(trendForm.ResidualName, "Residual Value of trend analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - trendForm.Residual.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < trendForm.Residual.Length; i++) var[i + lag] = trendForm.Residual[i];
                        try
                        {
                            this.data.SeriesVariables.Add(var);
                        }
                        catch (DuplicateVariableException)
                        {
                            MessageBox.Show("Variable '" + var.VariableName + "' already exist", "Duplicate Variable Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        this.seriesDataList.Refresh();
                    }

                    TrendAnalysisResultTabPage trendTabPage = new TrendAnalysisResultTabPage();

                    trendTabPage.Title = "Trend Analysis : '" + dlg.SelectedVariable.VariableName + "'";

                    if (trendForm.IsForecastedDataGridChecked)
                    {
                        trendTabPage.SetData(this.data, dlg.SelectedVariable, trendForm.TrendProperties, trendForm.Predicted,
                            trendForm.Forecast(trendForm.ForecastingStep), trendForm.Residual);
                    }
                    else
                    {
                        trendTabPage.SetData(this.data, dlg.SelectedVariable, trendForm.TrendProperties,
                            trendForm.Predicted, null, trendForm.Residual);
                    }

                    trendTabPage.IsTrendAnalysisModelSummaryVisible = trendForm.IsTrendAnalysisModelSummaryChecked;
                    trendTabPage.IsActualPredictedResidualDataGridVisible = trendForm.IsActualPredictedResidualDataGridChecked;
                    trendTabPage.IsForecastedDataGridVisible = trendForm.IsForecastedDataGridChecked;
                    trendTabPage.IsActualAndPredictedGraphVisible = trendForm.IsActualAndPredictedGraphChecked;
                    trendTabPage.IsActualAndForecastedGraphVisible = trendForm.IsActualAndForecastedGraphChecked;
                    trendTabPage.IsActualVsPredictedGraphVisible = trendForm.IsActualVsPredictedGraphChecked;
                    trendTabPage.IsResidualGraphVisible = trendForm.IsResidualGraphChecked;
                    trendTabPage.IsResidualVsActualGraphVisible = trendForm.IsResidualVsActualGraphChecked;
                    trendTabPage.IsResidualVsPredictedGraphVisible = trendForm.IsResidualVsPredictedGraphChecked;

                    trendTabPage.DrawControl();

                    trendTabPage.IsDrawn = true;
                    this.tabControlResult.AddTab(trendTabPage);
                    this.tabControlResult.SelectedItem = trendTabPage;

                    this.tabControlData.SelectedTab = this.tabPageResult;

                }
            }
        }
Ejemplo n.º 6
0
        public void LinearRegression()
        {
            LinearRegressionAnalysisForm dlg = new LinearRegressionAnalysisForm(this.data);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                int k = 1;
                foreach (FATabStripItem tabPage in this.tabControlResult.Items)
                {
                    if (tabPage.Title.StartsWith("Regression Analysis")) k++;
                }

                if (dlg.IsStorePredicted)
                {
                    SeriesVariable var = new SeriesVariable(dlg.PredictedName,
                        "Predicted Value of Linear Regression Analysis of 'Model " + k.ToString());
                    var.InitializeItem(dlg.LRTable.Predicted.Length);
                    for (int i = 0; i < dlg.LRTable.Predicted.Length; i++)
                        var[i] = dlg.LRTable.Predicted[i];
                    this.data.SeriesVariables.Add(var);
                    this.seriesDataList.Refresh();
                }

                if (dlg.IsStoreResidual)
                {
                    SeriesVariable var = new SeriesVariable(dlg.ResidualName,
                        "Residual Value of Linear Regression Analysis of 'Model " + k.ToString());
                    var.InitializeItem(dlg.LRTable.Residual.Length);
                    for (int i = 0; i < dlg.LRTable.Residual.Length; i++)
                        var[i] = dlg.LRTable.Residual[i];
                    this.data.SeriesVariables.Add(var);
                    this.seriesDataList.Refresh();
                }

                LRResultTabPage lRTabPage = new LRResultTabPage();
                lRTabPage.SetData(this.data, dlg.DependentVariable, dlg.IndependentVariables,
                    dlg.LRProperties, dlg.LRTable, dlg.TestValues, dlg.ForcastedTime, dlg.ForcastedData);
                lRTabPage.IsAnovaTableVisible = dlg.IsAnovaTableChecked;
                lRTabPage.IsCoefficientTableVisible = dlg.IsCoefficientTableChecked;
                lRTabPage.IsDurbinWatsonVisible = dlg.IsDurbinWatsonChecked;
                lRTabPage.IsConfidenceIntervalForParametersVisible = dlg.IsConfidenceIntervalForParametersChecked;
                lRTabPage.IsVIFForPredictorsVisible = dlg.IsVIFForPredictorsChecked;
                lRTabPage.IsPartialCorrelationVisible = dlg.IsPartialCorrelationCecked;
                lRTabPage.IsDataTableVisible = dlg.IsDataTableChecked;
                lRTabPage.IsForcastedTableVisible = dlg.IsForcastedTableChecked;
                lRTabPage.IsResidualVsPredictedGraphVisible = dlg.IsResidualVsPredictedGraphChecked;
                lRTabPage.IsResidualGraphVisible = dlg.IsResidualGraphChecked;
                lRTabPage.IsNormalProbabilityPlotVisible = dlg.IsNormalProbabilityPlotChecked;
                lRTabPage.DrawControl();

                lRTabPage.Title = "Regression Analysis : 'Model " + k.ToString() + "'";
                lRTabPage.IsDrawn = true;
                this.tabControlResult.AddTab(lRTabPage);
                this.tabControlResult.SelectedItem = lRTabPage;

                this.tabControlData.SelectedTab = this.tabPageResult;
            }
        }
        // change in version 0.1.2
        //        
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (this.useFirstRowRadio.Checked)
            {
                this.selectedVariables.Clear();
                for (int i = 0; i < this.variableCount; i++)
                {
                    if ((bool)this.variableNameGrid[0, i].Value == true)
                    {
                        SeriesVariable var = new SeriesVariable(this.variableNameGrid[2, i].Value.ToString(), this.variableNameGrid[2, i].Value.ToString());
                        var.InitializeItem(this.data.NumberObservations);
                        for (int j = 0; j < this.data.NumberObservations && j < this.reader.RowCount - 1; j++)
                        {
                            try
                            {
                                string str = this.stringData[j + 1][i];
                                if (str == "") var[j] = 0.0D;
                                else var[j] = double.Parse(str);

                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Non numeric value is found in variable: '" + this.variableNameGrid[2, i].Value.ToString() + "'", "Import from Excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                this.DialogResult = DialogResult.None;
                                return;
                            }
                        }
                        this.selectedVariables.Add(var);
                    }
                }

                if (this.data.NumberObservations < this.reader.RowCount - 1)
                {
                    if (MessageBox.Show("Variable length in this file is longer than the current project variable length\n" +
                    "Only partial data are imported\n Are you sure you want to import this file?", "Import CSV", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                    == DialogResult.No) this.DialogResult = DialogResult.None;
                }
                else if (this.data.NumberObservations > this.reader.RowCount - 1)
                {
                    if (MessageBox.Show("Variable length in this file is shorter than the current project variable length\n" +
                    "Unavaliable data will be setted to 0\nAre you sure you want to import this file?", "Import CSV", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                        == DialogResult.No) this.DialogResult = DialogResult.None;
                }
            }
            else
            {
                this.selectedVariables.Clear();
                for (int i = 0; i < this.variableCount; i++)
                {
                    if ((bool)this.variableNameGrid[0, i].Value == true)
                    {
                        SeriesVariable var = new SeriesVariable(this.variableNameGrid[2, i].Value.ToString(), this.variableNameGrid[2, i].Value.ToString());
                        var.InitializeItem(this.data.NumberObservations);
                        for (int j = 0; j < this.data.NumberObservations && j < this.reader.RowCount; j++)
                        {
                            try
                            {
                                string str = this.stringData[j][i];
                                if (str == "") var[j] = 0.0D;
                                else var[j] = double.Parse(str);

                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Non numeric value is found in variable: '" + this.variableNameGrid[2, i].Value.ToString() + "'", "Import from Excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                this.DialogResult = DialogResult.None;
                                return;
                            }
                        }
                        this.selectedVariables.Add(var);
                    }
                }

                if (this.data.NumberObservations < this.reader.RowCount)
                {
                    if (MessageBox.Show("Variable length in this file is longer than the current project variable length\n" +
                    "Only partial data are imported\n Are you sure you want to import this file?", "Import CSV", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                    == DialogResult.No) this.DialogResult = DialogResult.None;
                }
                else if (this.data.NumberObservations > this.reader.RowCount)
                {
                    if (MessageBox.Show("Variable length in this file is shorter than the current project variable length\n" +
                    "Unavaliable data will be setted to 0\nAre you sure you want to import this file?", "Import CSV", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                        == DialogResult.No) this.DialogResult = DialogResult.None;
                }
            }
        }