Example: ARSeasonalFit

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.

import com.imsl.stat.*;
import com.imsl.math.PrintMatrix;
import com.imsl.math.PrintMatrixFormat;

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);
    }
    
}

Output

NLost = 13
aic =606.3972456534914
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.31  


First 30 elements of the original time series and differenced series
    Original  Differenced  
 0    112           ?      
 1    118           ?      
 2    132           ?      
 3    129           ?      
 4    121           ?      
 5    135           ?      
 6    148           ?      
 7    148           ?      
 8    136           ?      
 9    119           ?      
10    104           ?      
11    118           ?      
12    115           ?      
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         -18      

Link to Java source.