This example is based on estimates of the Canadian lynx population. Class ARMAOutlierIdentification
is used to fit an model of the form Gaussian White noise, to the given series. Method compute
determines parameters and and identifies a LS outlier at time point .
import com.imsl.stat.*; import java.util.*; public class ARMAOutlierIdentificationEx1 { public static void main(String args[]) throws Exception { double[] series = { 0.24300E01,0.25060E01,0.27670E01,0.29400E01,0.31690E01,0.34500E01, 0.35940E01,0.37740E01,0.36950E01,0.34110E01,0.27180E01,0.19910E01, 0.22650E01,0.24460E01,0.26120E01,0.33590E01,0.34290E01,0.35330E01, 0.32610E01,0.26120E01,0.21790E01,0.16530E01,0.18320E01,0.23280E01, 0.27370E01,0.30140E01,0.33280E01,0.34040E01,0.29810E01,0.25570E01, 0.25760E01,0.23520E01,0.25560E01,0.28640E01,0.32140E01,0.34350E01, 0.34580E01,0.33260E01,0.28350E01,0.24760E01,0.23730E01,0.23890E01, 0.27420E01,0.32100E01,0.35200E01,0.38280E01,0.36280E01,0.28370E01, 0.24060E01,0.26750E01,0.25540E01,0.28940E01,0.32020E01,0.32240E01, 0.33520E01,0.31540E01,0.28780E01,0.24760E01,0.23030E01,0.23600E01, 0.26710E01,0.28670E01,0.33100E01,0.34490E01,0.36460E01,0.34000E01, 0.25900E01,0.18630E01,0.15810E01,0.16900E01,0.17710E01,0.22740E01, 0.25760E01,0.31110E01,0.36050E01,0.35430E01,0.27690E01,0.20210E01, 0.21850E01,0.25880E01,0.28800E01,0.31150E01,0.35400E01,0.38450E01, 0.38000E01,0.35790E01,0.32640E01,0.25380E01,0.25820E01,0.29070E01, 0.31420E01,0.34330E01,0.35800E01,0.34900E01,0.34750E01,0.35790E01, 0.28290E01,0.19090E01,0.19030E01,0.20330E01,0.23600E01,0.26010E01, 0.30540E01,0.33860E01,0.35530E01,0.34680E01,0.31870E01,0.27230E01, 0.26860E01,0.28210E01,0.30000E01,0.32010E01,0.34240E01,0.35310E01}; int[] model = new int[4]; double[] outlierFreeSeries; double resStdErr, aic, constant; double[] ar; int[][] outlierStatistics; int numOutliers; model[0] = 2; model[1] = 0; model[2] = 1; model[3] = 2; ARMAOutlierIdentification armaOutlier = new ARMAOutlierIdentification(series); armaOutlier.setCriticalValue(3.5); armaOutlier.compute(model); outlierFreeSeries = armaOutlier.getOutlierFreeSeries(); numOutliers = armaOutlier.getNumberOfOutliers(); outlierStatistics = armaOutlier.getOutlierStatistics(); constant = armaOutlier.getConstant(); ar = armaOutlier.getAR(); resStdErr = armaOutlier.getResidualStandardError(); aic = armaOutlier.getAIC(); System.out.printf("%n%n ARMA parameters:%n"); System.out.printf(Locale.ENGLISH, "constant:%9.6f%n", constant); System.out.printf(Locale.ENGLISH, "ar[0]:%12.6f%n", ar[0]); System.out.printf(Locale.ENGLISH, "ar[1]:%12.6f%n%n", ar[1]); System.out.printf("Number of outliers:%3d%n", numOutliers); System.out.printf("%n Outlier statistics:%n"); System.out.printf("Time point%6sOutlier type%n", " "); for (int i = 0; i < numOutliers; i++) System.out.printf("%10d%18d%n", outlierStatistics[i][0], outlierStatistics[i][1]); System.out.printf(Locale.ENGLISH, "%nRSE:%9.6f%n", resStdErr); System.out.printf(Locale.ENGLISH, "AIC:%11.6f", aic); System.out.printf("%n%n Extract from the series:%n"); System.out.printf("time original outlier free%n"); for (int i = 0; i < 36; i++) System.out.printf(Locale.ENGLISH, "%4d%11.4f%15.4f%n", i + 1, series[i], outlierFreeSeries[i]); } }
ARMA parameters: constant: 0.000000 ar[0]: 0.106507 ar[1]: -0.195843 Number of outliers: 1 Outlier statistics: Time point Outlier type 16 2 RSE: 0.319542 AIC: 282.918209 Extract from the series: time original outlier free 1 2.4300 2.4300 2 2.5060 2.5060 3 2.7670 2.7670 4 2.9400 2.9400 5 3.1690 3.1690 6 3.4500 3.4500 7 3.5940 3.5940 8 3.7740 3.7740 9 3.6950 3.6950 10 3.4110 3.4110 11 2.7180 2.7180 12 1.9910 1.9910 13 2.2650 2.2650 14 2.4460 2.4460 15 2.6120 2.6120 16 3.3590 2.6997 17 3.4290 2.7697 18 3.5330 2.8737 19 3.2610 2.6017 20 2.6120 1.9527 21 2.1790 1.5197 22 1.6530 0.9937 23 1.8320 1.1727 24 2.3280 1.6687 25 2.7370 2.0777 26 3.0140 2.3547 27 3.3280 2.6687 28 3.4040 2.7447 29 2.9810 2.3217 30 2.5570 1.8977 31 2.5760 1.9167 32 2.3520 1.6927 33 2.5560 1.8967 34 2.8640 2.2047 35 3.2140 2.5547 36 3.4350 2.7757Link to Java source.