Command Reference : Function Reference : Function Reference: D
  
 
d
Difference (time-series) functions for series.
First difference function for series.
Syntax: d(x)
x: series
Return: series
Computes where is the lag operator.
n-th order difference function for series.
Syntax: d(x, n)
x: series
n: integer, series
Return: series
Computes where is the lag operator.
If n is not an integer, the integer floor will be used.
n-th order difference function for series with an s-th seasonal difference.
Syntax: d(x, n, s)
x: series
n: integer
s: integer
Return: series
Computes where is the lag operator.
If n or s are not integers, the integer floors and will be used.
These functions are panel aware.
Examples
The code below produces a graph of a random walk process and its first difference:
wfcreate u 1000
series y = 0
smpl @first+1 @last
series y = y(-1) + nrnd
smpl @all
group g y d(y)
g.line
The first line creates an unstructured workfile containing a thousand observations. Lines two through five create the series y containing the realization of a random walk process initialized at 0. Lines six and seven graphs y and d(y) together.
Cross-references
See also dlog.