Example 1: Difference

This example uses the Airline Data (Box and Jenkins 1976, p. 531) consisting of the monthly total number of international airline passengers from January 1949 through December 1960. Difference is used to compute ...

W_t = \Delta _1 \Delta _{12} Z_t = \left( {Z_t - Z_{t - 12} } \right) - \left( {Z_{t - 1} - Z_{t - 13} } \right)

for t= 14, 15, ...,24.

using System;
using Imsl.Stat;

public class DifferenceEx1
{
	public static void  Main(String[] args)
	{
		
		int[] periods = new int[]{1, 12};
		int nLost;
		double[] z = new double[]{112.0, 118.0, 132.0, 129.0, 121.0, 
									 135.0, 148.0, 148.0, 136.0, 119.0,
									 104.0, 118.0, 115.0, 126.0, 141.0,
									 135.0, 125.0, 149.0, 170.0, 170.0,
									 158.00, 133.0, 114.0, 140.0};
		
		Difference diff = new Difference();
		double[] output = diff.Compute(z, periods);
		nLost = diff.ObservationsLost;
		
		Console.Out.WriteLine("Observations Lost = " + nLost);
		
		for (int i = 0; i < output.Length; i++)
			Console.Out.WriteLine(output[i]);
	}
}

Output

Observations Lost = 13
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
5
1
-3
-2
10
8
0
0
-8
-4
12

Link to C# source.