package com.imsl.test.example.stat; import com.imsl.stat.*; import com.imsl.math.*; /** *

* Searches for the best fit seasonality for the Airline * data.

* *

* 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 * $$W_t(s,d)=\Delta_{s_1}^{d_1}\Delta_{s_2}^{d_2}Z_t= * {(1-B^{s_1})}^{d_1}{(1-B^{s_2})}^{d_2}Z_t\rm{,}$$ where $$s=(1,1)$$ or * $$s=(1,12)$$ and $$d=(1,1)\rm{.}$$ *

*

* As differenced series with minimum AIC, * $$W_t=\Delta_1^1\Delta_{12}^2Z_t=(Z_t-Z_{t-12})- (Z_{t-1}-Z_{t-13})\rm{,}$$ * is identified. *

* * @see Code * @see Output */ public class ARSeasonalFitEx1 { public static void main(String args[]) throws Exception { double[] z = { 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(); System.out.println("NLost = " + seasFit.getNLost()); System.out.println("aic =" + seasFit.getAIC()); new PrintMatrix("Best Periods (Optimum S)"). print(seasFit.getOptimumS()); new PrintMatrix("Best Orders (Optimum D)"). print(seasFit.getOptimumD()); System.out.println("Best AR order selected = " + seasFit.getAROrder()); new PrintMatrix("AR Coefficients").print(seasFit.getAR()); System.out.println(""); double w[] = seasFit.getTransformedTimeSeries(); double pack[][] = new double[30][2]; for (int i = 0; i < 30; i++) { 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); } }