This example is the same as example 2 but now method 3 with the optimum model parameters p = 3, q = 2, s = 1, d = 0
from Example 2 is chosen for outlier detection and forecasting.
using System; using Imsl.Stat; public class AutoARIMAEx3 { public static void Main(String[] args) { int nOutliers; double aic, RSE, constant; int[] optimumModel; int[,] outlierStatistics; double[] outlierForecast, ar, ma; double[] psiWeights, probabilityLimits; double[] x = { 12.8, 12.2, 11.9, 10.9, 10.6, 11.3, 11.1, 10.4, 10.0, 9.7, 9.7, 9.7, 11.1, 10.5, 10.3, 9.8, 9.8, 10.4, 10.4, 10.0, 9.7, 9.3, 9.6, 9.7, 10.8, 10.7, 10.3, 9.7, 9.5, 10.0, 10.0, 9.3, 9.0, 8.8, 8.9, 9.2, 10.4, 10.0, 9.6, 9.0, 8.5, 9.2, 9.0, 8.6, 8.3, 7.9, 8.0, 8.2, 9.3, 8.9, 8.9, 7.7, 7.6, 8.4, 8.5, 7.8, 7.6, 7.3, 7.2, 7.3, 8.5, 8.2, 7.9, 7.4, 7.1, 7.9, 7.7, 7.2, 7.0, 6.7, 6.8, 6.9, 7.8, 7.6, 7.4, 6.6, 6.8, 7.2, 7.2, 7.0, 6.6, 6.3, 6.8, 6.7, 8.1, 7.9, 7.6, 7.1, 7.2, 8.2, 8.1, 8.1, 8.2, 8.7, 9.0, 9.3, 10.5, 10.1, 9.9, 9.4, 9.2, 9.8, 9.9, 9.5, 9.0, 9.0, 9.4, 9.6, 11.0, 10.8, 10.4, 9.8, 9.7, 10.6, 10.5, 10.0, 9.8, 9.5, 9.7, 9.6, 10.9, 10.3, 10.4, 9.3, 9.3, 9.8, 9.8, 9.3, 8.9, 9.1, 9.1, 9.1, 10.2, 9.9, 9.4 }; double[] exactForecast = { 8.7, 8.6, 9.3, 9.1, 8.8, 8.5 }; int[] times = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135 }; AutoARIMA autoArima = new AutoARIMA(times, x); autoArima.CriticalValue = 3.8; autoArima.Compute(3, 2, 1, 0); autoArima.Forecast(6); nOutliers = autoArima.NumberOfOutliers; aic = autoArima.AIC; optimumModel = autoArima.GetOptimumModelOrder(); outlierStatistics = autoArima.GetOutlierStatistics(); RSE = autoArima.ResidualStandardError; outlierForecast = autoArima.GetForecast(); psiWeights = autoArima.GetPsiWeights(); probabilityLimits = autoArima.GetDeviations(); constant = autoArima.Constant; ar = autoArima.GetAR(); ma = autoArima.GetMA(); Console.Out.WriteLine("\nMethod 3: Specified ARIMA model"); Console.Out.WriteLine(); Console.Out.WriteLine( "Optimum Model: p={0,1:d}, q={1,1:d}, s={2,1:d}, d={3,1:d}", optimumModel[0], optimumModel[1], optimumModel[2], optimumModel[3]); Console.Out.WriteLine("\nNumber of outliers:{0,2:d}\n", nOutliers); Console.Out.WriteLine("Outlier statistics:"); Console.Out.WriteLine(" Time Type"); for (int i = 0; i < nOutliers; i++) Console.Out.WriteLine("{0,5:d}{1,8:d}", outlierStatistics[i, 0], outlierStatistics[i, 1]); Console.Out.WriteLine("\nAIC:{0,13:f6}", aic); Console.Out.WriteLine("RSE:{0,13:f6}", RSE); Console.Out.WriteLine(); Console.Out.WriteLine(" Parameters"); Console.Out.WriteLine(" constant:{0,11:f6}", constant); for (int i = 0; i < ar.Length; i++) Console.Out.WriteLine(" ar[{0,2:d}]:{1,13:f6}", i, ar[i]); for (int i = 0; i < ma.Length; i++) Console.Out.WriteLine(" ma[{0,2:d}]:{1,13:f6}", i, ma[i]); Console.Out.WriteLine("\n\n * * * Forecast Table * * *"); Console.Out.WriteLine(" Exact forecast limits psi"); for (int i = 0; i < outlierForecast.Length; i++) Console.Out.WriteLine("{0,7:f4}{1,11:f4}{2,11:f4}{3,11:f4}", exactForecast[i], outlierForecast[i], probabilityLimits[i], psiWeights[i]); } }
Method 3: Specified ARIMA model Optimum Model: p=3, q=2, s=1, d=0 Number of outliers: 1 Outlier statistics: Time Type 109 0 AIC: 408.108176 RSE: 0.412456 Parameters constant: 0.554459 ar[ 0]: 1.940615 ar[ 1]: -1.898025 ar[ 2]: 0.897791 ma[ 0]: 1.115803 ma[ 1]: -0.911902 * * * Forecast Table * * * Exact forecast limits psi 8.7000 9.1085 0.8084 0.8248 8.6000 9.1715 1.0479 0.6145 9.3000 9.5039 1.1597 0.5248 9.1000 9.7677 1.2349 0.5926 8.8000 9.7051 1.3245 0.7056 8.5000 9.3817 1.4421 0.7157Link to C# source.