public void SSAForecast_Test() { var _ts = getAirPassengersData(); // Monthly time-series data //DataFrame.ToCsv("usa_deaths.csv",df); //var ts = df.ToSeries().Select(x => Convert.ToDouble(x)); //embed var ssa = new SSA(_ts); //embed var x = ssa.Embedding(12); //decompose ssa.Decompose(); // var charts = ssa.PlotEigenPairs(); XPlot.Plotly.Chart.ShowAll(charts); var ff = ssa.Forecast(new int[] { 1, 2, 3, 5, 7 }, 6, method: Forecasting.Rforecasing); var scatters1 = new Scatter() { name = "Predicted", x = Enumerable.Range(1, ff.Length), y = ff, mode = "line", }; var scatters2 = new Scatter() { name = "Actual", x = Enumerable.Range(1, _ts.Count()), y = _ts, mode = "line", fillcolor = "Blue" }; var chart = XPlot.Plotly.Chart.Plot <Trace>(new Trace[] { scatters1, scatters2 }); chart.Show(); }
public void SSA_Correlation_Test02() { // var df = getMonthlyDeatsData(); // Monthly time-series data //DataFrame.ToCsv("usa_deaths.csv",df); var ts = df.ToSeries().Select(x => Convert.ToDouble(x)); //embed var ssa = new SSA(ts); //embed var x = ssa.Embedding(24); PlotMatrix(x).Show(); //decompose ssa.Decompose(); var plt = new List <XPlot.Plotly.PlotlyChart> (); foreach (var tm in ssa.EM) { plt.Add(PlotMatrix(tm.Value)); } XPlot.Plotly.Chart.ShowAll(plt); var f1 = ssa.Reconstruct(1); var sct1 = new Scatter() { name = "Actual", x = Enumerable.Range(1, f1.Length), y = f1, mode = "line", }; var chart1 = XPlot.Plotly.Chart.Plot <Trace>(new Trace[] { sct1 }); chart1.Show(); var ff = ssa.Forecast(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, 6, method: Forecasting.Rforecasing); var scatters1 = new Scatter() { name = "Predicted", x = Enumerable.Range(1, ff.Length), y = ff, mode = "line", }; var scatters2 = new Scatter() { name = "Actual", x = Enumerable.Range(1, ts.Count()), y = ts, mode = "line", fillcolor = "Blue" }; var chart = XPlot.Plotly.Chart.Plot <Trace>(new Trace[] { scatters1, scatters2 }); // chart.Show(); // int i= 0; // ssa.PlotComponents(12); // ssa.PlotSingularValues().Show(); // var charts = ssa.PlotEigenPairs(); XPlot.Plotly.Chart.ShowAll(charts); var w = ssa.WCorrelation(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }); ssa.PlotwCorrelation(w).Show(); }