public void SetData(SeriesData data, SeriesVariable variable, double[] predicted) { this.variable = variable; this.data = data; this.predicted = predicted; this.update(); }
public void SetData(SeriesData data, SeriesVariable variable, double[] residual) { this.variable = variable; this.data = data; this.residual = residual; this.update(); }
/// <summary> /// Constructor /// </summary> /// <param name="name">Stock Name</param> /// <param name="description">Stock Description</param> /// <param name="open">Stock's open variable</param> /// <param name="close">Stock's close variable</param> /// <param name="high">Stock's high variable</param> /// <param name="low">Stock's low variable</param> /// <param name="volume">Stock's volume variable</param> private void initialize(string name, string description, SeriesVariable open, SeriesVariable close, SeriesVariable high, SeriesVariable low, SeriesVariable volume) { this.stockName = name; this.stockDescription = description; this.open = open; this.close = close; this.high = high; this.low = low; this.volume = volume; if (this.open != null) { this.open.Changed += new ChangedEventHandler(changed); } if (this.close != null) { this.close.Changed += new ChangedEventHandler(changed); } if (this.high != null) { this.high.Changed += new ChangedEventHandler(changed); } if (this.low != null) { this.low.Changed += new ChangedEventHandler(changed); } if (this.volume != null) { this.volume.Changed += new ChangedEventHandler(changed); } }
public void SetData(SeriesData data, SeriesVariable variable, double[] deseasonal) { this.variable = variable; this.data = data; this.deseasonal = deseasonal; this.update(); }
/// <summary> /// Metode dekomposisi klasik dengan rasio pada rata-rata bergerak /// </summary> /// <param name="variable">SeriesVariable. variabel yang akan dianalisis</param> /// <param name="seasonalLength">Integer. panjang satu siklus musiman</param> /// <param name="isMultiplikatif">Bool. apakah menggunakan metode multiplikatif?</param> /// <param name="initialTrend">Integer. Inisial model tren yang digunakan, 1-Linear, 2-Quadratic, 3-Cubic, 4-Exponential</param> public DecompositionClassic(SeriesVariable variable, int seasonalLength, bool isMultiplicative, int initialTrend) { this.variable = variable; Vector var = new Vector(this.variable.SeriesValuesNoNaN.ToArray()); this.y = new Vector(var.Tuples); for (int i = 0; i < y.Tuples; i++) this.y[i] = var[i]; this.n = y.Tuples; this.seasonalLength = seasonalLength; this.trend = new double[this.n]; this.detrend = new double[this.n]; this.seasonal = new double[this.n]; this.deseasonal = new double[this.n]; this.predicted = new double[this.n]; this.residual = new double[this.n]; this.isMultiplicative = isMultiplicative; this.initialTrend = initialTrend; if (this.isMultiplicative) this.Multiplicative(); else this.Additive(); this.ForecastingError(); }
public void SetData(SeriesData data, SeriesVariable variable, double[] detrend) { this.variable = variable; this.data = data; this.detrend = detrend; this.update(); }
/// <summary> /// Mencari index variabel pada list /// </summary> /// <param name="variableCollection">list variabel</param> /// <param name="name">nama variabel</param> /// <returns>index</returns> public static int FindVariableIndex(SeriesVariables variableCollection, string name) { variableToFind = new SeriesVariable(name, ""); System.Predicate<SeriesVariable> search = findVariablePredicate; return variableCollection.FindIndex(search); }
public void SetData(SeriesData data, SeriesVariable variable, double[] forecasted) { this.variable = variable; this.data = data; this.forecasted = forecasted; this.update(); }
/// <summary> /// Mencari index variabel pada list /// </summary> /// <param name="variableCollection">list variabel</param> /// <param name="name">nama variabel</param> /// <returns>index</returns> public static int FindVariableIndex(SeriesVariables variableCollection, string name) { variableToFind = new SeriesVariable(name, ""); System.Predicate <SeriesVariable> search = findVariablePredicate; return(variableCollection.FindIndex(search)); }
public void SetData(SeriesVariable dependentVariable, SeriesVariables independentVariables, LinearRegressionAnalysisForm.LRSpecification lrProperties) { this.dependentVariable = dependentVariable; this.independentVariables = independentVariables; this.lrProperties = lrProperties; this.update(); }
public void SetData(SeriesVariable variable, SeriesData data) { this.variable = variable; this.data = data; this.variable.SeriesValues.Changed += new ChangedEventHandler(SeriesValues_Changed); this.update(); }
public void SetData(SeriesData data, SeriesVariable variable, MovingAverageForm.MASpecification maProperties) { this.data = data; this.variable = variable; this.maProperties = maProperties; this.lblVariable.Text = variable.VariableName; this.update(); }
public void SetData(SeriesVariable variable, SeriesData data) { this.variableDataGrid.SetData(variable, data); this.variableGraph.SetData(variable, data); this.variableStatistics.SetData(variable, data); this.Text = variable.VariableName; this.Name = "SERIES " + variable.VariableName; }
public void SetData(SeriesData data, SeriesVariable variable, TrendAnalysisForm.TrendSpecification trendProperties) { this.data = data; this.variable = variable; this.trendProperties = trendProperties; this.lblVariable.Text = variable.VariableName; this.update(); }
public void SetData(SeriesData data, SeriesVariable variable, NeuralNetworkAnalysisForm.NetworkSpecification networkProperties) { this.data = data; this.variable = variable; this.networkProperties = networkProperties; this.lblVariable.Text = variable.VariableName; this.update(); }
public void SetData(SeriesData data, SeriesVariable variable, ExponentialSmoothingForm.ESSpecification esProperties) { this.data = data; this.variable = variable; this.esProperties = esProperties; this.lblVariable.Text = variable.VariableName; this.update(); }
public void SetData(SeriesData data, SeriesVariable variable, DecompositionForm.DECSpecification decProperties) { this.data = data; this.variable = variable; this.decProperties = decProperties; this.lblVariable.Text = variable.VariableName; this.update(); }
/// <summary> /// Mengkloning variabel /// </summary> /// <returns>variabel baru dengan nilai sama dengan variabel asal</returns> public object Clone() { SeriesVariable clone = new SeriesVariable(this.VariableName, this.VariableDescription, this.SeriesValues.Count); for (int i = 0; i < this.SeriesValues.Count; i++) { clone[i] = this[i]; } return(clone); }
public void SetData(SeriesData data, SeriesVariable variable, bool isSmoothingVisible, double[] smoothed1, double[] predicted, double[] residual) { this.data = data; this.variable = variable; this.isSmoothingVisible = isSmoothingVisible; this.smoothed1 = smoothed1; this.predicted = predicted; this.residual = residual; this.update(); }
public void SetData(SeriesData data, SeriesVariable variable, bool isSmoothingVisible, bool isTrendVisible, bool isSeasonalVisible, double[] smoothing, double[] trend, double[] seasonal, double[] predicted, double[] residual) { this.data = data; this.variable = variable; this.isSmoothingVisible = isSmoothingVisible; this.isTrendVisible = isTrendVisible; this.isSeasonalVisible = isSeasonalVisible; this.smoothing = smoothing; this.trend = trend; this.seasonal = seasonal; this.predicted = predicted; this.residual = residual; this.update(); }
/// <summary> /// Constructor. Pemulusan dengan metode Rata-Rata Bergerak Tunggal /// </summary> /// <param name="variable">SeriesVariable. variable</param> /// <param name="maLength">Integer. MA Length</param> public SingleMovingAverage(SeriesVariable variable, int maLength) { this.variable = variable; Vector var = new Vector(this.variable.SeriesValuesNoNaN.ToArray()); this.Y = new Vector(var.Tuples); for (int i = 0; i < Y.Tuples; i++) this.Y[i] = var[i]; this.n = Y.Tuples; this.t = maLength; this.smoothing1 = new double[this.n]; this.predicted = new double[this.n]; this.residual = new double[this.n]; this.Smoothing(); this.ForecastingError(); }
/// <summary> /// Constructor. Menghitung Pemulusan Eksponensial Tripel /// </summary> /// <param name="variable">SeriesVariable. variabel</param> /// <param name="alpha">Double. Smoothing constant for data</param> /// <param name="gamma">Double. Smoothing constant for trend</param> /// <param name="beta">Double. Smoothing constant for seasonal</param> /// <param name="seasonalLength">Integer. Panjang seasonal</param> public TripleExponentialSmoothingWinter(SeriesVariable variable, double alpha, double gamma, double beta, int seasonalLength, bool isMultiplicative) { this.variable = variable; Vector var = new Vector(this.variable.SeriesValuesNoNaN.ToArray()); this.y = new Vector(var.Tuples); for (int i = 0; i < y.Tuples; i++) this.y[i] = var[i]; this.n = this.y.Tuples; this.alpha = alpha; this.gamma = gamma; this.beta = beta; this.l = seasonalLength; this.isMultiplicative = isMultiplicative; this.smoothing = new double[this.n]; this.trend = new double[this.n]; this.seasonal = new double[this.n]; this.predicted= new double[this.n]; this.residual = new double[this.n]; //term term = new int[this.n]; for (int i = 0; i < this.n; ) { for (int j = 0; j < this.l; ++j) { if (i + j != this.n) term[i + j] = j; else break; } i += this.l; } if(this.isMultiplicative) SmoothingMultiplicative(); else SmoothingAdditive(); ForecastingError(); }
/// <summary> /// Constructor. Pemulusan Eksponensial Ganda dengan metode Holt /// </summary> /// <param name="variable">SeriesVariable. variabel</param> /// <param name="alpha">Double. Smoothing constanta for data</param> /// <param name="gamma">Double. Smoothing constanta for trend</param> public DoubleExponentialSmoothingHolt(SeriesVariable variable, double alpha, double gamma) { this.variable = variable; Vector var = new Vector(this.variable.SeriesValuesNoNaN.ToArray()); this.y = new Vector(var.Tuples); for (int i = 0; i < y.Tuples; i++) this.y[i] = var[i]; this.n = this.y.Tuples; this.a = alpha; this.g = gamma; this.smoothing = new double[this.n]; this.trend = new double[this.n]; this.predicted = new double[this.n]; this.residual = new double[this.n]; this.Smoothing(); this.ForecastingError(); }
/// <summary> /// Pemulusan dengan metode Rata-Rata Bergerak ganda /// </summary> /// <param name="variable">SeriesVariable. variabel yang akan dianalisis</param> /// <param name="maLength">Integer. MA Length</param> public DoubleMovingAverage(SeriesVariable variable, int maLength) { this.variable = variable; Vector var = new Vector(this.variable.SeriesValuesNoNaN.ToArray()); this.y = new Vector(var.Tuples); for (int i = 0; i < y.Tuples; i++) y[i] = var[i]; this.n = y.Tuples; this.t = maLength; this.smoothing1 = new double[n]; this.smoothing2 = new double[n]; this.at = new double[n]; this.bt = new double[n]; this.predicted = new double[n]; this.residual = new double[n]; Smoothing(); ForecastingError(); }
public void SetData(SeriesVariables independentVariables, SeriesVariable dependentVariable, double[,] testValues, string[] forcastedTime, double[] forcastedData) { foreach (SeriesVariable var in independentVariables) { DataGridViewTextBoxColumn clm = new DataGridViewTextBoxColumn(); clm.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; clm.HeaderText = var.VariableName; clm.Name = "clm" + var.VariableName; clm.ReadOnly = true; clm.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic; this.grdForcasted.Columns.Add(clm); } DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; c.HeaderText = dependentVariable.VariableName; c.Name = "clm" + dependentVariable.VariableName; c.ReadOnly = true; c.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic; this.grdForcasted.Columns.Add(c); this.grdForcasted.RowCount = forcastedTime.Length; for (int i = 0; i < this.grdForcasted.Rows.Count; i++) { this.grdForcasted.Rows[i].HeaderCell.Value = forcastedTime[i]; for (int j = 0; j < independentVariables.Count; j++) { this.grdForcasted.Rows[i].Cells[j].Value = testValues[j, i].ToString("F4"); } this.grdForcasted.Rows[i].Cells[independentVariables.Count].Value = forcastedData[i].ToString("F4"); } this.grdForcasted.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; }
public void TransformVariable() { SeriesVariables vars = this.data.SeriesVariables; zaitun.GUI.TransformVariable ser = new zaitun.GUI.TransformVariable(vars); ser.ShowDialog(); if (ser.DialogResult == DialogResult.OK) { SeriesVariable tmpVar = new SeriesVariable(ser.NewVariableName, ser.Transform.ToString() + " transformation" + " from \"" + ser.SelectedVariable.VariableName + "\""); if (ser.Transform == zaitun.GUI.TransformVariable.TransformationType.Differencing) { tmpVar.SeriesValues.Add(double.NaN); for (int i = 1; i < ser.SelectedVariable.SeriesValues.Count; i++) { tmpVar.SeriesValues.Add(ser.SelectedVariable.SeriesValues[i] - ser.SelectedVariable.SeriesValues[i - 1]); } } else if (ser.Transform == zaitun.GUI.TransformVariable.TransformationType.SeasonalDifferencing) { for (int i = 0; i < ser.SeasonalLag; i++) tmpVar.SeriesValues.Add(double.NaN); for (int i = ser.SeasonalLag; i < ser.SelectedVariable.SeriesValues.Count; i++) { tmpVar.SeriesValues.Add(ser.SelectedVariable.SeriesValues[i] - ser.SelectedVariable.SeriesValues[i - ser.SeasonalLag]); } } else if (ser.Transform == zaitun.GUI.TransformVariable.TransformationType.NaturalLogarithm) { for (int i = 0; i < ser.SelectedVariable.SeriesValues.Count; i++) { tmpVar.SeriesValues.Add(Math.Log(ser.SelectedVariable.SeriesValues[i])); } } else if (ser.Transform == zaitun.GUI.TransformVariable.TransformationType.Logarithm) { for (int i = 0; i < ser.SelectedVariable.SeriesValues.Count; i++) { tmpVar.SeriesValues.Add(Math.Log(ser.SelectedVariable.SeriesValues[i], ser.LogarithmBase)); } } else if (ser.Transform == zaitun.GUI.TransformVariable.TransformationType.SquareRoot) { for (int i = 0; i < ser.SelectedVariable.SeriesValues.Count; i++) { tmpVar.SeriesValues.Add(Math.Sqrt(ser.SelectedVariable.SeriesValues[i])); } } try { vars.Add(tmpVar); this.seriesDataList.Refresh(); } catch (DuplicateVariableException) { MessageBox.Show("Variable '" + tmpVar.VariableName + "' already exist", "Duplicate Variable Name", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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; } } }
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; } } }
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; } } }
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); } } }
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; } } }
/// <summary> /// Predicate untuk pencarian variabel /// </summary> /// <param name="search">variabel yang akan dicari</param> /// <returns>apakah nama variabel match</returns> private static bool findVariablePredicate(SeriesVariable search) { return(search.VariableName.Equals(variableToFind.VariableName)); }
/// <summary> /// Constructor /// </summary> /// <param name="name">Stock Name</param> /// <param name="description">Stock Description</param> /// <param name="open">Stock's open variable</param> /// <param name="close">Stock's close variable</param> /// <param name="high">Stock's high variable</param> /// <param name="low">Stock's low variable</param> /// <param name="volume">Stock's volume variable</param> public SeriesStock(string name, string description, SeriesVariable open, SeriesVariable close, SeriesVariable high, SeriesVariable low, SeriesVariable volume) { this.initialize(name, description, open, close, high, low, volume); }
/// <summary> /// Mengeset variabel yang aka dianalisis /// </summary> /// <param name="variable">variabel yang aka dianalisis</param> public void SetVariable(SeriesVariable variable) { this.variable = variable; this.data = variable.SeriesValuesNoNaN.ToArray(); double[,] actualSeries = new double[variable.Observations,2]; for (int i = 0; i < variable.Observations; i++) { actualSeries[i, 0] = i; actualSeries[i, 1] = variable.SeriesValuesNoNaN[i]; } seriesChart.RangeX = new DoubleRange(0, variable.Observations - 1); seriesChart.UpdateDataSeries("Actual", actualSeries); seriesChart.UpdateDataSeries("Predicted", null); this.observationLabel.Text = "Observations : " + variable.Observations.ToString(); this.Text = "Neural Network Analysis Form : " + variable.VariableName; }
/// <summary> /// Membaca data /// </summary> /// <returns>Series Data hasil pembacaan</returns> public SeriesData ReadData() { SeriesData tmpData; seriesDataReader.ReadToFollowing("SeriesData"); seriesDataReader.ReadStartElement(); { string seriesName = seriesDataReader.ReadElementContentAsString(); SeriesData.SeriesFrequency freq = (SeriesData.SeriesFrequency)seriesDataReader.ReadElementContentAsInt(); DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); if (freq != SeriesData.SeriesFrequency.Undated) { startDate = XmlConvert.ToDateTime(seriesDataReader.ReadElementContentAsString(), "dd/MM/yyyy"); endDate = XmlConvert.ToDateTime(seriesDataReader.ReadElementContentAsString(), "dd/MM/yyyy"); } else { seriesDataReader.Skip(); seriesDataReader.Skip(); } int numberObservations = seriesDataReader.ReadElementContentAsInt(); if (freq != SeriesData.SeriesFrequency.Undated) { tmpData = new SeriesData(seriesName, freq, startDate, endDate); } else { tmpData = new SeriesData(seriesName, numberObservations); } } seriesDataReader.ReadStartElement(); while (seriesDataReader.IsStartElement("SeriesVariable")) { SeriesVariable tmpVariable; seriesDataReader.ReadStartElement(); { string variableName = seriesDataReader.ReadElementContentAsString(); string variableDescription = seriesDataReader.ReadElementContentAsString(); tmpVariable = new SeriesVariable(variableName, variableDescription); } seriesDataReader.ReadStartElement(); for (int i = 0; i < tmpData.NumberObservations; i++) { tmpVariable.SeriesValues.Add(seriesDataReader.ReadElementContentAsDouble()); } seriesDataReader.ReadEndElement(); tmpData.SeriesVariables.Add(tmpVariable); seriesDataReader.ReadEndElement(); } seriesDataReader.ReadToFollowing("SeriesGroups"); seriesDataReader.ReadStartElement(); while (seriesDataReader.IsStartElement("SeriesGroup")) { SeriesGroup tmpGroup; SeriesVariables tmpGroupList = new SeriesVariables(); seriesDataReader.ReadStartElement(); string groupName = seriesDataReader.ReadElementContentAsString(); seriesDataReader.ReadStartElement(); while (seriesDataReader.IsStartElement("SeriesVariableItem")) { SeriesVariable tmpVariableItem; string variableName = seriesDataReader.ReadElementContentAsString(); tmpVariableItem = tmpData.SeriesVariables[VariableFinder.FindVariableIndex(tmpData.SeriesVariables, variableName)]; tmpGroupList.Add(tmpVariableItem); } tmpGroup = new SeriesGroup(groupName, tmpGroupList); seriesDataReader.ReadEndElement(); tmpData.SeriesGroups.Add(tmpGroup); seriesDataReader.ReadEndElement(); } return(tmpData); }
/// <summary> /// Mengeset variabel yang aka dianalisis /// </summary> /// <param name="variable">variabel yang aka dianalisis</param> public void SetVariable(SeriesVariable variable) { this.variable = variable; this.data = variable.SeriesValuesNoNaN.ToArray(); double[,] actualSeries = new double[variable.Observations,2]; this.actualDS.Length = variable.Observations; for (int i = 0; i < variable.Observations; i++) { actualSeries[i, 0] = i; actualSeries[i, 1] = variable.SeriesValuesNoNaN[i]; this.actualDS.Samples[i].x = i; this.actualDS.Samples[i].y = (float)variable.SeriesValuesNoNaN[i]; } //this.actualDS.AutoScaleY = true; this.actualDS.YD0 = (float)variable.MinValue; this.actualDS.YD1 = (float)variable.MaxValue; this.predictedDS.YD0 = (float)variable.MinValue; this.predictedDS.YD1 = (float)variable.MaxValue; this.validationDS.YD0 = (float)variable.MinValue; this.validationDS.YD1 = (float)variable.MaxValue; this.seriesGraph.XD0 = 0; this.seriesGraph.XD1 = variable.Observations; this.seriesGraph.hasMovingGrid = false; this.seriesGraph.hasBoundingBox = false; this.seriesGraph.layout = PlotterGraphPaneEx.LayoutMode.NORMAL; this.predictedDS.Active = false; this.validationDS.Active = false; this.seriesGraph.Refresh(); this.observationLabel.Text = "Observations : " + variable.Observations.ToString(); this.Text = "Neural Network Analysis Form : " + variable.VariableName; }