g13dl differences and/or transforms a multivariate time series. It is intended to be used prior to g13dd to fit a vector autoregressive moving average (VARMA) model to the differenced/transformed series.


public static void g13dl(
	int k,
	int n,
	double[,] z,
	string[] tr,
	int[] id,
	double[,] delta,
	double[,] w,
	out int nd,
	out int ifail
Visual Basic
Public Shared Sub g13dl ( _
	k As Integer, _
	n As Integer, _
	z As Double(,), _
	tr As String(), _
	id As Integer(), _
	delta As Double(,), _
	w As Double(,), _
	<OutAttribute> ByRef nd As Integer, _
	<OutAttribute> ByRef ifail As Integer _
Visual C++
static void g13dl(
	int k, 
	int n, 
	array<double,2>^ z, 
	array<String^>^ tr, 
	array<int>^ id, 
	array<double,2>^ delta, 
	array<double,2>^ w, 
	[OutAttribute] int% nd, 
	[OutAttribute] int% ifail
static member g13dl : 
        k : int * 
        n : int * 
        z : float[,] * 
        tr : string[] * 
        id : int[] * 
        delta : float[,] * 
        w : float[,] * 
        nd : int byref * 
        ifail : int byref -> unit 


Type: System..::..Int32
On entry: k, the dimension of the multivariate time series.
Constraint: k1.
Type: System..::..Int32
On entry: n, the number of observations in the series, prior to differencing.
Constraint: n1.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: _kmaxk
On entry: z[i,t] must contain, zit, the ith component of Zt, for i=1,2,,k and t=1,2,,n.
  • if tr[i-1]="L", z[i,t]>0.0;
  • if tr[i-1]="S", z[i,t]0.0, for i=0,1,,k-1 and t=0,1,,n-1.
Type: array<System..::..String>[]()[][]
An array of size [k]
On entry: tr[i-1] indicates whether the ith time series is to be transformed, for i=1,2,,k.
No transformation is used.
A log transformation is used.
A square root transformation is used.
Constraint: tr[i-1]="N", "L" or "S", for i=1,2,,k.
Type: array<System..::..Int32>[]()[][]
An array of size [k]
On entry: the order of differencing for each series, d1,d2,,dk.
Constraint: 0id[i]<n, for i=0,1,,k-1.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: _kmaxk
Note: the second dimension of the array delta must be at least max1,d, where d=maxid[i-1].
On entry: if id[i-1]>0, then delta[i-1,j-1] must be set equal to δij, for j=1,2,,di and i=1,2,,k.
If d=0, then delta is not referenced.
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, dim2]
Note: dim1 must satisfy the constraint: _kmaxk
Note: the second dimension of the array w must be at least n-d, where d=maxid[i-1].
On exit: w[i-1,t-1] contains the value of wi,t+d, for i=1,2,,k and t=1,2,,n-d.
Type: System..::..Int32%
On exit: the number of differenced values, n-d, in the series, where d=maxid[i-1].
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).


For certain time series it may first be necessary to difference the original data to obtain a stationary series before calculating autocorrelations, etc. This method also allows you to apply either a square root or a log transformation to the original time series to stabilize the variance if required.
If the order of differencing required for the ith series is di, then the differencing operator is defined by δiB=1-δi1B-δi2B2--δidiBdi, where B is the backward shift operator; that is, BZt=Zt-1. Let d denote the maximum of the orders of differencing, di, over the k series. The method computes values of the differenced/transformed series Wt=w1t,w2t,,wktT, for t=d+1,,n, as follows:
wit=δiBzit*,  i=1,2,,k
where zit* are the transformed values of the original k-dimensional time series Zt=z1t,z2t,,zktT.
The differencing parameters δij, for i=1,2,,k and j=1,2,,di, must be supplied by you. If the ith series does not require differencing, then di=0.


Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Wei W W S (1990) Time Series Analysis: Univariate and Multivariate Methods Addison–Wesley

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (KMAX) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry,k<1,
On entry,id[i-1]<0, for some i=1,2,,k,
orid[i-1]n, for some i=1,2,,k.
On entry,at least one of the first k elements of tr is not equal to "N", "L" or "S".
On entry, one or more of the elements of z is invalid, for the transformation requested; that is, you may be trying to log or square root a series, some of whose values are negative.
An error occured, see message report.
Invalid Parameters value
Invalid dimension for array value
Negative dimension for array value
Invalid Parameters value


The computations are believed to be stable.

Parallelism and Performance


Further Comments

The same differencing operator does not have to be applied to all the series. For example, suppose we have k=2, and wish to apply the second-order differencing operator 2 to the first series and the first-order differencing operator  to the second series:
w1t=2z1t=1-B2z1t=1-2B+B2z1t,   andw2t=z2t=1-Bz2t.
Then d1=2,d2=1, d=maxd1,d2=2, and


A program to difference (non-seasonally) each of two time series of length 48. No transformation is to be applied to either of the series.

Example program (C#): g13dle.cs

Example program data: g13dle.d

Example program results: g13dle.r

See Also