JMSLTM Numerical Library 5.0.1

com.imsl.stat
Class Difference

java.lang.Object
  extended by com.imsl.stat.Difference
All Implemented Interfaces:
Serializable, Cloneable

public class Difference
extends Object
implements Serializable, Cloneable

Differences a seasonal or nonseasonal time series.

Class Difference performs m = periods.length successive backward differences of period s_i = {rm {periods}} 
  [i - 1] and order d_i = {rm {orders}} [i - 1] ,, 
  {rm{for}} ,, i = 1, dots, m on the n = z.length observations left{ Z_t right} ,, 
  {rm{for}} ,, t = 1, 2, dots, n.

Consider the backward shift operator B given by

B^kZ_t = Z_{t-k}

for all k. Then, the backward difference operator with period s is defined by the following:

Delta _s Z_t  = left( {1 - B^s } right)Z_t 
  = Z_t  - Z_{t - s} ,,,,,,{rm{for}},s ge 0

Note that B_sZ_t and Delta_sZ_t are defined only for t = (s + 1), dots, n. Repeated differencing with period s is simply

Delta _s^d Z_t  = left( {1 - B^s } right)^d 
  Z_t  = sumlimits_{j = 0}^d {frac{{d!}}{{j!left( {d - j} right)!}}} 
  left( { - 1} right)^j B^{sj} Z_t

where d ge 0 is the order of differencing. Note that

Delta _s^d Z_t

is defined only for t = (sd + 1), dots, n.

The general difference formula used in the class Difference is given by

W_T = left{ begin{array}{ll} rm{NaN} & 
  {rm for},, t = 1, ldots, n_L  \ Delta _{s_1 }^{d_1 } 
  Delta _{s_2 }^{d2} ldots Delta _{s_m }^{d_m } Z_t & {rm for},, 
  t = n_L  + 1,ldots, n end{array} right.

where n_L represents the number of observations "lost" because of differencing and NaN represents the missing value code. Note that

n_L  = sumlimits_j {s_j d_j }

A homogeneous, stationary time series can be arrived at by appropriately differencing a homogeneous, nonstationary time series (Box and Jenkins 1976, p. 85). Preliminary application of an appropriate transformation followed by differencing of a series can enable model identification and parameter estimation in the class of homogeneous stationary autoregressive moving average models.

See Also:
Example 1, Example 2, Serialized Form

Constructor Summary
Difference()
          Constructor for Difference.
 
Method Summary
 double[] compute(double[] z, int[] periods)
          Computes a Difference series.
 void excludeFirst(boolean exclude)
          If set to true, the observations lost due to differencing will be excluded.
 int getObservationsLost()
          Returns the number of observations lost because of differencing the time series.
 void setOrders(int[] orders)
          Sets the orders for the Difference object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Difference

public Difference()
Constructor for Difference.

Method Detail

compute

public final double[] compute(double[] z,
                              int[] periods)
                       throws IllegalArgumentException
Computes a Difference series.

Parameters:
z - a double array containing the time series.
periods - an int array containing the periods at which z is to be differenced.
Returns:
a double array containing the differenced series.
Throws:
IllegalArgumentException

excludeFirst

public void excludeFirst(boolean exclude)
If set to true, the observations lost due to differencing will be excluded. The differenced series will be the length of the number of observations minus the number of observations lost. If set to false, the observations lost due to differencing will be set to NaN (Not a number) and included in the differenced series. The default is to set the lost observations to NaN.

Parameters:
exclude - a boolean specifying whether or not to exclude lost observations due to differencing.

getObservationsLost

public int getObservationsLost()
Returns the number of observations lost because of differencing the time series. Note that the compute method must be invoked first before invoking this method. Otherwise, the return value is 0.

Returns:
an int containing the number of observations lost because of differencing the time series z.

setOrders

public void setOrders(int[] orders)
Sets the orders for the Difference object

Parameters:
orders - an int array of length equal to length of periods, containing the order of each difference given in periods. The elements of orders must be greater than or equal to 0.

JMSLTM Numerical Library 5.0.1

Copyright © 1970-2008 Visual Numerics, Inc.
Built July 8 2008.