Assignment Due Dates
Problem Set: Due Feb. 13th (JF)
Sprague critique: Due Feb. 20th (Send to JBS, she will send to JF)
Arima: Due March 6th (Send to Jon, he will send to JF)
VAR: Due April 17th (Send to Jan, she will send to JP)
ECM: Due May 8th (Send to Jon, he will send to JBS) (The shorthand is: JF = Professor Freeman, JP = Professor Pevehouse and JBS = Professor Box-Steffensmeier)
Dynamic Analysts,
You will find below some instructions for using RATS. The program might seem complicated until you actually use it, at which point its logic will become more clear. These notes are intended to be a reference for you to have when you do your assignments for the course.Instructions for using RATS
Data Input
You can read data into RATS using "free format," where you type your numbers into any text editor that saves in ASCII format. The better option is to use a spreadsheet to enter your data. If you don't already know how to use one, it's worth the rather minor (about 15 minutes) time investment to learn the basics. It doesn't really matter which one you use. Lotus 1-2-3, Excel, Quattro Pro, dBase, and others are all OK. The only constraint is that your spreadsheet has to be able to save in Lotus 1-2-3 or dBase format. All spreadsheets that I've ever seen can save in their own format as well as Lotus 1-2-3, so this shouldn't be a problem.
Within your spreadsheet, simply type in the data, but use the first row for variable labels. Your screen will look something like this:
A B C D E .... 1 Year Opinion Unemp Regime 2 1970 26.3 6.5 0 3 1971 25.4 6.2 0 4 1972 23.8 5.4 1 5 1973 23.6 5.6 1 ... Note that you are limited (by RATS) to eight characters for variable names. If you have missing data use "NA" to indicate this. When you save your file, you should save a version in either Lotus 1-2-3 (with a .wk1 filename extension). You will then read the Lotus 1-2-3 version directly into RATS.
Surviving the RATS Windows
The most confusing part about RATS is that it has three different modes and operates slightly different depending upon which mode you are in. RATS tells you which mode you are in at the bottom left hand corner of the screen. The three modes are Ready, Local, and Edit. The program starts you off in Ready mode, with only a single window. You need not use Edit mode, or more than one window, unless you want to. If you want to keep things simple, you will only have one window (within which you will both type in your code and examine your output) and you only have to worry about Ready mode and Local mode. Use "Control-L" to toggle back and forth between Ready and Local.
At the top of any RATS screen for version 4.2, you see 4 menus: File, Edit, Windows, and Help. To access these menus, you type "Alt-F", or "Alt-E", etc, or else you can use the mouse to pull down the menus. If you are using version 4.0 (and perhaps 4.1--I can't remember) you will have a 5th menu which is for Graphics. The main difference between version 4.2 and the earlier version is an improvement and simplification of the graphics capability.
Eventually you will want to use more than one window. To open a new window, type "Alt-F" then use the arrow keys to find 'new' (the fact that you get a new window by accessing one of the "file" commands, rather than one of the "window" commands is a bit confusing). Then type "Alt-W" and hit enter when you scroll down to 'output'. This window will now be your output window; the other one will be your input window. Hit "F8" to switch back and forth between them.
Within Ready mode, any commands that you type in will be immediately executed as soon as you finish typing the line. If you have a separate output window, when you execute a line you won't see anything on the screen; you have to hit F8 to see the output. Much of the time you will want to type in several commands before you want them to be executed; to do this you need to be in Local mode. Within Local mode, the screen works like a word processor. You can type in a bunch of commands and when you are ready to execute them you use "Control-L" to switch back to Ready mode. Then you simply highlight the lines of code you want to execute by holding down "Shift" and hitting the up and down arrow keys, and then hitting "Enter". Alternatively, you can write your commands in a text editor, save them as ASCII text, and input the command file with "Alt-F" then "Open". The important thing to remember, no matter how you generate your commands, is that the "Ready" word must appear in the bottom left corner of your screen. You can change whether a window is used for input or output by hitting "Alt-W" and either "Input" or "Output".
Writing RATS Code
You can use RATS for cross-sectional analyses, but its strength is in time series analysis. The following description assumes that your data are time series. The first command for any RATS program is the Calendar command. For most of you, your command will look like
calendar 1959 1 1where the "1959" is the beginning year, the first "1" is the period the data starts (1 for annual data), and the second "1" is the number of periods per year (1 for annual data, 12 for monthly, etc.). The next command is the allocate command, which looks like
allocate 1994:36where 1994 is the end year for the data and the "36" indicates total number of observations. Alternatively, your can skip the calendar command and just tell RATS the number of observations within the allocate command, e.g.,
allocate 36In the next line, you will open a data file; it will look something like
open data c:\mydata.wk1Note that you need the full DOS extension, and your path probably will be different than the one listed above. Next, you will read in the data.
data(format=wks,org=obs)The "format=wks" indicates that you file is in Lotus 1-2-3 format. Note that is command, and all others in RATS that use parentheses, has no spaces before the left parenthesee or within the parentheses. You will get an error message if you put in a space.
To run a regression, use the linreg command. It will look like
linreg opinion /
# constant unempThis is a basic regression, using all the cases. The dependent variable is on the first line and the independent variables are on the second line. Note that you must explicitly include the constant if you want one. You can do lots of interesting things by using the options available in the linreg command slightly; here we will discuss only saving residuals. To do this, use a command like
linreg opinion / resid1
# constant unempResid1 is now a RATS variable that you can use to do other things (e.g. graph it or regress it on other variables).
Graphing Variables
To graph variables over time (with time on the X-axis), type the following commands, substituting your variable names. The 2 after the graph tells RATS to graph 2 variables on one graph. You can change it as needed to graph any number of variables (one or more) on the same graph.
graph 2
# opinion
# unempTo do scatterplots (where one variables is plotted against another), type
scatter 1
# unemp opinionIn the example here, unemp will be on the X-axis and opinion will be on the Y-axis. You can label the axes and the top of the graph as follows.
graph(hlabel='time',vlabel='unemp',header='unemployment $ from 1970-92') 1
# unemp
scatter(hlabel='unemp',vlabel='opinion',header='Opinion vs. $
Unemployment') 1
# unemp opinionNote that there is no space before the left parenthesee, or anywhere within the parentheses. Note also that the "$" that appear at the end of the lines above indicate that the command is being carried over to the next line. You will get an error message if you have a command that covers two lines and you fail to include the "$".
Your graph or scatterplot will be displayed on the screen; hit any key to return to RATS. To print your graph or scatterplot in RATS version 4.2, point the mouse at the "print" box at the bottom of the screen right after you are down viewing the graph. In RATS version 4.0, to print your graph or scatterplot, hit "Alt-F then scroll down to "Print". In either case, you can print only the last graph or scatterplot that you viewed. You may have to play around with the printer setup (in the file menu) to make sure you have specified the connection to your printer properly.
Additional Info
Once a program is typed in, it can be saved by hitting "Alt-F" then using the arrows to scroll down to 'Save As'. You must give the full DOS file extension when saving a program. You can retrieve a previously saved file by using "Alt-F" then 'Open'. You can save either, or both, your input and output files. (Recall that "F8" lets you switch back and forth between the two windows.)
Box-Jenkins Models
To use to identification procedure within RATS, you have to include the command
source(noecho) c:\rats\bjident.srcAgain, remember that there is no space before the left parenthesee. This command tells RATS that you are using one of the procedures that aren't part of the software, but have been written explicitly for it. You can include the command at any point before you try to identify a model, but standard practice is to make the command the first line of your program. To identify a model, use the command
@bjident series_nameThis will give you, in numerical form, the autocorrelations and partial autocorrelations for the series you requested. If you would rather see the a bar graph with the autocorrelations and partial autocorrelations, use the command
@bjident(graph) series_nameIn RATS version 4.2, you get the graph automatically. To estimate a model, use the "boxjenk" command. There are a number of options that go along with it. In the basic form, you specify the order of integration (if any), the number of autoregressive parameters (if any), and the number of moving average parameters (if any). You will usually save the residuals and then run the identification procedure on them. For example, to estimate a (0,1,2) model and analyze the residuals, you would use the commands
boxjenk(diffs=1,ma=2) series_name / res
@bjident(graph) resThe "difference" command, not surprisingly, will create a new variable that is the first differences of the variable you specify. The variable before the "/" is the current varible, while the variable after the "/" is the first differences that you are creating. An example of the code is
difference unemp / dunempYou can name the residuals whatever you want; I have chosen to call them "res." Note that if you want an intercept estimated, you have to indicate this explicitly, e.g.
boxjenk(constant,diffs=1,ma=2) series_name / resYou also can estimate a multivariate model with the boxjenk command. To do this, you have to indicate the number of explanatory variables, which will be one if you are estimating a basic intervention model. Also, you have to indicate on a separate supplementary card for each input variable the number of lags in the numerator (omega parameters) and the number of lags in the denominator (delta parameters). A typical intervention estimation would look like this:
boxjenk(constant,input=1,ar=1) series_name / res
# intervention_name 0 1The easiest way to estimate an intervention model is to have the string of 0's and 1's defined in your spreadsheet as a separate variable. You would insert the variable name of the intervention in the slot I have called "intervention_name." These instructions should be sufficient for your assignments for the course, but there are many more options and features available within RATS. In you're interested in the other features, chapter 7 of the manual covers Box-Jenkins models.
Trouble-shooting
Given that non-linear estimation is more complicated than linear estimation, you are more likely to encounter problems. You may run into error messages telling you that the program failed to converge after the requested number of iterations. The default number of iterations and subiterations in RATS are fairly low, 20 and 10 respectively. It is easy to raise these defaults. To change the number of subiterations, before you run the boxjenk command you should include a command with the form
nlpar(subiterations=30)where you can pick the maximum number of subiterations. Similarly, to raise the number of iterations, include a change within the boxjenk command, e.g.
boxjenk(constant,diffs=1,ma=2,iterations=40) series_name / resThese instructions are a streamlined version of what RATS is capable of. The manual is generally well-written and clear, and it will give you the full range of options available in RATS. Also, the help menus within RATS are quite useful. Feel free to e-mail me (msmith@polisci.umn.edu) if you run into problems with the software.
Below is a copy of the code I used to estimate an intervention model, which I will cover in more detail on Friday, February 23.
source(noecho) k:\rats\bjident.src
allocate 0 217
open data h:\8125\welfare.wk1
data(format=wks,org=obs)
nlpar(subiterations=30)
@bjident(graph) welillin
difference welillin / dwel
@bjident(graph) dwel
boxjenk(constant,diffs=1,ar=1,iterations=40) welillin / res1
@bjident(graph) res1
boxjenk(constant,input=1,diffs=1,ar=1,iterations=40) welillin /
res2
# cut 0 1
@bjident(graph) res2Happy estimating.
VAR in RATSTime Series Gang,
Below are some sample instructions for data assignment #5 on VAR.Getting RATS to estimate a VAR system is pretty easy; understanding the principles behind the estimation is the tough part. Chapter 8 of the RATS manual gives a full description of the software's capabilities. I'll give you the basics here.
To estimate a VAR system, you will use a group of about 5 RATS commands. You specify the number of equations, the list of variables, and the number of lags using, respectively, the "SYSTEM", "VARIABLES", "LAGS" commands. With the "DET" command, you specify the predetermined variables, which usually will be only the constant. You will use the "END" command to indicate the end of the system, which you will then estimate using the "ESTIMATE" command.
An example of how to estimate a 5-variable VAR system, using 4 lags, follows below.
allocate 0 200
open data h:\8125\var2.wk1
data(format=wks,org=obs)
system 1 to 5
variables caspop demleg fyincpc fyunemp drfyipc
lags 1 to 4
det constant
end(system)
estimate(outsigma=v)
RATS will automatically give you the F-statistics for each of the bivariate direct Granger causality tests. (See Example 8.2 in the RATS manual, page 8-7, if you want to do a causality test for a block of variables.)
Basic innovation accounting is done with the "IMPULSE" command. The example below has 5 equations and traces the effects for 20 periods of a shock to each variable. The use of the "*" character in the command indicates that the impulses are desired for each independent variable on each independent variable. Given that there are 5 variables, there will be 25 total impulses (5x5). Note that "v" is the "outsigma" matrix saved above.
impulse 5 20 * v # 1 * 1 1
# 2 * 1 2
# 3 * 1 3
# 4 * 1 4
# 5 * 1 5
See the RATS manual, example 8.3 on page 8-15, for an example of how to do this same innovation accounting, with the impulse responses graphed rather than merely listed. I've tested out the code for example 8.3 and it works.