Title: A Demo of STAMP
1GiveWin STAMP Demo
October 9, 2002 Charlie Hallahan
2GiveWin overview
GiveWin provides an interface to empirical
econometric modelling. It is a menu-driven
program, with an advanced text editor for
results. It can accept a range of data input
formats from disk, or by copy and paste from
other Windows programs, and it offers an
extensive range of data transformations using
either a calculator or algebra. These
facilitate the creation of lags and dummy
variables. It focuses on graphical analyses,
providing a Graphics dialog to create the usual
scatter plots with many bivariate regression
options and time series. It has a range of
descriptive graphics to show histograms and
densities, QQ plots, correlograms, and spectra.
These can be edited on screen, saved in a variety
of formats, and input to word processors. GiveWi
n acts as the front-end to other modules, such as
TSP, STAMP, PcGive, supplying data input,
taking their output and graphics.
3GiveWin overview
When running for the first time, double click on
the GiveWin icon and then double click on the
STAMP icon. From then on, it is only necessary
to click on the STAMP icon. After the data
is read in and preliminary graphics and
transformations are performed in GiveWin, click
on Modules/STAMP menu...
4GiveWin overview
GiveWin data file (.IN7/.BN7) The information
file, with an (.IN7) extension, holds information
about the data set and is accompanied by a
binary data file which holds the actual data,
with a .BN7 extension. Variables in an .IN7
file can have different sample periods,.but the
largest sample will be used (missing
observations get the missing values, -9999.99 or
NaN). The .BN7 file which holds the actual data
is binary, so is not human readable. Data are
stored in double precision, taking 8 bytes per
observation. The amount of data in the
.IN7/.BN7 files is only limited by available disk
space. Results Window - All output is written
to the Results Window can be saved.
5GiveWin overview
Filenames their extensions If the basic
dataset is called M1UKQ, then the GiveWin
information binary data files are called
M1UKQ.IN7 M1UKQ.BN7 respectively the default
Results storage file is M1UKQ.OUT the algebra
storage file M1UKQ.ALG and
batch files M1UKQ.FL. Graph files can be saved
in encapsulated Postscript (.EPS), Postscript
(.PS), Windows metafiles (.WMF), enhanced
metafiles (.EMF), and GiveWin graphics (.GWG),
of which the last can be read by GiveWin for
further editing.
6GiveWin overview
Algebra commands Used to transform variables.
Algebra commands can be saved, reloaded,
edited. GiveWin Batch Language Can load data,
append results, implement algebra and save STAMP
models in batch files. Useful for saving and
later rerunning complicated models
developed interactively.
7GiveWin overview - Tutorial Dataset
Start with File/Open Data File and select
the tutorial dataset DATA.IN7.
8GiveWin overview - Tutorial Dataset
Open data files ?
Results window ?
Currently active database ?
9GiveWin overview - Tutorial Dataset
Clicking on the icon for a data file opens
a spreadsheet view ?
10GiveWin overview - Tutorial Dataset
Double-clicking on a variable name opens
a Variable Description ? view Data values can
be copied/ cut/pasted in the spreadsheet. Double-
clicking on a data value allows the value to
be edited.
11GiveWin overview - GiveWin Graphics
Graphics is the first choice on the Tools menu
Select the variables to be graphed and click on
the double-arrow key to move them to the
Selection box. To get a simple time-plot, either
click on the Actual values plot box along the
bottom or on the first icon on the left along the
top.
12GiveWin overview - GiveWin Graphics
For a complete list of possible graphs, click on
the Next Choose graph box at the bottom right.
The default is Actual series / One or more series
against time.
13GiveWin overview - GiveWin Graphics
Multiple graphs can be created in either the same
or separate windows. Clicking again on the
Graphics icon or on the toolbar, select CONS
INC again and (YX) Scatterplot. The first
variable selected is the Y variable.
Double-clicking on the scatterplot brings up a
Graphics Properties window. Click on the
Regression,Scale tab and increase the Regression
Number to 1.
14GiveWin overview - GiveWin Graphics
This adds a linear regression line to the scatter
plot. With the Graphics window the active
window, clicking on the Print icon sends the
graph to the printer. The graph can also be saved
in various formats (as mentioned before).
15GiveWin overview - GiveWin Calculator
Clicking on either the Calculator icon or on
Tools/Calculator brings up the
Calculator window. Click on a variable, such as
CONS, then on an operation, such as the diff
button, accept the default lag of 1 for
diff(cons,1), and the default name of DCONS.
The calculator generates Algebra code, which is
logged to the Results window.
16GiveWin overview - GiveWin Algebra
Clicking on either the Algebra icon or on
Tools/Algebra brings up the Algebra
window. Expressions can be typed into the Algebra
code window. GiveWin and STAMP are
case- sensitive. Existing variable names in the
database can be pasted into the expressions
by double clicking on the names in the window on
the right. A complete list of available function
appears in a scrollable box on the bottom
left. Algebra code can be saved and reloaded
later. It is best to store the algebra code and
re-execute it each time the database is loaded
in case the data has been changed.
17GiveWin overview - GiveWin Toolbar
18GiveWin overview - GiveWin Manual
The GiveWin manual contains Tutorial chapters
on - Graph Editing, Graphics, Data Input and
Output, Data Transformation. There are also
chapters on - GiveWin Statistics - GiveWin
file formats - Algebra Language - Batch
Language - GiveWin graphics - GiveWin data
management
19 STAMP Overview
STAMP is a menu-driven system designed to model,
describe and predict time series. It is based
on structural time series models. These models
are set up in terms of components such as
trends, seasonals and cycles, which have a direct
interpretation. Estimation is carried out using
state space methods and Kalman filtering The
help system is context sensitive, and provides
hyperlinks to other help information by clicking
with the mouse on underlined topics (the arrow
will turn to a hand). STAMP interfaces with
GiveWin, which handles data loading, data
transformations (using either a calculator or
algebra), shows graphical output, and provides
results editing in its Results window. The
data, algebra, and results can be saved on disk
in database, algebra, and results files
respectively.
20STAMP Overview
At the top of the STAMP screen is a menu bar,
which gives access to pull-down menus on
clicking, and a toolbar with icons, that when
clicked, jump to the specific operation. The
function of the icons is shown in the status bar.
If STAMP requires information to perform a
task, it will display a dialog with
multiple-selection list boxes, in which you can
enter the required information (or modify the
suggested defaults). The information available
in separate help sections explains how to access
each menu and fill in the associated dialogs
using the keyboard and mouse.
21STAMP Tutorial - Graphics
First open the STAMP tutorial data set,
Energy.in7, in GiveWin then start
STAMP from GiveWin
The dataset contains data on 8 variables
related to quarterly energy consumption in the UK.
22STAMP Tutorial - Graphics
Comparing graphs of the variable ofuGAS and its
log, ofuGASl, we see that the seasonality is much
more constant after logging the data.
23STAMP Tutorial - Data Transformations
Open the EXCH data set consisting of daily
exchange rates of the US dollar against the
pound, yen, deutschmark, and Swiss franc. Well
use the Calculator to create the absolute value
of the logged first differences of the variable
Pound and look at the generated Algebra
code. Click on the variable Pound, then the log
Next click on LPound and the
diff button and accept the default name LPound
button to create DLPound.
24STAMP Tutorial - Data Transformations
Finally, click on the variable DLPound and scroll
down the function list to the function fabs to
create absDLPound.
The generated Algebra code is written in the
Results window.
25STAMP Tutorial - Data Transformations
Well now look at a time plot of absDLPound along
with a cubic spline fit using an automatic
bandwidth selection. In the Graphics dialog,
double click on absDLPound and select
Scatterplot as the plot type. With just a single
variable selected, it becomes the Y variable and
time is the X variable.
26STAMP Tutorial - Univariate Modelling
Using the ENERGY data set, well look at the
Model and Test menus in STAMP. Well begin by
graphing ofuCOAL, quarterly consumption of coal
by Other final users. There is a clear
downward trend and seasonality, which becomes
more constant when the data is logged.
27STAMP Tutorial - Univariate Modelling
In STAMP, use the Model menu to specify a
structural time series model and the Test menu
for model evaluation.
The first step is to Formulate the model.
28STAMP Tutorial - Univariate Modelling
With a univariate model, we need only double
click on a single variable, ofuCOALl, to serve as
the dependent Y variable. Clicking on OK brings
up the Select Components dialog. The default
setting is for Harveys Basic Structural Model
(BSM). This model has a trend with Stochastic
Level and Stochastic Slope, a Trigonometric
Seasonal, and an Irregular term.
29STAMP Tutorial - Univariate Modelling
Clicking on Finish brings up the Estimate Model
dialog. The Estimation sample and a Holdout
sample (designated as Less forecasts) can be
specified here. The Results window shows that
convergence is very strong.
30STAMP Tutorial - Univariate Modelling
The only parameters in the model are the
disturbance variances. Of interest is if any of
the variances are 0, i.e., can a component be
treated as fixed instead of stochastic. In this
example, the results indicate that the
seasonality is fixed.
Well go over these diagnostic statistics later.
seasonality is fixed ?
31STAMP Tutorial - Univariate Modelling
Note that p-values are not given for the
diagnostic statistics. For example, the Box-Ljung
Q-statistic has a value of 2.6424 and is
asymptotically distributed as a chi-square with 6
degrees of freedom. To find the p-value in
GiveWin, use Tools/Tail Probability, select
Chi2(n1) and enter 6 for n1 and the
value of the test statistic in value. The
p-value is then given as 0.8522 in the
Results window.
32STAMP Tutorial - Univariate Modelling
Evaluating Testing the Model The Test menu
has six dialogs
Further output shows estimates for the final
state vector.
33STAMP Tutorial - Univariate Modelling
Since the data in this example is logged, the
Anti-log analysis option is appropriate.
So, for example, the slope can be interpreted as
a growth rate, -2.74 per year. The seasonals can
be interpreted as multiplicative factors for the
trend, so that, for example, consumption of coal
is, on average, 31 higher in the winter, Seas 1.
34STAMP Tutorial - Univariate Modelling
Component graphics The information provided in
the Component graphics is fundamental to the
interpretation of the model. The default contains
the most useful plots. The smoothed estimates of
the components use all the data in the
sample. This is sometimes referred to as signal
extraction.
Note how the seasonal factors are constant.
35STAMP Tutorial - Univariate Modelling
Residuals graphics Diagnostic checking of the
residuals of the model.
The default graphs the residuals and their
correlogram and write diagnostic tests in the
Results window.
36STAMP Tutorial - Univariate Modelling
Forecasting Produces out-of-sample forecasts
Forecasts begin ?
37STAMP Tutorial - Univariate Modelling
Prediction graphics Produces predictions over a
holdout sample. Define the holdout sample
at the time of estimation. Well re-estimate
withholding 12 observations (designated as Less
forecasts in the Estimate Model dialog.
38STAMP Tutorial - Univariate Modelling
The within sample predictions for 1984/Q3 and Q4
are outside the two-standard error bounds and the
next 3 predictions are not very good.
It turns out that there was a coal miners strike
in 83/3 83/4, so an intervention model is
appropriate.
39STAMP Tutorials
There are other tutorials in the STAMP manual.
There are Tutorials on Components Intervent
ion Analysis Explanatory Variables Multivaria
te Models Application in Macroeconomics
Finance Model Building Testing and Chapters
elaborating on Descriptive Statistics Statis
tical Treatment of Models Model Output
40Selection of Components
- Selection of components is the core of
Structural Time Series models - Initial
Specification usually based on prior information.
For example, whether to include a seasonal
component or not. Whether to apply a log
transformation or not to stabilize seasonal
variation. - Estimation or convergence problems
usually evidence of a poorly specified model. -
Parameters usually consist of just error
variances. Variance ratios more interpretable
than the variance estimates themselves, e.g.,
signal-to-noise ratios. A variance
estimate of zero indicates a deterministic rather
than stochastic component. - Diagnostics and
goodness-of-fit measures available through the
Test/Residuals menu. - Predictive testing
available with a holdout sample.
41Trend
Trend is the long-run component of the series and
indicates the general direction the series is
moving. There are two parts to the trend ?
Level - the actual values of the trend ?
Slope - may or may not be present Well use the
sample dataset USYCIMP.IN7 which consists of
quarterly US macroeconomic data, which are
seasonally adjusted
42Local Level Model
The local level model consists of a random
disturbance around an underlying level that moves
up and down, but without any particular direction.
Well start with the rate of inflation, which is
denoted as Dp first difference of the logged
price level, p.
43Local Level Model
The graph exhibits the characteristics of a local
level model.
44Local Level Model
To estimate a local level model for Dp, click on
Model/Formulate and select Dp as the variable.
Then in the Select Components dialog, select No
slope and No Seasonal.
45Local Level Model
Note that the estimated signal-to-noise ratio is
23.
? estimated signal-to-noise ratio
46Local Level Model
Various plots are available through the
Test/Components graphics dialog. To see forecasts
of the components, just the level in this case,
use the Test/Forecasts dialog. Note that the
forecasts of the level is a straight line
representing the final estimate of the level
since no slope for the trend was assumed.
47Statistical Analysis of the Local Level Model
48Statistical Analysis of the Local Level Model
The Components dialog allows estimation of the
trend throughout the sample using all the
observations. This is known as signal extraction
or smoothing. The smoothed estimates of the
level are what is depicted in the lower graph on
page 8. The filtered estimates are based only
on previous observations.
49Statistical Analysis of the Local Level Model
The correlogram clearly shows that Dp is
nonstationary and ?Dp is stationary. Note,
however, that in contrast to Box-Jenkins ARIMA
modeling, with structural time series modeling it
is not necessary to take first differences in
order to induce stationarity.
50Local Linear Trend and Smooth Trend
The local linear trend model specifies both the
level and slope to be stochastic. The forecast
function is a straight line with an upward or
downward slope, depending on the final state
estimates.
51Local Linear Trend and Smooth Trend
The various specifications of the trend in the
Components dialog are
52Local Linear Trend and Smooth Trend
Important special cases ? Local level or
random walk plus noise - the trend is a random
walk. Specify Stochastic level and
No slope. ? Local level with
drift - Stochastic level and Fixed
slope. ? Smooth trend -
Fixed level and Stochastic slope. Plots can
sometimes suggest which trend specification to
use. A value of zero for a particular error term
variance would indicate a fixed component.
However, tests of variances are not
straightforward. When several specifications
pass the diagnostic tests, the behavior of the
forecast function sometimes helps to decide on a
specification. Stochastic slopes may lead to
unstable forecasts. Start with the most general
model that seems to apply.
53Seasonal Component
There are four options in STAMP for specifying
the seasonal component. The seasonal pattern
becomes deterministic when the seasonal variance
parameter is set to zero. For example,
estimating the BSM for the logarithm of income,
y, in the file UKCYP.IN7 leads to the output
on the following page. Additional output is
obtained with Test/Further output and
activating Anti-log analysis and State and
regression output.
54Seasonal Component
55Seasonal Component
Conclusions from the output ? seasonal
variance is non-zero, indicating there are
changes in the seasonal pattern. ? the state
has s-1 elements to capture seasonality. These
terms are not directly interpretable, but
STAMP transforms them into monthly or quarterly
effects. Note that the seasonal effects sum
to zero. ? if the Anti-log analysis option is
selected, then STAMP presents the seasonal
effects as factors of proportionality by which to
multiply the other components to get the
systematic part of the series. For y log(UK
income), the seasonal factors are 0.984,
1.000, 1.004, and 1.012. So, for example, UK
income is on average 1.2 higher in the
winter. ? the statistical significance of the
seasonal component is given by the chi-square
test, which, in this case, has a p-value of
0.0249 - indicating a significant seasonal
component for y.
56Seasonal Adjustment
Once a seasonal component has been estimated, an
optimal model-based seasonally adjusted series
can be obtained by subtracting off the seasonal
component. In the Test/Components graphics
dialog, click on the Seasonally adjusted box
?
57Seasonal Adjustment
Original Data
Seasonally-adjusted Data