RATS 8 Additional Topics
RATS 8 Additional Topics
RATS 8 Additional Topics
ADDITIONAL TOPICS
Additional Topics
This PDF supplement provides additional information on various aspects of using
rats, including more information on the rats interface, details on the supported
data file formats, coverage of some additional topics in econometrics, documentation
on several little-used instructions no longer included in the Reference Manual, and
more.
2. Data Formats 27
2.1 FORMAT=BINARY (Native binary format)..................................................................28
2.2 FORMAT=CDF (Comma delimited text formats).........................................................29
2.3 FORMAT=CITIBASE/FORMAT=DRI...........................................................................30
2.4 FORMAT=CRSP (CRSP Files)...................................................................................31
2.5 FORMAT=DBF (dBase Files)......................................................................................32
2.6 FORMAT=DIF (Data Interchange Format)..................................................................33
2.7 FORMAT=DTA (Stata Native Format).........................................................................34
2.8 FORMAT=FAME (FAME Databases)..........................................................................35
2.9 FORMAT=FORTRAN string........................................................................................37
2.10 FORMAT=FREE (Delimited text format, no names/dates)........................................41
2.11 FORMAT=HAVER (Haver Analytics native format)...................................................42
2.12 FORMAT=HTML (HTML table)..................................................................................43
2.13 FORMAT=MATLAB (MATLAB binary format)............................................................44
2.14 FORMAT=ODBC (ODBC/SQL databases)...............................................................46
2.15 FORMAT=PORTABLE (RATS Portable Format).......................................................48
2.16 FORMAT=PRN (Delimited text formats)...................................................................49
2.17 FORMAT=RATS (RATS data format)........................................................................50
2.18 FORMAT=TEX (TeX table)........................................................................................51
2.19 FORMAT=TSD (Tab separated text formats)............................................................53
2.20 FORMAT=WF1 (EViews workfile format)..................................................................54
2.21 FORMAT=WKS (Lotus WKS format)........................................................................55
2.22 FORMAT=XLS/XLSX (Excel workbook)....................................................................56
3. More on Functions 57
3.1 The Sweep Family of Functions..................................................................................58
3.2 Working With Polynomials..........................................................................................60
4. Statistical Techniques 61
4.1 Polynomial Distributed Lags........................................................................................62
Example 4.1 Polynomial Distributed Lags................................................................63
Additional Topics
5. Instructions 73
5.1 Deprecated Options and Parameters..........................................................................74
5.2 Deprecated Instructions..............................................................................................77
CNTRL Tools for Controlling Interactive Procedures...........................................78
DEFAULT Changing Default Options...................................................................79
DELETE Removing Series from a RATS Data File.............................................80
EDIT Screen Data Editing....................................................................................81
INCLUDE Adding Series to a RATS Data File.....................................................83
RENAME Renaming Data File Series.................................................................85
UPDATE Altering Data on a RATS Data File.......................................................86
7. Manual Errata 99
7.1 User's Guide..............................................................................................................100
7.2 Reference Manual.....................................................................................................100
Menu Operations
Toolbar Icons
Preference Settings
Batch Mode Operation
Additional Topics
New
opens a new text window, or a new rats format data file window.
Open...
opens an existing file. Using the file-type field in the dialog box, youc an open text
files (such as rats program and procedure files), rats graph files, or rats format
data files. For text files, the new window will only be flagged as the input window
if there are no other open text windows.
Recent Files
provides a list of the most recently used files. The list is preserved from one session
to the next, so you can easily reopen files you were using in a previous session.
Close
closes the active window. rats will give you a chance to save any changes before
closing the window. If you close the input window, rats does a Clear Memory op-
eration (see next page).
Merge...
inserts the contents of an existing file into the active window.
Save
saves the entire contents of the active window to disk using the current file name
(Save will prompt you for a file name if the file hasnt been saved previously).
Save As...
saves the contents of the active window to disk, using a filename you select. If you
have text selected in the window, Save As will ask if you want to save the selected
block, or the entire window.
Export...
exports the contents of the active window to a file. This operation is supported for
most windows other than text windows (where you just use FileSave As...). Export
allows you to choose from a variety of file formats.
Page Setup...
selects a printer, and allows you to set printerspecific options.
Print
prints the contents of the active text or graph window. To print just a portion of a
text window, select the desired lines before doing Print.
Directory...
lets you change the default drive and directory for the current session.
Preferences...
customizes the behavior of the rats editor. See page page 19 for details. On Macintosh
versions, this operation is located on the rats menu.
Batch Mode
puts rats into batch mode. See page page 23.
Clear Memory
clears the current data and settings (all data series, other variables, CALENDAR and
ALLOCATE settings, etc.) from memory. Use Clear Memory (or the icon) when
you want to enter a new program, or re-execute a program from the beginning. This
does not delete any text, close any windows, or close open data files.
Exit
closes all windows and exits the rats program. rats will give you an opportunity
to save any changes before quitting. On Macintosh versions, this operation is called
Quit and is located on the rats menu.
Undo
undoes the recent changes. For example, if you have Cut a block of text, Undo will
replace the text. Undo also works with data editing windows. You can undo up
to the twenty most recent changes in each window. Note that Undo never reverses
calculationsit applies only to editing operations.
Redo
redoes the results of the most recent Undo.
Cut
for a text window, this deletes the selected text and copies it to the Clipboard. This
can also be used to delete series from a rats format file when applied to a Datafile
List window (the deleted series can be pasted to another file if desired).
Paste
copies the contents of the clipboard into the active window. Most commonly used for
copying text, you can also copy-and-paste (or cut-and-paste) series from one rats
format file to another using Datafile List windows. Note that you cannot paste
graphics into rats.
Delete
deletes the selected text (does not copy it to the clipboard).
Select All
selects every line in the window. To execute every instruction in the input window,
you can do EditSelect All (or click on the Select all icon) and hit <Enter> (or
click the Run icon).
Find...
searches for a string of text. You can search from the top of the window, or forward
or backward from the current cursor position. Turn on the Case Sensitive check
box for a case-sensitive search.
Find Next
repeats the most recent Find... operation.
Replace...
does a find-and-replace operation, locating a specified string in the active window,
and replacing it with another string.
To Lower Case
converts the selected lines to all lower-case.
Format comments
Takes the selected line(s) and turns them into a block of comments (lines prefixed
with an * that rats will ignore rather than execute as commands). The lines will
be reformatted to be of approximately uniform length. You can change this length
with the Comment Length box on the Preferences dialog box.
Comment-Out Lines
This turns the selected lines into comment lines, that will be ignored by rats
when executing instructions. This is done by adding the * symbol to the beginning
of each line.
Uncomment Lines
The opposite of the Comment-Out Lines operation, this removes the * symbols from
the beginning of the selected lines.
Indent Lines
Indents the selected lines. You can change the width of the indenting with the
Indenting box on the Preferences dialog box.
Unindent Lines
Removes indenting from the selected lines. The amount of indenting that will be
removed is the indenting amount set via the Preferences operation.
Reset List
When a rats format file window is active, this allows you to change which series
are listed, and whether the series are sorted by name.
Change Layout
allows you to customize the appearance of the window. Only applies to some types
of windows.
Series Window
brings up a window showing all the series currently in memory. From this window,
you can use the other View menu operations or the toolbar icons to graph the series,
display basic statistics, export series, edit the series, and more.
Standard Functions
opens the Function Lookup dialog box, which you can use to browse through the built-
in functions, check the function syntax, and paste a function into the input window.
Standard Variables
displays a list all of the reserved variables defined by various rats instructions.
You can view an alphabetical list of all the variables, or list variables by category.
User Variables
displays a list of all the variables defined by the user in the current session.
All Symbols
displays a list of all global variable and function names, including reserved variables
and functions defined by rats as well as user-defined variables.
The following are available when the Series Window or a rats format file window
is active. These serve the same function as the corresponding toolbar icons (see page
page 17). The last two operations apply only for a list of series in memory.
Histogram
produces a histogram plot of the selected series (can only be applied to one series
at a time).
Box Plot
produces box plots for the selected series.
Autocorrelations
produces a plot of the autocorrelations and partial autocorrelations for the series.
Statistics
produces basic descriptive statistics for the selected series
Covariance Matrix
produces a covariance\correlation matrix of the selected series
Data Table
displays the selected series as columns in a spreadsheet-style window, similar to
doing PRINT with the WINDOW option. You cannot edit series values using this data
viewdouble click on a series if you want to edit values in the series.
Trend/Seasonals/Dummies
generates trend series, seasonal and 0/1 dummies, or a series of draws from a ran-
dom normal distribution.
Transformations
provides a convenient way to do a variety of data transformations, from taking logs
or square roots to generating growth rates, and more.
Differencing
allows you to difference series using regular, seasonal, and/or fractional differences.
Filter/Smooth
implements several types of time-series filters.
Graph Settings
This generates a GRPARM instruction, allowing you to set the font, style, and size
of labels used on graphs.
Graph
generates time series graphs.
Covariance Matrix
computes a variance/covariance matrix for a set of series.
Linear Regressions
performs a variety of linear regressions, including ols, instrumental variables,
gmm, and ar1.
Dependent Variables
dependent variable models, such as probit and tobit.
Regression Tests
does hypothesis testing on the most recently completed regression.
Nonparametric Regression
provides an interface to the NPREG instruction for non-parametric regressions.
Equation/FRML definition
defines an equation or formula. For formulas, you can define the list of nonlinear
parameters.
Autocorrelations
computes regular and partial autocorrelations of a series.
Cross Correlations
computes cross correlations and covariances for a pair of series.
ARCH/GARCH
estimates univariate and multivariate arch, garch, and related models.
Exponential Smoothing
implements exponential smoothing.
VAR (Setup/Estimate)
defines and estimates var models.
VAR (Forecast/Analyze)
generates forecasts, impulse responses, variance decompositions, and historical
decompositions for vars and other multi-equation models.
CATS Cointegration
If you have version 2 of the cats cointegration analysis procedure (sold separately),
you can use this operation to execute the procedure.
Single-Equation Forecasts
generates forecasts for a single equation.
Tile Horizontal
tiles the open windows so they are all visible on the screen, using a horizontal
orientation (windows will be wider than they are tall).
Tile Vertical
tiles the open windows, using a vertical orientation (windows will generally be taller
than they are wide).
Cascade
stacks the open windows so the title bar of each window is visible.
Close All
closes all open windows. rats will give you a chance to save any changes to text
windows.
Report Windows
This displays a list of the recently generated report windows. Selecting one of these
will display the report in a new Report Window. You can use this to re-display the
formatted output produced by instructions like REPORT, LINREG, TABLE, STATIS-
TICS, and many others. From the report windows, you can copy, paste, and export
information to spreadsheet programs and other applications.
(Save) Shortcut for FileSave. Saves the contents of the active window.
(Print) Shortcut for FilePrint. Prints the contents of the active window.
(Cut) Shortcut for EditCut. Removes the selected content from the
window and copies it to the clipboard.
(Copy) Shortcut for EditCopy. Copies the selected content to the clipboard.
(Paste) Shortcut for EditPaste. Pastes content from the clipboard into
the current window.
(Find) Shortcut for EditFind. Allows you to search for text.
(Functions) This opens the Function Wizard, which displays a list of all of the
built-in functions in rats. See Section 1.2 of the User's Guide.
(Input) This designates the active (front) window as the Input window.
It is equivalent to the WindowUse for Input operation. See page
Int-7 of the Introduction for more on the Input and Output icons.
(Output) This designates the active (front) window as the Output window.
It is equivalent to the WindowUse for Output operation.
, These set up split Input and Output windows, tiled horizontally
or vertically..
(Select A
ll) Shortcut for the EditSelect All operation. Selects all the text or
items in the active window.
(Run) Runs the selected instructions, or the instruction on the cursor
line, if any (equivalent to hitting <Enter>). Disabled if the active
window is not the input window. See page Int-7 of the Introduction
for more on the Run and Stop icons.
(Stop) While rats is processing instructions, the Run icon changes to
this Stop icon. You can click on this to halt the processing of the
instructions.
(Ready/Local) Switches rats from Ready mode to Local mode. The icon will
change to Local/Ready ( ), indicating that rats is in Local
mode. Click the icon again to change back to Ready mode. You
can also hit <Ctrl>+L to switch modes. See page Int-7 of the
Introduction for details. This is omitted on Macintosh versions,
where you can just hit <Return> to insert a new line.
(Clear Mem.) This clears the memory. It is equivalent to FileClear Memory.
Graph Windows
When a graph window is active, rats will display the Save, Print, and Copy
icons described above, along with the additional icons for fixing and un-fixing the
graph proportions and for switching between color and grayscale mode. See page Int-
56 of the Introduction for details.
Series Window
See page Int-38 in the Introduction for details on the icons available when viewing
the Series Window (a list of the series stored in memory), which you can display by
selecting ViewSeries Window.
However, virtually all of the functionality of ratsdata has now been incorporated
in rats itself. So, in most cases you will probably find it easiest to just use the File
New and FileOpen operations in rats to do this kind of work.
You can use the Serial Number field at the top to store your rats serial num-
ber in the registry. This allows you to view the serial number at any time by doing
HelpAbout rats (ratsAbout rats on Macintosh). For convenience, you can also
store serial numbers for other rats products (such as the cats cointegration proce-
dures)just separate the serial numbers by semi-colon (;).
Note: in some cases, the installation program may be able to save the serial number
in the registry automatically.
The remaining fields are described on the following pages.
supply an additional search directory. So, if you have procedures you use regularly,
you may want to collect them in a specific directory, and enter the name of that direc-
tory in this field. See Section 15.2.1 of the Users Guide for details.
Procedure Library
The Procedure Library field allows you to specify a file of procedures that you want
rats to load automatically each time you start the program or clear the memory.
CATS Directory
If you have version 2.0 or later of our cats cointegration analysis procedure, enter
the directory containing your cats files here. This will allow you to use the CATS
Cointegration operation on the Statistics menu to launch the cats procedure.
Batch Output .ext
This field lets you specify the extension that is appended to output files when run-
ning in batch mode.
You can drag and drop the files one at a time, or you can drag and drop several files
simultaneously. Note that a check mark appears next to the Batch Mode operation on
the menu while rats is in batch mode. To switch back to interactive mode, just select
the Batch Mode operation again.
If you use batch mode frequently, you may want to create a copy of the Winrats icon
that will automatically start rats in batch mode. Heres how:
1. Make a copy of the Winrats program icon (see your Windows documentation or
help for details).
2. Right-click on the rats icon to display the properties dialog for the new icon.
3. Set the icon to Run minimized and click on OK.
Now, when you double click on this new icon, rats will automatically start up with
the Batch Mode switch turned on. You will need to click on the minimized icon to
open it up into a window. You can then drag and drop program files onto the window.
This will run the job and save the output to MYPROG.LIS (unless you have used File
Preferences in Winrats to change the default output filename extension). You can
include commands like this in a dos batch (.bat) file if desired.
Series Window
a window showing all of the series in memory, which can also be used to read in
and export data. Use the ViewSeries Window operation to display this window.
Report Window
a window display a rats Report, generated either by a REPORT instruction, a
WINDOW option on various other instructions, or by using the reloading a Report
Window using the Restore Report submenu on the Window menu.
Matrix Window
a window displaying the contents of an array. Opened using an MEDIT instruction
or by doing ViewAll Symbols and double-clicking on a matrix variable.
Additional Topics
RATS Instructions
data(format=binary) read series from binary into memory
store(convert=binary) copy series from binary to rats format
copy(format=binary) write series to binary file
prtdata(format=binary) write series from rats format file to binary
read(format=binary) read scalars and arrays from a binary file
write(format=binary) write scalars and arrays to binary file
ORG options are required on DATA, STORE, COPY and PRTDATA.
Interface Operations
None
Details
Binary format is the fastest way of reading and writing data, as it requires no trans-
lation from characters to numbers. It also preserves the internal representation of
all numbers. Speed, however, is the only real advantage it has over other formats. Its
disadvantages tend to outweigh this:
Because the data file is not in character form, it is very difficult to determine what
is on the file should you happen to forget.
It is impossible to change any number on the file without rewriting the entire file.
You cannot store dates or series labels on a binary file.
We dont recommend that you use BINARY format unless it's the only way available
to communicate data to another program (running on the same type of computer).
In reading binary data prepared using another program, you must be very careful to
read the data back in exactly the same way as it was written.
Real-valued data use a 64-bit representation. This is double precision, except on
machines with 64-bit single precision, like a dec Alpha.
With ORG=ROWS, rats reads (or writes) each series with a single call, so you
should use a separate fortran WRITE (READ) for each as well.
With ORG=COLS, each observation is read (written) with a single call; again you
should use a separate WRITE (READ) for each.
RATS Instructions
data(format=cdf) read series from cdf into memory
store(convert=cdf) copy series from cdf to rats format
copy(format=cdf) write series to cdf file
prtdata(format=cdf) write series from rats format file to cdf
read(format=cdf) read scalars or arrays from cdf into memory
write(format=cdf) write scalars or arrays from memory to cdf file
ORG options are required on DATA, STORE, COPY and PRTDATA.
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Details
On DATA and STORE, you can, if required, use the NOLABELS option to skip automatic
label processing and use the LEFT and TOP options to isolate the data.
See Spreadsheet and Delimited Text Formats on page Int114 of the Introduction for more
details on the format.
2.3 FORMAT=CITIBASE/FORMAT=DRI
This is a Time Series Database format available for series input, only on the Pro-
fessional versions of rats. It is the format used for the Basic Economics database
(formerly known as Citibase), which is maintained by Global Insight.
RATS Instructions
data(format=citibase) read from Basic Economics into memory
store(convert=citibase) copy series from Basic Econ. to rats format
Interface Operations
None for reading or writing data. FilePreferences sets location of files.
Details
You must use the Preferences operation on the File menu to tell rats where the data
are located on your hard disk. With that done, you can read data with
data(format=citibase,other options) start end list of series
Because the series have dates, you can use this to select a sub-sample, or allow com-
pact or expand to a different frequency (see Changing Data Frequencies on page Int104 of
the Introduction).
RATS Instructions
data(format=crsp) read series from crsp into memory
Interface Operations
None for reading or writing data.
You can use FilePreferences to set the default location of the crsp files.
Details
Your workstation must be configured with the proper set of environment variables
(CRSP_ROOT=, etc.) and you need to tell rats where the data are located. You can do
that by setting the crsp Directory setting in the FilePreferences... dialog box, or by
using an explicit OPEN CRSP instruction specifying the path in your program.
You can fetch the price, return, volume, bid and ask prices for stocks. These are done
by prefixing the crsp Permno for the stock with P for price, R for return, V for
volume, B for bid and A for ask. You can ask for any data frequency from daily to
annual, and youll get the aggregation for that frequency produced by crsp.
For example, the following will get the monthly returns for ibm (permno 12490) and
Microsoft (10107) over 1984:4 to 2004:12. Since Microsoft doesnt start trading until
1986, its returns will be nas until then.
open crsp c:\CRSP_Sample_Data\data\aiz\diz\
cal(m) 1984:4
all 2004:12
data(format=crsp) / r12490 r10107
RATS Instructions
data(format=dbf) read series from dbf into memory
store(convert=dbf) copy series from dbf to rats format
copy(format=dbf) write series to dbf file
prtdata(format=dbf) write series from rats format file to dbf
Interface Operations
Data Wizard
You can read series using Data (Other Formats) wizard on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Details
The data are read from the file based upon the field (column) names. Each record is
treated as a separate observation. If the file includes a date field as the first field,
rats will be able to make use of the date information to select a sub-sample, recog-
nize skipped observations, or allow compacting or expanding to a different frequency
(Changing Data Frequencies on page Int104 of the Introduction). The dates can either use
the dbf date field format, which codes dates as year/month/day, or be entered as a
character field with the standard codings like year:period.
For writing data, each series that you write will be a field in the database. The dBase
specification allows for at most ten characters in a field name, so longer names will
be truncated. If you ask for dates, rats will either include a date field (for daily or
weekly data), or a character field with coded dates.
Example
This reads in several series of stock return data from a dbf file:
calendar(d) 1996:1:2
allocate 2009:12:31
open data stockdat.dbf
data(format=dbf)
RATS Instructions
data(format=dif) read series from dif into memory
store(convert=dif) copy series from dif to rats format
copy(format=dif) write series to dif file
prtdata(format=dif) write series from rats format file to dif
read(format=dif) read scalars or arrays from dif into memory
report(format=dif) (with ACTION=FORMAT) write a report to dif file
ORG options are required on DATA, STORE, COPY and PRTDATA.
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Report Windows
You can write reports to a dif file using FileSave As, FileExport, EditCopy; the
Export and Copy toolbar items, and the Export and Copy contextual menu operations.
Matrix Windows
You can write the contents of a matrix window to a dif file using File-Save As, File-
Export; the Save and Export toolbars, and the Export contextual menu.
Details
For copy-and-pasting into dif, you will probably have to choose the Paste Special op-
eration in the target application. RATS copies the full precision of real numbers when
copying to the clipboard in dif format.
RATS Instructions
data(format=dta) read series from Stata into memory
store(convert=dta) copy series from Stata into rats format
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button.
Details
Data in a dta file are stored as named series which will be read or imported using those
names. You can read all the series by leaving the series list blank on either DATA or
STORE, or you can request specific series by listing just the ones you want. If you import
directly into a data list, you will get all series.
rats will not recognize any dates on the file.
Example
open data pennxrate.dta
calendar(panelobs=34,a) 1970
data(format=dta) 1//1970:01 151//2003:01 year xrate ppp $
id capt realxrate lnrxrate oecd g7
reads 24 years of panel data for 151 countries.
RATS Instructions
data(format=fame) read series from fame into memory
store(convert=fame) copy series from fame to rats format
copy(format=fame) write series to fame file
Interface Operations
On the Data/Graphics menu (for Pro versions), theres a Data BrowserFame Database
operation. This opens a Series Window showing the contents of the file. You can drag
and drop series from that into the Series Window or a RATS Data File window.
Details
Fame databases can be either local (accessed as standard operating system files) or
server. There are slight differences in how you use them.
Local databases are files with a .DB extension that you read like any other file:
cal(m) 1970:1
open data c:\fame\util\driecon.db
data(format=fame) 1970:1 2003:7 ipsb50001 cusa0
For server access, just use the base name of the database on the OPEN DATA, and in-
clude the additional option SERVER=server spec on the DATA or STORE instruction.
The server spec is a string with the port, followed by the server node, followed by
(if necessary) the user id and password. These are separated from each other by the |
character. For instance:
cal(q) 1980:1
open data driecon
data(format=fame,server="5555|booker") 1980:1 2010:2 gdp gicv
You can only add series to a local database. Use the APPEND option on the OPEN
COPY instruction to add to an existing file (rather than create a new one):
open(append) copy write.db
copy(format=fame) / x y z
RATS Instructions
data(format='Fortran format string') read series using fortran format
copy(format='Fortran format string') write series using fortran format
read(format='Fortran format string') read data using fortran format
write(format='Fortran format string') write data using fortran format
ORG options are required on DATA and COPY.
Interface Operations
None
Details
fortran format allows you to use the standard fortran I/O formatting codes to
indicate the format of the data file. You probably shouldnt try using it unless you
are fairly comfortable with fortran formats (described briefly below), and the other
methods above are cumbersome.
With fortran formats you can tell rats exactly how the data are organized when
using DATA or READ, or exactly how you want the data to be formatted when using
COPY or WRITE. For example, when used with COPY, FORMAT=FREE uses a very wide
field for each number so that it can reasonably handle very different magnitudes. The
result is that you can sometimes get a lot of extra digits. This takes up space (so you
see fewer numbers at a glance) and masses of digits can be hard to read.
If you are unfamiliar with fortran, a brief description is in order. The basic format
elements for real numbers take the forms Fw.d, Ew.d and Gw.d. rats (which only
simulates fortran I/O) also allows you to use the Iw format for input.
Fw.d For numbers with a fixed decimal place: a total of w positions
(total digits to the left and the right of the decimal) with d dig-
its to the right of the decimal. Very large and very small num-
bers will not fit an F format. For example, the number 1000000.
cannot be printed as F15.8.
Ew.d For numbers in scientific notation. When writing files, this for-
mat is useful because it can handle a number of any magnitude,
but it can be difficult to pick out large and small values at a
single glance. For example, it takes a bit of work to see that the
first of 1.343E-02 and 8.547E-03 is the larger.
Gw.d This is a mixture of the F and E formats. If a number can rea-
sonably be printed with the F format, that is used. All others
(very large and very small) are displayed in the E format.
Iw For integer numbers. If there is a fractional part to the number,
it is ignored.
Aw This is used (by COPY) only for the date strings. It prints a char-
acter string, left justified, in a field of width w.
wX Indicates w spaces
/ Indicates a skip to the next line
In the description of a line, the fields are separated by commas. You can prefix a field
descriptor by a number of repetitions. For instance, F6.2,F6.2,F6.2 can be short-
ened to 3F6.2.
read(n,1000) (gnp(i),i=1,100)
read(n,1000) (m1(i) ,i=1,100)
1000 format(11x,4f15.7)
If you have blank lines separating the series, you may have to read the first series
with one format, then use a format such as (//(11X,4F15.7)) for the remaining
series: this particular format will skip two lines before reading a series.
With ORG=COLS
The equivalent of a separate fortran read statement is used for each observation:
on the next page is a sample rats instruction and its fortran equivalent. (You
must delete any header lines at the top of the file).
data(org=col,format="(f9.4,2x,f10.3,2x,f9.4)") 1 100 gnp m1 ipd
do 100 i=1,100
read(n,1000) gnp(i),m1(i),ipd(i)
100 continue
1000 format(f9.4,2x,f10.3,2x,f9.4)
Missing Data
You can use the codes (such as NA) for missing values used by other text files.
You can also leave a blank area where the missing values should be and use
BLANK=MISSING on the DATA instruction. This will interpret the blank area as a
missing value (as opposed to a standard practice of reading a zero).
FIRM B
1996 22.5 21.9 24.3 25.6
1997 21.9 21.8 22.6 23.5
1998 22.5 25.0 24.5 25.4
The data rows can be read with (12X,4F9.1). The problem is the other rows: there
is only one row preceding the first series (the row with FIRM A), but two (the blank
plus FIRM B) preceding the second. The simplest way to handle this is to add a
blank line at the beginning of the file and use
cal(q) 1996:1
all 1998:4
open data test.dat
data(format="(//(12x,4f9.1))",org=rows) / firma firmb
print / firma firmb
Note that we use PRINT to verify that the data has been read properly. How did we
come up with '(//(12X,4F9.1))'? First, the two slashes tell rats to skip two lines
before each block of data. Next, for a data block where the numbers are regularly
spaced (as they are here), just determine the position of the last digit in the first
data value on the line (column 21 in this case) and the field width of the data (here
9, which is the distance from the end of one number to the end of the next). The 12 in
12X is just the number of leading positions (219=12) to be skipped.
The 4F9.1 indicates that the fields are each nine characters wide (including lead-
ing blanks) with 1 digit after the decimal point, and that this format is repeated 4
times per row. After skipping two lines, rats will read data into FIRMA using the
12X,4F9.1 format until it has read the requested number of data points (12 in this
case). It then skips two more lines and again uses the 12X,4F9.1 format to read 12
data points into FIRMB.
An alternative if you either cant, or dont want to, alter the original file is to use
separate instructions so that you can apply different formats in succession:
data(format="(/(12x,4f9.1))",org=rows) / firma
data(format="(//(12x,4f9.1))",org=rows) / firmb
RATS Instructions
data(format=free) read series from free into memory
store(convert=free) copy series from free to rats format
copy(format=free) write series to free file
prtdata(format=free) write series from rats format file to free
read(format=free) read scalars or arrays from free into memory
write(format=free) write scalars or arrays from memory to free file
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Details
See Text Files on page Int120 of the Introduction for details.
RATS Instructions
data(format=haver) read series from Haver into memory
store(convert=haver) copy series from Haver to rats format
Interface Operations
On the Data/Graphics menu (for WinRATS Pro), theres a Data BrowserHaver DLX
Database operation. This opens a window listing the contents of the file. You can drag
and drop series from that into the Series Window or a RATS Data File window.
Details
A dlx database consists of several files in the same directory with a common base name,
For instance, the usecon data base (a 12,000 series database with a broad range of
key U.S. macroeconomic series) comprises the files USECON.IDX and USECON.DAT. To
use DATA or STORE, you need to open a unit named HAVER with just that base name
(in this case USECON), with the full directory if required. In the FilePreference dialog,
in the Data Sources tab, you can set a permanent association of the HAVER unit with
a particular database, If youve done that, you dont need to include an OPEN HAVER
instruction to access that database.
Series are read according to their database names. Each series has its own range and
date scheme, so you can choose any subset of entries and can do compaction and expan-
sion as described in Changing Data Frequencies on page Int104 of the Introduction.
Example
The following reads six series (gdp, gdp deflator, gross private domestic investment,
unemployment rate, one year T-bill rate and M2) from the usecon data base. The
last three series are compacted from the monthly data on the database to quarterly
in the workspace.
open haver m:\data\haver\usecon
cal(q) 1960:1
data(format=haver) 1960:1 2010:2 gdpq dgdp fq lr fcm1 fm2
RATS Instructions
copy(format=html) copy series from memory to an html table
prtdata(format=html) copy series from a rats format file to an html table
write(format=html) write scalars or arrays from memory to html file
report(format=html) used with the ACTION=SHOW and UNIT options, this
writes the report to an html table
Interface Operations
Report Windows
You can write reports to html using FileSave As, FileExport, EditCopy; the Ex-
port and Copy toolbar items, and the Export and Copy contextual menu operations.
Series Window and RATS Data File Window
You can export series using FileExport..., the Export toolbar button, or the Export
operation on the contextual menu.
Matrix Windows
You can write the contents of a matrix window to an html file using File-Save As,
File-Export; the Save and Export toolbars, and the Export contextual menu.
Details
This produces just a part of a full html file, so you will have to insert it into a larger
document. From a report window, it copies real numbers as they are displayed on the
screen, so format them first to the precision that you want.
RATS Instructions
data(format=matlab) read series from matlab into memory
store(convert=matlab) copy series from matlab to rats format
read(format=matlab) read scalars or arrays from matlab into memory
Interface Operations
Data Wizard
You can read series from a matlab (*.MAT) file using Data (Other Formats) on the
Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button.
Details
read(format=matlab)
Since READ is designed to read matrices, reading matlab data is straightforward: if
theres an NM matrix A on the file, READ A will dimension A as NM and read the
data into it. You can read multiple matrices off a single file. If youve saved scalars on
the file, you can read those as well.
data(format=matlab)
store(convert=matlab)
Data series will typically be stored in one of two ways: as separately named column
vectors, or as a single matrix with multiple columns. Either way, rats will not rec-
ognize any dates on the file. If the data are in separate columns, read them by name.
For the arrangement with multiple columns, use the option SHEET=matrix name,
then give series names to the columns.
Examples
The file CBES.MAT has one matrix named PSID. This has 3051 rows by 3 columns.
The columns represent (in order) age, education and income. The following will read
the data from that file and create three series:
open data cbes.bat
data(format=matlab,sheet="psid") 1 3051 age education income
The file USMODEL_DATA.MAT has seven column matrices with names DC, DINVE, DY,
LABOBS, DW, PINFOBS and ROBS. Each column has 230 entries, representing quar-
terly data from 1950Q1 to 2007Q2. The following reads data from the file:
open data usmodel_data.mat
calendar(q) 1950:1
data(format=matlab) 1950:01 2007:02 dc dinve dy labobs dw $
pinfobs robs
RATS Instructions
data(format=odbc) read series from a database into memory
store(format=odbc) copies series from a database to a rats format file
Interface Operations
None
Details
Before reading data from a database using odbc and sql, you must set up an odbc
Data Source for the desired database. The process for doing this varies somewhat
depending on the operating system in use. With recent versions of Windows, you can
set up a Data Source by opening the Windows Control Panel and double-clicking on
the Data Sources (odbc) control. This displays a dialog box you can use to define a
Data Source Name for your database.
Once you have the Data Source defined, you can open a connection to the database in
rats by using a command of the form:
The DATA command creates a table (internally) which is then processed similar to the
spreadsheet files in Section 2.8 of the Introduction.
For example, the following creates a table with date and total daily sales (summing
the SUBTOTAL field by date to create the SALES field), then reads the data into rats,
creating the series SALES as monthly sums.
cal(m) 1995:1
open odbc "Sales"
data(format=odbc,compact=sum,
sql="select date,sum(subtot) as sales from invoice order by date") $
1995:1 2006:12
select date,sum(subtot)
as sales from invoice
order by date
;
RATS Instructions
data(format=portable) read series from portable into memory
store(convert=portable) copy series from portable to rats format
copy(format=portable) write series to portable file
prtdata(format=portable) write series from rats format file to portable
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Examples
This writes a series out to a file in portable format, including one header (description)
line). You can add up to two of those.
copy(format=portable,header=1) / gnp
GROSS NATIONAL PRODUCT, CURRENT DOLLARS
This shows how a portable file is constructed. The series are displayed separately.
The key elements for each are the series name (on a separate line), the line contain-
ing the frequency and starting and ending dates, the header lines, and the row of ===
which ends the header.
GNP
Quarterly data from 1947:01 to 1990:04
GROSS NATIONAL PRODUCT, CURRENT DOLLARS
===============================================================================
1947:01 224.9000000 229.1000000 233.3000000 243.6000000
1948:01 249.6000000 257.1000000 264.0000000 265.5000000
etc.
dedit mydata.rat
open copy archive.txt
prtdata(unit=copy)
This writes all of the series stored in the rats data file MYDATA.RAT to a text file
called ARCHIVE.TXT.
RATS Instructions
data(format=prn) read series from prn into memory
store(convert=prn) copy series from prn to rats format
copy(format=prn) write series to prn file
prtdata(format=prn) write series from rats format file to prn
read(format=prn) read scalars or arrays from prn into memory
write(format=prn) write scalars or arrays from memory to prn file
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Details
On DATA and STORE, you can, if required, use the NOLABELS option to skip automatic
label processing and use the LEFT and TOP options to isolate the data.
See Spreadsheet and Delimited Text Formats on page Int114 of the Introduction for more
details on the format.
RATS Instructions
data(format=rats) read series from rats format into memory
store(convert=rats) copy series from one rats format file to another
copy(format=rats) write series to rats file
prtdata(format=rats) write series from one rats format file to another
Interface Operations
Data Wizard
You can read series by using FileOpen... to open a rats format file, selecting the
desired series from the rats Data File window, and using Data (RATS Formats) on
the Data/Graphics menu.
Series Window and RATS Data Window
You can use FileOpen and FileNew... to open or create a rats format file. Various
toolbar and contextual menu operation are available for generating graphs, editing
series, renaming series, and so on. You can bring series into memory from an open
rats file using the Data Wizard described above, or by dragging and dropping series
onto the Series Window.
You can write series from memory to the open file by dragging and dropping them
from the Series Window onto the rats Data File Window.
You can import series into the file from another using FileImport... or the Import
toolbar button. You can export series to another using FileExport..., the Export tool-
bar button, or the Export operation on the contextual menu.
Details
See RATS Format on page Int110 of the Introduction for more details on creating and using
rats format files.
RATS Instructions
copy(format=tex) writes series to a tex file
prtdata(convert=tex) copy series from a rats file to a tex file
report(format=tex) used with the ACTION=SHOW and UNIT options, this
writes the report to a tex file
Interface Operations
Series Window and RATS Data File Window
You can export series using FileExport..., the Export toolbar button, or the Export
operation on the contextual menu.
Report Windows
You can write reports to a tex file using FileSave As, FileExport, EditCopy as tex,
the Export and Copy toolbar items, and the Export and EditCopy as tex contextual
menu operations.
Matrix Windows
You can write the contents of a matrix window to a tex file using File-Save As, File-
Export, EditCopy as tex, the Save and Export toolbars, and the Export contextual
menu.
Details
To use the tex table in a document, you need to include the dcolumn package, which
allows for decimal alignment of columns. This is an example of what is produced:
\newcolumntype{.}{D{.}{.}{-1}}
\begin{tabular}{. . . }
\multicolumn{1}{c}{Test} & \multicolumn{1}{c}{Statistic} &
\multicolumn{1}{c}{P-Value}\\
\multicolumn{1}{l}{Joint} & \multicolumn{1}{r}{4.070} &
\multicolumn{1}{r}{0.000}\\
\multicolumn{1}{l}{Variance} & \multicolumn{1}{r}{0.121} &
\multicolumn{1}{r}{0.473}\\
\multicolumn{1}{l}{Constant} & \multicolumn{1}{r}{0.922} &
\multicolumn{1}{r}{0.004}\\
\multicolumn{1}{l}{X2} & \multicolumn{1}{r}{0.917} &
\multicolumn{1}{r}{0.004}\\
\multicolumn{1}{l}{X3} & \multicolumn{1}{r}{0.914} &
\multicolumn{1}{r}{0.004}\\
\end{tabular}
Note that if you want to paste the table into a tex document, you need to use one of
the Copy as tex operations. The standard Copy operations also produce a straight tab-
delimited text copy of the data, which will generally be the one chosen by the Paste opera-
tion in the target application. Copy as tex puts only the tex version into the clipboard.
You will generally enclose the tabular environment produced by rats inside a table
environment which will handle the placement and captioning. If the tex code on the
previous page is saved in the file testtable.tex, the following would center it on
the page with the caption Example of tex Output.
\begin{table}[htb]
\centering
\include{testtable}
\caption{Example of TeX Output}
\end{table}
RATS Instructions
data(format=tsd) read series from tsd into memory
store(convert=tsd) copy series from tsd to rats format
copy(format=tsd) write series to tsd file
prtdata(format=tsd) write series from rats format file to tsd
read(format=tsd) read scalars or arrays from tsd into memory
write(format=tsd) write scalars or arrays from memory to tsd file
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Details
On DATA and STORE, you can, if required, use the NOLABELS option to skip automatic
label processing and use the LEFT and TOP options to isolate the data.
See Spreadsheet and Delimited Text Formats on page Int114 of the Introduction for more
details on the format.
RATS Instructions
data(format=wf1) read series from wf1 format into memory
store(convert=wf1) copy series from wf1 format to rats format
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button.
Details
Data in a wf1 file are stored as named series which will be read or imported using
those names. You can read all the series by leaving the series list blank on either
DATA or STORE, or you can request specific series by listing just the ones you want. If
you import directly into a data list, you will get all series.
Each file has a data frequency and start date, so you can read a subset of entries
or change the frequency and get the standard compaction or expansion handling
(Changing Data Frequencies on page Int104 of the Introduction).
Because these are often work files rather than simply data files, they will often
include extra series (like residuals) which are derived from the original data series.
If you use the Data Wizard, you may want to trim the list of series to include just the
data and do any further transformations yourself.
Example
open data yen1kp.wf1
calendar(m) 1973:1
data(format=wf1) 1973:01 1996:07 dm yen
RATS Instructions
data(format=wks) read series from wks into memory
store(convert=wks) copy series from wks to rats format
copy(format=wks) write series to wks file
prtdata(format=wks) write series from rats format file to wks
read(format=wks) read scalars or arrays from wks into memory
write(format=wks) write scalars or arrays from memory to wks file
report(format=wks) (with ACTION=FORMAT) write a report to wks file
Interface Operations
Data Wizard
You can read series using Data (Other Formats) on the Data/Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Report Windows
You can write reports to a wks file using FileSave As, FileExport, EditCopy; the
Export and Copy toolbar items, and the Export and Copy contextual menu operations.
Matrix Windows
You can write the contents of a matrix window to a wks file using File-Save As, File-
Export; the Save and Export toolbars, and the Export contextual menu.
The Copy operations will generally only allow pasting in wks format into a spreadsheet.
Details
On DATA and STORE, you can, if required, use the NOLABELS option to skip automatic
label processing and use the LEFT and TOP options to isolate the data.
See Spreadsheet and Delimited Text Formats on page Int114 of the Introduction for more
details on the format.
RATS Instructions
For all of these, use FORMAT=XLS for Excel 2003 and older formats, and FORMAT=XLSX
for Excel 2007 format. Only XLS is permitted for output.
data(format=xlsx) read series from xlsx into memory
store(convert=xlsx) copy series from xlsx to rats format
copy(format=xls) write series to xls file
prtdata(format=xls) write series from rats format file to xls
read(format=xlsx) read scalars or arrays from xlsx into memory
write(format=xls) write scalars or arrays from memory to xls file
report(format=xlsx) (with ACTION=FORMAT) write a report to xlsx file
Interface Operations
Data Wizard
You can read series from xls or xlsx files using Data (Other Formats) on the Data/
Graphics menu.
Series Window and RATS Data File Window
You can import series using FileImport... or the Import toolbar button. You can
export series using FileExport..., the Export toolbar button, or the Export operation
on the contextual menu.
Report Windows
You can write reports using FileSave As, FileExport, EditCopy; the Export and
Copy toolbar items, and the Export and Copy contextual menu operations.
Matrix Windows
You can write the contents of a matrix window to a file using File-Save As, File-Ex-
port; the Save and Export toolbars, and the Export contextual menu.
The Copy operations will generally only allow pasting in xls format into a spreadsheet.
Details
On DATA and STORE, you can, if required, use the NOLABELS option to skip automatic
label processing and use the LEFT and TOP options to isolate the data.
See Spreadsheet and Delimited Text Formats on page Int114 of the Introduction for
more details on the format.
Using %SWEEP
Polynomials
Additional Topics
B (k, k ) = 1 A (k, k )
B (i, k) = A (i, k) A (k, k) for i k
B (k, j ) = A (k, j ) A (k, k ) for j k
B (i, j ) = A (i, j ) A (i, k) A (k, j ) A (k, k) otherwise
One of the exercises in Hayashi (2000) is to do a Monte Carlo analysis of unit root
tests, doing one Dickey-Fuller test allowing for intercept and one with intercept and
trend. The sweep functions offer an efficient way to do this because the two regres-
sions can be done by sweeping first on the lag and intercept, then again on the trend.
cmom
# y y{1} constant trend
We sweep on 2 and 3 to regress on Y{1} and CONSTANT. The regression coefficients
are going to be in column 1 (non-pivot column). The sum of squared residuals is in
(1,1). The t-stat can be put together using these and the (2,2) element.
compute ss=%sweeplist(%cmom,||2,3||)
compute tmu=(ss(2,1)-1)/sqrt(ss(1,1)*ss(2,2)/(%nobs-2))
Now sweep on the trend as well and repeat
compute ss=%sweep(ss,4)
compute ttau=(ss(2,1)-1)/sqrt(ss(1,1)*ss(2,2)/(%nobs-3))
v (1) + v (2) x + + v (n + 1) x n
*
* Compute the long run effect
*
compute ardllt=%polyvalue(dlpoly,1)/%polyvalue(arpoly,1)
*
* Compute 8 lags of the expansion (degree 7 polynomial)
*
compute ardlest=%polydiv(dlpoly,arpoly,7)
where a, , c and d are the free parameters, that is, bl is constrained to follow a 3rd
order polynomial. If you expand this sum, a is the coefficient on the sum of X t-k , b
on kX t-k , etc. We use ENCODE to create these four series, which we then use in the
regression.
We impose an end constraint (polynomial is zero for lag L+1) by writing the
polynomial as (k (L + 1))(a + bk + ck2 ) .
We impose near (polynomial is zero for lag 1) and far constraints using
(k (L + 1))(k + 1)(a + bk).
The trick in handling the constrained PDLs is to get the EWISE instruction, which
creates the encoding matrix R, correct. Because lag 0 (k=0) corresponds to the first
row in R (J=1 in EWISE), the roots should be at J=0 (k=1) and J=L+2 (k=L+1).
As mentioned in the Users Guide section, you need to be very cautious in interpret-
ing the results from a pdl, since the t-statistics will usually be very high. This is
because they are testing whether a coefficient can be made zero, while maintaining
the hard shape constraint.
pdls have fallen out of favor mainly because the basic distributed lag like (1) usually
leaves very high serial correlation in the residuals. If you allow for richer dynam-
ics by adding lagged dependent variables (the ardl model), you will generally get
results that are easier to interpret.
(4) r = Rb + v , Cov (v ) = V
Computation Tools
1
Note that both techniques estimate b as ( X X + Q) ( X y + q). The tools for imple-
menting such estimators are the CMOMENT and LINREG(CMOMENT) instructions:
CMOMENT computes the matrices X X and X y using the actual data. In prac-
tice, these will actually be segments of the same matrix. We then replace these
matrices with X X + Q and X y + q.
LINREG(CMOMENT) computes the regressions using the altered versions of
X X and X y.
To simplify this process, on CMOMENT you should list the variables as regressors first,
followed by the dependent variable. That way, the matrix %CMOM, as computed by
CMOMENT will have the form
X X y X
X y y y
(actually just the lower triangle of this), so X X is the top corner, and X y is all but
the last element of the last row.
Ridge Regression
Ridge regression is especially easy because all we need to do is add a constant to the
diagonal elements of . The simplest way to do this is with a DO loop:
cmoment
# constant x1 x2 x3 x4 y
linreg(cmoment) y Least squares
# constant x1 x2 x3 x4
do row=1,5
compute %cmom(row,row)=%cmom(row,row)+k Add to diagonals 1-5
end do row
linreg(cmoment) y Ridge regression
# constant x1 x2 x3 x4
Choosing an appropriate value for K is the real problem with ridge regression. See,
for example, the discussion in Judge, Griffiths, Hill and Lee (1980).
Mixed Estimation
We need to construct the matrices R, r and V in some fashion. r is often zero and V is
almost always diagonal, and is usually a scalar matrix (a constant times the iden-
tity), which simplify these considerably.
Since we do not know s2, in general, we must use an estimate s2 of it. We do a pre-
liminary LINREG to get the estimate s of s, then use matrix commands to replace
X X by X X + s2 R V1R , and
X y by X y + s2 R V1r .
Where V is scalar (say l 2 I ), this can be done quite simply (if the %CMOM array has
been arranged as described on the previous page) by stacking R on top of r into Rr
and then adding to %CMOM the array (s2 /l 2 )(Rr ) (Rr ) . This is what is done in Ex-
ample 4.2. If V is more general, its necessary to change the X X and X y matrices
separately. This is done most easily using the OVERLAY instruction.
Because the general case involves a bit of extra programming, we provide with rats
a procedure named @MIXED (on the file MIXED.SRC) which does the entire calcula-
tion. Its syntax is
@mixed( options ) depvar start end
# explanatory variables in regression format
The options are
capr=R matrix
lowr=r matrix
scalar=scalar for V being a scalar matrix
V=V matrix in general
compute scalefac=%seesq/.01
dofor [real] power = 1.0 2.0 4.0 8.0
compute kfactor=power*scalefac
compute %cmom =cmomhold+kfactor*dummyxx
compute title=$
"Shiller Smoothness Prior with k="+%strval(kfactor,"*.##")
linreg(cmom,title=title) longrate
# constant shortrate{0 to 24}
end dofor
( )
12
2
(7) min c 2 + ut (b )
b
t
X tut
(8) 12
=0
t (c 2
+ ut2 )
12
which are the same as the FONCs for weighted least squares with SPREAD= (c 2 + ut2 )
We can thus estimate b by iterated weighted least squares.
Using the results from Section 2.2 in the Users Guide, we can compute the covari-
ance matrix as A-1BA-1, where
ut2
(9) B = X tX t
t (c 2
+ ut2 )
c2
(10) A = X tX t 32
(Note: we changed the sign on this)
t (c 2
+ ut2 )
compute nords=2*%freqsize(2007:3)
frequency 2 nords
rtoc
# prepped
# 1
fft 1
Create bands of width p/16. Leave the low frequencies in.
cmask 2 / (nords/12) (nords/32) (nords/12)+1
cmult 1 2
ift 1
Send the deseasonalized data back, add back the removed trend and exponentiate.
ctor 1960:1 %allocend()
# 1
# deseason
Deprecated Instructions
Obsolete Options and Parameters
Additional Topics
ALLOCATE
Prior to Version 6 of rats, the ALLOCATE command was required in any program
that used data series. It is now optional. This is no longer needed, as you now set the
default range by supplying explicit start and end dates (or entry numbers) on your
first DATA, SET, or SMPL instruction.
AR1
A fifth coefficient used in versions prior to 7.0 for saving the coefficients has been
deprecated. Coefficients are now saved automatically in the vectors %BETA and %BE-
TASYS.
The DIFFERING option was renamed as HETEROGENOUS in Version 7. The name DIF-
FERING is still recognized, but not recommended.
ERRORS
The steps and VCV Matrix parameters used in older versions have been replaced
by the STEPS and CV options, respectively.
ESMOOTH
Two parameters (forecasts and steps) used in older versions have been replaced
by the FORECASTS and STEPS options described below.
ESTIMATE
Two additional parameters (residuals and coeffs) used in older versions have
been replaced by the RESIDUALS and COEFFS options described below.
IMPULSE
The steps, shock to and VCV Matrix parameters used in older versions have been
deprecated. These are replaced by the STEPS, COLUMN, and CV options, respectively.
INCLUDE
The comments parameter used in older versions has been replaced by the COMMENTS
option.
KALMAN
The parameters residual, coeffs, and printflag used in older versions have been
replaced by options. The first two parameters, for storing the residuals and coef-
ficients, have been replaced by the RESIDS and COEFFS options (you can also use
COHISTORY to save coefficients). The functionality of the third parameter, used to
control printing of output based on a logical expression, has been incorporated into
the PRINT option .
MRESTRICT
Two additional parameters (resids and coeffs) used in older versions have been
deprecated. rats still recognizes these, but they are unnecessarythe residuals and
coefficients are now saved automatically in the %RESIDS series and %BETA vector,
respectively. You can also use the COEFF option to save the coefficients.
MVFRACTILE
The MVFRACTILE instruction functionality has been incorporated into the MVSTATS
instruction.
RENAME
The comments parameter (and accompanying text cards) used in older versions has
been replaced by the COMMENTS option described below.
RREG
A fifth parameter called coeffs, which saved coefficients into a series, has been dep-
recated. It will still function in Version 7, but is not recommended, as the coefficients
are automatically saved in the %BETA vector.
SEASONAL
Two additional parameters (seasonal and period) used in older versions have been
replaced by the SPAN and PERIOD options described below.
SIMULATE
Three additional parameters used in older versions have been replaced by options.
The steps and start parameters are replaced by the STEPS, FROM, and TO options.
The VCV Matrix parameter is replaced by the CV option.
STEPS
Two additional parameters (steps and start) used in older versions have been
replaced by the STEPS, FROM, and TO options described below.
STWISE
A fifth parameter, coeffs, still works but is not recommended. The coefficients are
automatically saved in the vector %BETA.
SUR
The current options CV and CVOUT were called ISIGMA and OUTSIGMA, re-
spectively, in previous versions. The old names are still recognized in Version 8.
THEIL
Two additional parameters used in older versions, steps and data end, have been
replaced by the STEPS and TO options.
X11
Two additional parameters, adjusted and factors, used in earlier versions have
been replaced by options of the same names.
Parameter
pause message This is a string of characters which is reproduced in the dia-
log box or prompt when you do CNTRL(PAUSE). Note that the
newer MESSAGEBOX and INFOBOX instructions are generally
more useful for interactive programs.
Options
page/[nopage]
CNTRL(PAGE) inserts a page break in the output file. You should only use this for
programs you intend to run in batch mode.
pause/[nopause]
Pauses and waits for a user response before continuing. This will be a dialog box,
or a simple message to hit a key, depending upon the environment. You can use
the pause message parameter to add a message to the user prompt. As noted
above, the MESSAGEBOX and INFOBOX instructions offer more flexible alterna-
tives.
user/[nouser]
Takes input from the keyboard until the user types a RETURN instruction.
interactive/[nointeractive]
Use this at the beginning of a program which is run as a batch program but uses
some interactive features.
Notes
If you are writing an interactive procedure that is to be executed in batch mode, you
will probably want to use the instruction ENVIRONMENT NOECHO to suppress the
echoing of lines as they are processed. Let the user see only what you want her to see.
Parameters
The parameter field for DEFAULT looks like an instruction plus its option field, for
instance, GRAPH(NODATES). You can change more than one option for a given in-
struction with a single DEFAULT, but you need a separate DEFAULT for each separate
instruction whose defaults you wish to change.
DEFAULT only affects the options you specifyother default settings for the instruc-
tion remain unchanged.
Examples
default print(nodates)
default graph(nodates)
These two instructions set NODATES as the default option for PRINT and GRAPH. Sub-
sequent PRINT and GRAPH instructions will, by default, label output by entry number
rather than dates.
default linreg(noprint,smpl=regsampl)
This changes two of the default options for the LINREG instruction
The default print option becomes NOPRINT, so you would need to include a
PRINT option in a LINREG instruction to have it display the output.
The SMPL=REGSAMPL option means that subsequent LINREG instructions will
use REGSAMPL as the SMPL series.
Wizard
If you open the rats format file with Open on the File menu, the Delete and Cut
operations on the Edit menu will delete the selected series.
Parameters
list of series The list of series which you want to delete from the file.
Example
dedit pricedat.rat
delete turcpi grccpi prtcpi islcpi
save
removes the series TURCPI, GRCCPI, PRTCPI and ISLCPI from the rats data file
PRICEDAT.RAT.
Notes
When you do a DELETE instruction, it is likely that the length of your file will not
change. rats simply marks the old records as unavailable, but does not physically
change the size of the file.
See Also . . .
Intro. Section 2.7 rats format data files
DEDIT Opens (or creates) a rats format data file for editing.
STORE Adds data from one or more series to the rats file you are edit-
ing
INCLUDE Adds data from a single series to the rats file you are editing.
Wizards
You can also edit series on a rats file by using the Open or New operations on the
File menu to open or create a rats file, and double-clicking on the series you want to
edit or clicking on the new series toolbar icon. You can edit series stored in memory
(rather than on a rats file) by doing ViewSeries Window and double-clicking on the
series you want to edit.
Parameters
series The list of series names you want to edit or create. If listing
multiple names, separate each by one or more blank spaces. If
you dont list any series, rats will display a scrolling list of all
the series on the file. You can select a series to edit from the
list, or enter a new series name to create a new series.
Option
modal/[nomodal]
With MODAL, an EDIT editing window functions like a modal dialog box. Execu-
tion of any pending instructions is suspended until the user closes the editing
window and new instructions can be executed. This can be useful when you want
the program to stop and wait for the end user to enter data before continuing.
Editing a Series
Once you have opened or created a rats data file, you can edit or create a series by
issuing a command like:
edit usargdps
rats will display a series edit window which you can use to edit the values in the
series. See page Int-14 in the Introduction for details on using the series editing
window.
Saving Changes
When you are done editing, just close the editing window. You will see a dialog box
asking if you want to save the changes to the series. Answer Yes if you want to keep
the changes.
Important Note: You still need to save the changes to the file itself by issuing a
SAVE instruction if you opened the file using DEDIT, or by using FileSave if you
opened the file using FileOpen or FileNew. If you try to quit out of rats before sav-
ing changes to the data file, the program will ask if you want to save your changes.
Wizard
You can also store series on a rats format files using the mouse. First, open or cre-
ate a rats format file by doing FileOpen or FileNew. Then, use Series Window on
the View menu to display a list of the series in memory. Finally, drag and drop the
desired series from the series window onto the rats data file window.
Parameters
fileseries Name you want to assign to the series when it is saved on the
data file. There should not be a series with name file series
already on the file. If you wish to change an existing file series,
use STORE or EDIT, or DELETE the series before INCLUDEing.
series The series (in working memory) which supplies the values for
file series. Since you often will be using the same name on
the data file, the default for series is file series. However,
the names can be different.
start end Starting and ending entries of the range of data you want to
save. If you have not set a SMPL, this defaults to the defined
range of series.
Option
comments=STRING or VECT[STRINGS] containing comments [no comments]
Use this option if you want to add comments describing the series. You can add
up to two (80 character) comments to a series.
Description
INCLUDE adds to the data file a series with name file series. rats takes the data
for this from series entries start to end. If you only specify the file series
parameter, INCLUDE takes data from that series and saves it on the file under the
same name. As with other editing instructions, you must SAVE the file when you are
finished with all your changes to make them permanent.
Supplying Comments
If you wish to add comments to a series, you can define the STRING or
VECT[STRINGS] ahead of time, or create it directly as the argument for the option,
as shown in the example below.
Example
cal(q) 1980:1
all 2006:4
Wizard
If you open a rats format file using FileOpen..., you can rename a series using the
Rename toolbar ion:
Parameters
old name Current name of the series.
new name New name for the series.
Option
comments=STRING or VECT[STRINGS] containing comments [no comments]
Use this option if you want to add comments describing the series. You can add
up to two (80 character) comments to a series.
Examples
dedit mydata.rat
rename fzm1 m1
rename(comments="GDP in 1992 dollars") gdp92 realgdp
save
This renames two series on the file, and attaches the comment GDP in 1992 Dollars
to the series REALGDP.
dedit prices.rat
open data prices.xlsx
store(convert=xlsx,org=cols)
rename 1234 a1234
save
converts an xlsx file to rats format, then fixes an illegal name (rats variable
names cant start with a digit).
Parameters
file series Name of the series (on the rats data file) you want to update.
begin entry This is the date or entry number of the first entry you want to
change or add. You can use date fields, but note that these are
for the calendar setting of the series on the file. By default, it is
the current end of the file series + 1.
end entry The date or entry number of the end of the updated section.
If you omit this, UPDATE will add or alter one or more values
starting with begin entry.
Description
UPDATE reads data for the update from data cards following the instruction. Data
can be separated by blanks, tabs or commas. If you give explicit values for both the
begin entry and end entry parameters it will replace or add data for just those en-
tries. If you omit end entry or both, UPDATE will change or add as many entries as it
processes from a single line of data. With panel and intra-day data, you can only add
entries to the end of the series with UPDATE. Use EDIT, SET, or COMPUTE to modify
existing values of a panel data series.
You do not need to set up a full rats program (with CALENDAR and ALLOCATE) to use
UPDATE, as it takes all its information from the data file. You can update a file simply
with DEDIT, one or more UPDATEs, SAVE and END.
Example
dedit mydata.rat
update realgdp
1604.3 1611.4 1625.2 1644.7
update sales 2006:3
11234
save
adds four entries to the end of REALGDP and replaces the 2006:3 value of SALES.
In the listing below, information that varies depending on the context of the error
(such as the specific dimensions involved in the MAT2 error show above) are enclosed
in << and >>. Where possible, we indicate the type of information that rats will
display in an actual error message. For example, <<name>> means that rats will
display the name of a variable, instruction, option, etc., while <<data type>> indi-
cates that it will display a data type, such as SERIES or REAL.
Some of the error messages end with a question, such as Did you forget to
SOURCE?. Note that these only suggest a possible cause for the error.
Finally, note that a number of these error messages are obsolete, and thus will never
be generated by Version 7 or later of rats. We include them here only because they
are still present in the error message file used by rats (RATSERRS.MSG).
Dont put a space between an instruction name and an option field. For example:
use print(nodates), not print (nodates). Check for misspelled names.
SX12 Expected a Variable Name Here
SX13 <<name>> Is Not a Valid RATS Variable Name
See Symbolic Names in Section 1.9 of the Users Guide for details on what rats
accepts as valid variable names.
SX14 Ill-formatted number
SX15 Trying to Store into Constant or Expression. Called Parameter by
Value?
If a PROCEDURE parameter is called by value, you cannot change the value stored in
that variable. If necessary, call the parameter by address instead.
SX16 Missing Operand or Adjacent Operators
Be sure to put at least one space before the equal sign in a SET instruction. For
example, use set x =t and not set x=t.
SX17 Missing Operator or Adjacent Operands
The SX17 can occur if you refer to N(entry) where N is a series number use
([series] N)(entry) instead. In SET or FRML expressions, you can use lag
notation: N{0}
SX18 Dates Must be a:b or a:b:c
Dont forget to separate the year and period (or the year, month, and day) in a date
expression with colons, such as: 1999:3:1.
SX19 This Character is Illegal Here
SX20 Expected <<character>> Here
SX21 A <<character>> Here is Unneeded or Unexpected
SX22 Expected Type <<data type>>, Got <<data type>> Instead
An expression may be returning a different data type than the declared type of
the variable you are setting, or you are using a variable of a type other than that
expected by the instruction (such as using a REAL variable as the series parameter
on SET).
SX23 Expected Variable/Element of Type <<type>>, Got Expression Instead
SX24 Expected Dimension Field Here
When using DIMENSION, dont put a space between a variable name and the left
parentheses. For example, use dim xmat(10,10), not dim xmat (10,10).
SX25 Logical Operators are .EQ./.NE./.LE./.LT./.GE./.GT./.AND./.OR./.N
OT.
SX26 Matrix Constructed with ||...|| has Too Complicated a Type
SX27 Illegal Combination of Data Types for Operation
SX28 <<{ or }>> For Lags Used In Improper Manner
SX29 Need a } to End the Lag Field
SX30 Characters After End of Expression
SX31 Expression to Left of , Has No Effect (year,period is obsolete no-
tation)
SX32 Expected */ To End Block Comment
SX33 Expression is Too Complicated. Break into Parts?
Regression/Estimation Problems
REG1 Cannot Execute Unless Preceded by a Completed Regression
REG2 LINREG(CMOM) First Requires CMOM/MCOV without CORR, CENTERED or
MATRIX option
REG3 <<instruction>> Fails - No Prior Regression or Regression Was Dif-
ferent Size
REG4 Variable <<name>> is Not in the Prior Regression
REG5 Variable <<name>> is Not in the Prior CMOMENT
REG6 Matrix <<name>> Is Singular. Check for Collinearity in First
<<number>> <<rows or columns>>
Forecasting/Simulation Errors
FO1 Equations <<name or number>> and <<name or number>> both have de-
pendent variable <<name>>
Each equation in the system must have a unique dependent variable. See Section
11.2 in the Users Guide.
FO2 Need the equation parameter on each supplementary card
FO3 You need to do THEIL(SETUP) first
FO4 Identities must come last
FO5 SHOCKS array has <<number>> columns. Should have <<number>>
FO6 SIMULATE(SETUP) is no longer needed. See description of SIMULATE.
FO7 Gauss-Seidel solution is explosive. Check model. Try DAMP option.
FO8 Gauss-Seidel did not converge in <<number>> Iterations. Criterion
= <<value>>.
See Section 11.2 in the Users Guide for tips on getting your simultaneous equation
model to converge.
FO9 Simultaneous block is singular. Check your equations.
FO10 Either actual or forecast is NA. Skipping step(s).
FO11 IMPULSE, ERRORS and HISTORY cant handle model with FRMLs.
Memory/Internal Errors
M1 <<parameter or option>> = <<number>> is Illegal. Value should be
between <<number>> and <<number>>
M2 <<parameter or option>> = <<number>> is Illegal. Value should be
<<required value type>>
M3 RATS Internal Error!!! This should never happen
M4 A memory request for an additional <<number>> bytes cannot be
satisfied
M5 <<name>> has Value <<number>> , Must Be <<number>>
M6 User Abort
M7 Untrapped Floating Point Error: Overflow or NA
M8 Untrapped Miscellaneous Error
M9 RATS Internal Error!!! Save Your Work Now Using Save As
M10 Classroom RATS Limit of <<number>> Data Points Exceeded. You Need
<<number>>
M11 Integer divide by zero
M12 Polynomials cant have negative powers
M13 Table Must be 2xN RECT[INTEGER]
DLM3 The G Option Requires Both A and SW to Solve Out Initial Condi-
tions
DLM4 With TYPE=CONTROL, B Option is Required
DLM5 Probable Model Error. Diffuse prior was not reduced to zero rank
Input/Output Errors
IO1 Unit <<I/O unit name>> is already open
IO2 Unit <<I/O unit name>> Is Already In Use For <<access type>>
IO3 Unable to open <<file name>>
Check to make sure the file isnt already open in another application.
IO4 Unit <<I/O unit name>> does not exist
IO5 Unit <<I/O unit name>> is permanent. You cannot <<OPEN or
CLOSE>> it
IO6 Units <<I/O unit name>> and <<I/O unit name>> are already
aliases
IO7 Unit <<I/O unit name>> is not open
IO8 An error occurred while writing to the disk, the disk may be full.
IO9 Invalid input <<string>> on line <<number>> while processing se-
ries <<name>> entry <<number>>
Usually occurs when a file being read with DATA includes text information. This is
only a warningrats will set the indicated entry to NA and continue reading data.
See the end of Section 2.8 in the Users Guide.
IO10 Unexpected end of file while processing line <<number>>. (series
<<name>> entry <<number>>)
IO11 Input/Output error on <<operation>> <<error code>>
IO12 A date is missing from series <<name>> after entry <<number>>
IO13 <<string>> is not a valid date on line <<number>>
IO14 Data are not in ascending date sequence
IO15 Using dates from the data file
IO16 Input file does not contain dates
IO17 Header names <<number>> series while there are <<number>> series
on file
The file should have one series name per column or row of data. This indicates that
there are too few or too many series names.
IO18 Unexpected end of line while processing line <<number>> (series
<<name>> entry <<number>>)
IO19 The file does not have a valid <<format type>> format
IO20 The file contains no valid data
IO21 RATS only process the first worksheet in a spreadsheet file
IO22 Format has nothing to read or write
Manual Errata
Additional Topics
ESTIMATE Instruction
The Variables Defined list should say %XX, not %X (fixed in pdf version).
Functions
The following functions were not listed in Section 2.
%CHOICE option (still need to add to ref manpdf)
%EQNRESID and %EQNRVALUE, for extracting a residual value from an equation.
(Fixed in PDF).
%FILE option (still need in Ref man)
%GRPARM in Section 2 (is documented in references under instructions). need to
add to ref man sec 2
The following are documented in the main alphabetical listing, but were not listed in
the summary list of Distribution/Probability functions at the beginning of Section 2:
%LOGGEVDENSITY and %LOGGPDENSITY. (Fixed in the PDF)
Hoerl, A.E. and R.W. Kennard (1970). Ridge Regression: Biased Estimation for Non-Orthogonal
Problems. Technometrics, Vol. 12, pp. 55-82.
Judge, G.G., W.E. Griffiths, R.C. Hill and T-C. Lee (1980). The Theory and Practice of Economet-
rics. New York: Wiley.
Shiller, R.J. (1973). A Distributed Lag Estimator Derived from Smoothness Priors. Econometrica,
Vol. 41, pp. 775-788.
Sims, C.A. (1974). Seasonality in Regression. Journal of the American Statistical Association, Vol.
69, pp. 618-626.