//once the time series data has been transformed under either an iterative or Weibull like transformation, the transformed //data can be further standardised, the standardise() method of the Statistics class is used //see Section 3.1 of accompanying manual private void explrFormstandardisebt_Click(object sender, EventArgs e) { standardiseForm f1 = new standardiseForm(); f1.N1 = this.R; f1.M1 = this.C; //display the dialog if (f1.ShowDialog() == DialogResult.OK) { //need to figure out the number of rows and number of columns in the underlying spreadsheet int m2; bool m2Test = int.TryParse(f1.standardisetxtbcols.Text, out m2); int n2; bool n2Test = int.TryParse(f1.standardisetxtbrows.Text, out n2); if ((n2 > 0) && (m2 > 0) && (n2 <= R) && (m2 <= C)) { P.standardise(P.TransformedData, this.R, this.C, n2, m2); //now plot the means explrFormMeans.Show(); explrFormMeans.Titles.Clear(); explrFormMeans.Titles.Add(new Title("Transformed Data: Mean of groups", Docking.Top, new Font("Verdana", 8f, FontStyle.Bold), Color.Black)); explrFormMeans.ChartAreas[0].AxisY.LabelStyle.Font = explrFormMeans.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", 11, GraphicsUnit.Pixel); explrFormMeans.ChartAreas[0].RecalculateAxesScale(); explrFormMeans.Series.Clear(); var series10 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "Series10", Color = System.Drawing.Color.Blue, IsVisibleInLegend = false, IsXValueIndexed = true, ChartType = SeriesChartType.Line }; this.explrFormMeans.Series.Add(series10); explrFormMeans.ChartAreas[0].AxisY.Minimum = Math.Round(P.minimum(P.StdMeans) * 0.95, 2); explrFormMeans.ChartAreas[0].AxisY.Maximum = Math.Round(P.maximum(P.StdMeans) * 1.05, 2); int u = 0; foreach (double dd in P.StdMeans) { series10.Points.AddXY(u, Math.Round(dd, 2)); u++; } //skewness and kurtosis for transformed data standardisedlbl.Show(); standardisedskewlbl.Show(); standardisedkurtlbl.Show(); standardisedskewval.Show(); standardisedkurtval.Show(); double sk = Math.Round(P.skew(P.StandardisedTransformedData), 2); double ku = Math.Round(P.kurt(P.StandardisedTransformedData), 2); standardisedskewval.Text = sk.ToString(); standardisedkurtval.Text = ku.ToString(); } } }
//method which helps with differencing of the data //the method also plots the acf and pacf of the differenced data private void ARIMAdiff_Click(object sender, EventArgs e) { if (this.Mean > 0) this.Mean = 0; //form which will help to determine the order of differencing standardiseForm f1 = new standardiseForm(); ARIMAresidacf.Hide(); ARIMAdgv.Hide(); ARIMAhist.Hide(); ARIMAparameterdgv.Hide(); ARIMAparameterdgv.Hide(); ARIMAplbl.Hide(); ARIMArlbl.Hide(); ARIMAresidqqplot.Hide(); label1.Hide(); ARIMAroutput.Hide(); ARIMAsquaredresiduals.Hide(); ARIMAubt.Hide(); ARIMAsave.Hide(); //we don't need all the info from the "standardiseForm" hence we can hide some of objects in the form f1.standardisetxtbcols.Text = "1"; f1.standardisetxtbcols.Visible = false; f1.standardiselblcols.Visible = false; f1.standardiselblh.Text = "Provide an Integer to specify the differencing:"; f1.standardiselblrows.Text = "Integer"; f1.N1 = 100; f1.M1 = 100; //display the dialog if (f1.ShowDialog() == DialogResult.OK) { int m2; bool m2Test = int.TryParse(f1.standardisetxtbcols.Text, out m2); int n2; bool n2Test = int.TryParse(f1.standardisetxtbrows.Text, out n2); if ((n2 > 0)) { //display the chart ARIMAac2.Show(); this.P.DifferencedData.Clear(); this.P.Diff = n2; //now difference the data P.difference(); //calculate the autcorrelation and partial autocorrelation of the data List<double> sc = P.sampleautocorrelation(P.DifferencedData, 50); sc.RemoveAt(0); List<double> spc = P.samplepartialautocorrelation(P.DifferencedData, 50); spc.RemoveAt(0); //we will use the following code to create the horizontal lines in the ACF and PACF plots int n = this.P.DifferencedData.Count(); double l1 = 1.96 / Math.Sqrt(n); double l2 = -1.96 / Math.Sqrt(n); List<double> line1 = new List<double>(); List<double> line2 = new List<double>(); for (int i = 0; i < sc.Count(); i++) { line1.Add(l1); line2.Add(l2); } //plot of the autcoorrelation ARIMAac2.Titles.Clear(); ARIMAac2.Titles.Add(new Title("Differenced Data: ACF and PACF", Docking.Top, new Font("Verdana", 8f, FontStyle.Bold), Color.Black)); ARIMAac2.ChartAreas[0].AxisY.LabelStyle.Font = ARIMAac2.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", 11, GraphicsUnit.Pixel); ARIMAac2.ChartAreas[0].RecalculateAxesScale(); ARIMAac2.Series.Clear(); var series3 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "ACF", Color = System.Drawing.Color.Blue, IsVisibleInLegend = true, IsXValueIndexed = true, ChartType = SeriesChartType.Column }; this.ARIMAac2.Series.Add(series3); int z = 0; foreach (double dd in sc) { series3.Points.AddXY(z + 1, sc[z]); z++; } var series4 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "PACF", Color = System.Drawing.Color.Red, IsVisibleInLegend = true, IsXValueIndexed = true, ChartType = SeriesChartType.Column }; this.ARIMAac2.Series.Add(series4); z = 0; foreach (double dd in spc) { series4.Points.AddXY(z + 1, spc[z]); z++; } var series23 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "Series23", Color = System.Drawing.Color.Black, IsVisibleInLegend = false, IsXValueIndexed = true, ChartType = SeriesChartType.Line }; this.ARIMAac2.Series.Add(series23); z = 0; foreach (double dd in line1) { series23.Points.AddXY(z + 1, line1[z]); z++; } var series24 = new System.Windows.Forms.DataVisualization.Charting.Series { Name = "Series24", Color = System.Drawing.Color.Black, IsVisibleInLegend = false, IsXValueIndexed = true, ChartType = SeriesChartType.Line }; this.ARIMAac2.Series.Add(series24); z = 0; foreach (double dd in line2) { series24.Points.AddXY(z + 1, line2[z]); z++; } ARIMAac2.Invalidate(); ARIMAac2.ChartAreas[0].AxisY.Maximum = Math.Max(P.maximum(sc), P.maximum(spc)); } else { //ensure that the Diff is set to 0 as the user has decided not to use differencing this.P.Diff = 0; } } //end of method }