RATS 10.1
RATS 10.1

Instructions /

DIFFERENCE Instruction

Home Page

← Previous Next →

DIFFERENCE( options )   series start end newseries newstart

Takes a combination of regular \(\left( {{X_t} - {X_{t - 1}}} \right)\) and seasonal \(\left( {{X_t} - {X_{t - s}}} \right)\) differences or a fractional difference of series. It can also extract the mean from or standardize a series. Use FILTER for more general linear filtering.

Wizard

The capabilities of the DIFFERENCE instruction are also available using the Data/Graphics—Differencing Wizard.

Parameters

series

source series

start, end

range to transform (by default, maximum range of series allowing for required lags)

newseries

result series, by default, series

newstart

start for newseries, by default start

Options

DIFFERENCES=number of regular differences [1 if no SDIFFS]

SDIFFS=number of seasonal differences [0]

SPAN=span for seasonal differences [CALENDAR seasonal]

Use these to specify the differencing operators to apply. The default, if you use neither option, is a single regular difference (DIFFERENCES=1). If you use the SDIFFERENCES option, DIFFERENCES defaults to zero. So, if you want to use a combination of regular and seasonal, you must use both options.
 

FRACTION=d (the fractional differencing parameter) [unused]

PADDING=padding value for out-of-sample observations [0.0]

To do fractional differencing, use the FRACTION option (which can also be called D) to supply a value for the fractional differencing parameter "d". Fractional differencing is an infinite filter in the frequency domain, so finite real-valued data must be padded at either end before the filter can be computed. You can use the PADDING option to supply the value to be used to pad the data--normally this would be the mean value of the series being filtered. The default value of zero is appropriate for a series with a zero mean.

 

CENTER/[NOCENTER]

STANDARDIZE/[NOSTANDARDIZE]

The CENTER option centers the series by subtracting its mean from each observation \({Y_t} = {X_t} - \bar X\). STANDARDIZE subtracts off the mean and divides by the standard deviation \({Y_t} = \left( {{X_t} - \bar X} \right)/s\) to make a series with mean 0 and variance 1. If you use one of these with the DIFFERENCES or SDIFFERENCES options, it will be applied to the results of the differencing operation. If you use one of these with the FRACTION option, the centering or standardization will be done first.

Description

If d=regular differences and e=seasonal differences, and s=span, and L represents the lag (or backshift) operator, DIFFERENCE computes

 

\({Y_t} = {\left( {1 - L} \right)^d}\,{\left( {1 - {L^s}} \right)^e}\,{X_t}\)

      

For frequencies defined in terms of the number of periods per year, SPAN defaults to the CALENDAR seasonal (for example, SPAN=12 for monthly data). For frequencies like weekly and daily, where there is no clear definition of a seasonal span, SPAN defaults to 1.

Variables Defined

%NOBS

number of observations (if CENTER or STANDARDIZE) (INTEGER)

%MEAN

sample mean (if CENTER or STANDARDIZE) (REAL)

%VARIANCE

sample variance (if STANDARDIZE) (REAL)

Examples

diff y / dy

diff r / dr

 

first differences the two variables, producing DY and DR.


 

diff(center) sunspots / cspots

 

removes the mean from SUNSPOTS to create CSPOTS.

 

 

diff(diffs=2) y_hp / ddy_hp


does two differences to create DDY_HP.


 

diff(sdiffs=1) sbl / dy

diff(sdiffs=1) ft  / gt


does seasonal differences, creating DY and GT.


 

difference ics / icsd

@rgse icsd

diff(d=-.11) icsd / icsdf

 

First differences a series, then estimates a fractional differencing parameter and uses it to fractionally difference the original series. (The original series was differenced 1, then it gets the d parameter of -.11, so the net effect is differencing with d=.89).

Notes

The instruction BOXJENK includes the DIFFS, SDIFFS and SPAN options which allow you to use the undifferenced form of the dependent variable in the estimation procedure. BOXJENK handles the differencing itself prior to estimating the ARMA parameters, then rewrites the estimated equations in terms of the original dependent variable.

 

If you estimate a regression on a differenced series (whether with BOXJENK or LINREG or any other instruction), and want the equivalent equation using the original series, use the instructions MODIFY and VREPLACE.

 

For instance, the following

 

diff m1nsa / m11diff

linreg(define=diffeq) m11diff

# constant m11diff{1 to 12}

modify diffeq

vreplace m11diff with m1nsa diff 1

 

estimates a twelve lag autoregression on the first difference of M1NSA, then recasts the equation DIFFEQ in terms of M1NSA itself by substituting out M11DIFF.

 


Copyright © 2025 Thomas A. Doan