Consider the Airline Data (Box, Jenkins and Reinsel 1994, p. 547) consisting of the monthly total number of international airline passengers from January 1949 through December 1960. Class ARSeasonalFit
is used to compute the optimum seasonality representation of the adjusted series
As differenced series with minimum AIC,
using System; using Imsl.Stat; using Imsl.Math; using PrintMatrix = Imsl.Math.PrintMatrix; using Imsl; public class ARSeasonalFitEx1 { public static void Main(String[] args) { double[] z = new double[]{112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 140, 145, 150, 178, 163, 172, 178, 199, 199, 184, 162, 146, 166, 171, 180, 193, 181, 183, 218, 230, 242, 209, 191, 172, 194, 196, 196, 236, 235, 229, 243, 264, 272, 237, 211, 180, 201, 204, 188, 235, 227, 234, 264, 302, 293, 259, 229, 203, 229, 242, 233, 267, 269, 270, 315, 364, 347, 312, 274, 237, 278, 284, 277, 317, 313, 318, 374, 413, 405, 355, 306, 271, 306, 315, 301, 356, 348, 355, 422, 465, 467, 404, 347, 305, 336, 340, 318, 362, 348, 363, 435, 491, 505, 404, 359, 310, 337, 360, 342, 406, 396, 420, 472, 548, 559, 463, 407, 362, 405, 417, 391, 419, 461, 472, 535, 622, 606, 508, 461, 390, 432}; int[,] sInit = {{1, 1}, {1, 12}}; ARSeasonalFit seasFit = new ARSeasonalFit(10, sInit, z); seasFit.Compute(); Console.Out.WriteLine("NLost = " + seasFit.NLost); Console.Out.WriteLine("aic =" + seasFit.AIC); new PrintMatrix("Best Periods (Optimum S)").Print(seasFit.GetOptimumS()); new PrintMatrix("Best Orders (Optimum D)").Print(seasFit.GetOptimumD()); Console.Out.WriteLine("Best AR order selected = " + seasFit.AROrder); new PrintMatrix("AR Coefficients").Print(seasFit.GetAR()); Console.Out.WriteLine(""); double[] w = seasFit.GetTransformedTimeSeries(); double[][] pack = new double[30][]; for (int i = 0; i < 30; i++) { pack[i] = new double[2]; pack[i][0] = z[i]; pack[i][1] = w[i]; } PrintMatrix pm = new PrintMatrix(); String str = "First 30 elements of the original time series and " + "differenced series"; pm.SetTitle(str); PrintMatrixFormat fmt = new PrintMatrixFormat(); fmt.SetColumnLabels(new String[]{"Original", "Differenced"}); pm.Print(fmt, pack); } }
NLost = 13 aic =606.397245653491 Best Periods (Optimum S) 0 0 1 1 12 Best Orders (Optimum D) 0 0 1 1 1 Best AR order selected = 1 AR Coefficients 0 0 -0.309834454941166 First 30 elements of the original time series and differenced series Original Differenced 0 112 NaN 1 118 NaN 2 132 NaN 3 129 NaN 4 121 NaN 5 135 NaN 6 148 NaN 7 148 NaN 8 136 NaN 9 119 NaN 10 104 NaN 11 118 NaN 12 115 NaN 13 126 5 14 141 1 15 135 -3 16 125 -2 17 149 10 18 170 8 19 170 0 20 158 0 21 133 -8 22 114 -4 23 140 12 24 145 8 25 150 -6 26 178 13 27 163 -9 28 172 19 29 178 -18Link to C# source.