Last modified: 2003 Jun 06
This is very much in progress. I'd say it's about half done. Perhaps it will prove of some use in its current state.

Introduction to EViews

EViews is a state-of-the-art, user-friendly econometric package with a strength in time-series analysis. It is currently available only for the Windows operating system. On the AU campus, EViews is available as an EagleNet application.

EViews comes with extensive documentation in the form of two online books: the Command and Programming Reference and the User's Guide. You should read chapter 3 ("EViews Basics") of the User's Guide. You should always read about each command and option you use in the Command and Programming Reference. Aside from that, read these resources selectively. They are very helpful, but the User's Guide focuses unfortunately on the "point-and-click" approach to data analysis, which is a very bad approach to serious empirical research. (Specifically, it renders replicability impossible.) Much of what follows below is just text from the User's Guide, altered to be more command oriented.

Preliminaries

I have seen students try to program with "hunt and peck" typing. Do yourself a favor and acquire some basic keyboarding skills. These can be quickly acquired. There are surely many sources of cheap software assistance. On Linux and Windows there is the free, open source TuxType. The GNU Typist has multi-language support, but I did not find a Windows version. (There is also the console based TypingTutor, but development seems to have ground to a halt.) Here is one inexpensive commercial product that I am aware of: MavisBeacon. I welcome recommendations of competitive products.

Importing Data

In your courses, you are often given your data in a format ready to use with your data analysis program. The "real world" is not so coddling. Often you will get data from a CD or off the web in a format that needs to be "cleaned" before you can use it. Sometimes you will need to enter data from "hard copy" sources.

Your data may be available in a variety of forms: machine readable spreadsheet, a text file that you created yourself or downloaded from the World Wide Web, or perhaps even as hardcopy or a graphics file. We want to input this data into series and group objects. (We omit for now any discussion of input into EViews matrix, vector and pool objects.) The question you face is: how can you get this data into EViews? There are four basic answers. i. If the data are preformatted for you, you may be able to copy and paste into EViews. I have had best luck with single series. ii. If the data are not quite so well arranged, you may still be able to read them into a modern spreadsheet and then export them to EViews. Recent versions of Excel seem pretty good at importing HTML tables. iii. You may have to clean up the data with a text editor, and then import it into EViews. iv. In the worst case, when the data is presented as graphics instead of text or is otherwise difficult to download, you will have to copy the data observation by observation.

Entering Data by Hand

For small data sets in printed form, you may wish to enter the data by typing at the keyboard. For larger data sets only available in hardcopy (or as graphics), OCR programs such as TextBridge are also useful. In generaly, however, these should be last choices: they are time consuming and error prone methods of data set creation.

To open a spreadsheet window in which you will enter the data, first declare your series. For example, series series1. Second, create a group of these series. For example, group mygroup series1 series2. Display the sheet view of this group either by double-clicking the group name or with the sheet command. For example, mygroup.sheet. To enter the data, click on the appropriate cell and type the number. (You may need to click the Edit +/- button.) Pressing Enter after entering a number will move you to the next cell. If you prefer, you can use the cursor keys.

Copy and Paste

You can also use the Windows clipboard. The following discussion involves an example using an Excel spreadsheet, but the basic principles apply to other Windows applications. Begin in EViews by creating an empty group, just as we did for data entry by hand. Make sure to set your sample to match the sample of the data you are importing.

Open your spreadsheet in Excel. Highlight the cells to be imported into EViews. If there are column headings containing the variable names, highlight them as well. Do not copy the date column unless you need it for some reason. Click and drag across the data you want. You should see this data highlighted. Select Edit/Copy to copy the highlighted data to the clipboard. Make sure your EViews sample matches the sample for the data you copied, and then paste the new series into an empty group. (If you are pasting in the series names, first click on the up arrow in the scroll bar to make room for the series names.)

Note that when importing data from the clipboard, EViews follows the Windows standard of tab-delimited free-format data with one observation per line. Since different applications use different whitespace a#d delimiter characters, attempting copy-and-paste from nonstandard applications may produce unanticipated results.

Importing Spreadsheet Files

You can also read data directly from spreadsheet file in Lotus (.wks, .wk1 or .wk3) or Excel (.xls) spreadsheet formats. If you are reading data from a multi-sheet Excel workbook file, you can also enter the name of the sheet containing your data. (If you do not enter a name, EViews will read the topmost sheet in the Excel workbook.) First, you need to tell whether the data are ordered by observation or by series. By observation means that all of the data for the first observation are followed by all of the data For the second observation, etc. By series means that all of the data for the first variable are followed by all data for the second variable, etc. That is, ``by observation'' means that variables are arranged in columns, while ``by row'' means that all of the observations for a single variable are in a single row. Next tell EViews the location of the beginning cell (upper left-hand corner) of your actual data, not including any label or date inormation. Enter the names of the series that you wish to read. EViews reads spreadsheet data in contiguous blocks, so you should provide a name for each column or row (depending on the orientation of the data), even if you only wish to read selected rows. If the names that you wish to use for your series are contained in the file, you can simply provide the number of series to be read. The names must be adjacent to your data. If the data are organized by row and the starting cell is B2, then the names must be in column A, beginning at cell A2. If the data are organized by column beginning in B2, then the names must be in row 1, starting in cell B1. Finally, you need to tell EViews the sample of data that you wish to import. EViews begins with the first observation in the file and assigns it to the first date in the sample for each variable. Each successive observation in the file is associated with successive observations in the sample. Thus, in an annual workfile, if you enter the sample: 1971 1975 1990 1991 the first 5 observations will be assigned to the dates 1971–1975, and the sixth and seventh observations will be assigned to the dates 1990–1991. The data in the intermediate period will be unaffected by the importing procedure. If you read into a sample which has more observations than are present in your input file, observations for which there are no corresponding inputs will be assigned missing value codes.

Using a Text Editor

ASCII file import is considerably more complicated than spreadsheet import since there is no standard format for ASCII files. EViews provides you with a range of options to handle various types of ASCII files. ASCII file importing is explained in considerable detail in chapter 4 of the EViews User's Guide, and the ``Addendum: Reading ASCII Files'' is particularly helpful.

  1. We will focus on this case. This requires you to choose a text editor (I have arranged for TextPad and Vim to be available to you via EagleNet), You will copy the data and paste the data into a new text file, and then clean up the data a bit.
  2. Go to the web site, select the data (ONLY THE DATA) in your browser, and copy it to the clipboard. (To copy to the clipboard on a Windows operating system, you can generally use ctrl-c.) Choose a browser that reliably retain table formatting in the plain text copy. (I find Opera and K-meleon give predictable and orderly results.)
  3. Next open a new file in your favorite text editor and paste the copied data into this file. (To paste to the clipboard on a Windows operating system, you can generally use ctrl-v.) Save your data as an ASCII text file called, say, g:\hist1800.dat.
  4. Generally you will have to clean your data a bit. In particular, to be most useful, your data needs to be in columns that are separated only by spaces or tabs. Unfortunately, when you copy and paste this data it may not be formatted this way, and worse yet the formatting will vary to some extent with your choice of browser. In order to clean your data, you need to take a close look at it in your text editor. Be sure to turn on visible tabs so that you can see the spaces and tabs. (E.g., in TextPad pick View/visible spaces, and in Vim type :list. Then use your editor to format the data.
    Now you could of course go in and change the 200 observations by hand, one at a time. Or you might guess that people who work with data simply cannot be spending their time this way. Indeed, you can use regular expressions to reformat the whole file with a single command. E.g., you can search for a tab using "\t" and for an end-of-line as "\n". (In TextPad, pick Search/Replace from the TextPad menus, and be sure to check the Regular expression box before clicking Replace All. In Vim, all searches are for regular expressions.) Format your data into three columns. (Fix the first observation by hand by changing &hyph;&hyph; to NA, which is the EViews missing value code). Reminder: always visually check your data when this is feasible.
    You have now been initiated into the wonders of searching and replacing using regular expressions, a powerful tool used by everyone who does serious data analysis. Having formatted your data, you are now ready to import the data into EViews.
  5. Start EViews and create an annual workfile from 1800 to the present. Then import the data using one of the three following methods.
  6. Method 1: use the EViews menus.
    1. Pick from the menus: File-Import-Read
    2. In the dialogue box, give the filename as g:\hist1800.dat (or whatever you called it) and the file type as text-ASCII. Click OK.
    3. If you included a header in the file, giving the series names in the first row, just put in the number of series. (If you just kept the whole file, the number of series will be 3.) Otherwise, put in the series names you want to use. Be sure to include the date, so that you can check the accuracy of your data import. I will assume you named the CPI series `cpi'.
  7. Method 2: copy and paste.
    1. Create a series to hold the cpi data with the command series cpi.
    2. Open the spreadsheet view of this series with the command cpi.sheet. Click the Edit +/- button to make this view editable and place the cursor in the cell first observation (which will have an NA in it).
    3. Go to you text editor and copy the column with the CPI data.
      E.g., in TextPad you can do the following. Turn off word wrap (Configure/WordWrap) and select the column by holding down the Alt key as you use the mouse.
    4. Return to EViews and paste what you have copied into the spreadsheet view of the cpi series. You should see your data appear.
  8. Method 3: use the read command.
    1. Method 1 or method 2 will get you moving right away. But you should learn to do all this in your EViews program files. After you create a new workfile with the workfile command, you can import your data with the read command. (Be sure to read about these commands in the EViews help.) For example, assuming you have the data in hist1800.dat, and that you have added a single line above the data that contains the three series names, and you have changed one missing value to NA, then you can read the data into a new workfile as follows:
      
      workfile cpitest a 1800 2002
      read(t=dat,rect,name,label=1,d=s,mult) g:\hist1800.dat 3  
    2. Check your data import by double clicking the date series in your workfile and visually inspecting it.
Take as an example the task of getting some CPI data, which you must import into EViews. At the Minneapolis Fed, you will find long-run US price data from 1800.

Approaches to Data Analysis

EViews offers a "user-friendly", mouse-oriented environment. This "point-and-click" environment is very nice for getting acquainted with a data set, but is does not allow you to keep track of all that you have done when you are conducting empirical research. For this reason, after any initial exploration, you should always conduct your analysis by means of an EViews program. For this purpose, EViews allows you to create program (.prg) files. To start a new program file, pick File, New, Program from the EViews menus. A new program window will open. Enter EViews commands into the program window, the Save your program and Run it.

Unit Root Tests

  1. It can be useful to conduct a unit root tests initially in a point and click fashion and then to add to your .prg file the commands for producing your favored version.
    1. Click the View button in the Series window, and pick Unit Root Test. Do an Augmented Dicky-Fuller (ADF) test on the level of the d_lp series, with 4 lags, allowing for an Intercept. Click OK.
    2. Try a few other versions as well. Freeze the resulting table for your favored version, click Edit+/-, and add your name, date, and comments. Specifically, can you reject the presence of a unit root (i.e., is the test statistic more negative than the critical values)?
      Hint: If you wish to save this annotated table as part of your workfile, click Name, name it, and be sure to save your workfile before exiting EViews.

    Objects

    In EViews we work with "objects". Examples are series, groups, graphs, and tables. Series and groups hold data. Graphs and tables display data.

    All objects must be contained in an object container. The basic object container is the workfile. So generally the first thing you do when starting an EViews project is create a workfile.

    To create a workfile you need to know three things: a name for the workfile, a frequency of observation, and a range of dates. Create an workfile named temp intended to contain annual observations from 1800 to 2010 as follows: workfile temp a 1800 2010

    1. Pick File-New-Workfile from the EViews menus.
    2. Set workfile frequency to annual, and put your start date and end date in the dialogue box. Click OK.

    Basic Data Handling

    The process of entering, reading, editing, manipulating,and generating data forms the foundation of most data analyses. Accordingly, most of your time in EViews will probably be spent working with data.

    There are two cornerstones of data handling in EViews: data objects (especially series and groups), and the use of samples.

    Data Objects

    The actual numeric values that make up your data will generally be held in one or more of EViews' data objects (series, groups, matrices, vectors, scalars). For most users, series and groups will be, by far, the most important objects.

    Series

    An EViews series contains a set of observations on a variable. Associated with each observation in the series is a date or observation label. For series in dated workiles, the observations are presumed to be observed regularly over time. For undated data, the observations are not assumed to follow any particular frequency.

    Creating a series

    Suppose we have an active workfile in which we wish to "create" a series named x1. We do this by "declaring" the series with the "series" command series x1 Let us take a look at what we have created by looking at the "spreadsheet view" of this series. This is done with the "sheet" command. x1.sheet This command causes EViews to open a spreadsheet view of the new series object. Note that all of the elements of the series have been assigned the missing value code ``NA''. This is because we have not yet assigned any values to this series.

    There are many ways to assign values to the elements of a series. Two of the most common are: i. Assign values resulting from the mathematical manipulation of other series. ii. Assign values element by element.

    Example: Suppose our workfile contains a money supply series, M, and a price level series, P. We can set our new series mp equal to real money supply with the command mp=M/P Note that the division operation will be done element-by-element for every observation where both M and P do not have a missing value.

    Example: Suppose we want to set the first element of x1 to the value 15. We do this as x1(1)=15

    Changing the Spreadsheet Display

    Once you see the sheet view of a series, EViews provides you with some menu driven options for altering it. The default display has the observations for the series in a single column, with date labels in the margin. The wide display arranges the observations from left to right and top to bottom, matching the frequency of the data when this is sensible. Toggle between the wide and narrow views with the button labeled Wide +/-.

    You can also restrict the data dispaly to the current sample. By default, all observations in the workfile are displayed. Click Smpl +/- to toggle between showing all observations in the workfile and showing only those observations in the current sample.

    Groups

    When working with multiple series, you will often want to create a group object to help you manage your data. A group is a list of series names (and potentially, mathematical expressions) that provides simultaneous access to all of the elements in the list.

    With a group, you can refer to sets of variables using a single name. Thus, a set of variables may be analyzed, graphed, or printed using the group object, rather than each one of the individual series. Therefore, groups are often used in place of entering a lengthy list of names. Once a group is defined, you can use the group name in many places to refer to all of the series contained in the group.

    You will also create groups of series when you wish to analyze or examine multiple series at the same time. For example, groups are used in computing correlation matrices, testing for cointegration and estimating a VAR or VEC, and graphing series against one another.

    Creating Groups

    There are several ways to create a group. You should enter the names of the series to be included in the group. You can use group names as well as series names. If you include a group name, all of the series in the named group will be included in the new group. Note that only the series are contained in the new group, not the old groups itself. (That is, if you later add series to the old group, they will not be added to the new group.) Finally, you can include series expressions. Series expressions are mathematical expressions that may involve one or more series. EViews will evaluate the series expressions for each observation and display the results as if they were an ordinary series.

    You can also create an empty group that may be used for entering new data from the keyboard or pasting data copied from another Windows program. See ``Copying-and-Pasting'' on page 65.

    Samples

    EViews allows easy setting of the sample of observations. The sample is the set of observations in the workfile to be included in displays and in statistical procedures. Samples may be specified using ranges of observations and/or ``if conditions'' that observations must satisfy to be included. For example, you can tell EViews that you want to work with observations from 1953:1 to 1970:12 and 1995:1 to 1996:12. Or you may want to work with data from 1953:1 to 1958:12 where observations on a specified series exceed 0.

    The Workfile Sample

    When you create a workfile, the global or workfile sample is set initially to be the entire range of the workfile. The workfile sample tells EViews what set of observations you wish to use for subsequent operations. Unless you want to work with a different set of observations, you will not need to reset the workfile sample.

    The current workfile sample of observations is displayed at the top of your workfile window.

    Changing the Sample

    The workfile sample is set with the smpl command. For example, smpl 1955 1973 1990 2000 tells EViews to use observations for 1955 through 1973 and observations for 1990 through 2000 in subsequent operations; observations from 1974 through 1989 will be excluded.

    EViews lets you restrict the sample by adding if conditions: smpl 1955 1973 if var1>var1(-1) tells EViews to use in subsequent operations those observations for 1955 through 1973 for which var1 has risen relative to its previous period's value. Your if conditions can contain ``or'' and ``and'' operators: smpl 1955 1973 if var1>var1(-1) and var2<var2(-1) tells EViews to use in subsequent operations those observations for 1955 through 1973 for which var1 has risen relative to its previous period's value and var2 has fallen relative to its previous period's value. (Use parentheses to group the conditions and operators whenever the order of evaluation is otherwise ambiguous.) Should a comparison in the if condition encounters a missing value, EViews evaluates the condition to false (so the observation will not be included in the sample).

    EViews provides some keywords that make entering sample ranges easier. The keyword ``@all'' refers to the entire workfile range. The keywords ``@first'' and ``@last'' refer to the first and last observation in the workfile. Thus, the following sample ranges are identical:

    smpl @all 
    smpl @first @last 
    

    Sample range elements may contain mathematical expressions. For example, the sample string 1955:1 1955:1+11 defines a sample that includes the 12 observations in the calendar year beginning in 1955:1. EViews expects date offsets that are integer values: use the ``@round'', ``@floor'' or ``@ceil'' functions to force non-integer numbers to integer values. This feature can be used to set up a fixed width window of observations.

    Basic Data Handling

    Sample Objects

    If you work with well-defined subsets of your data, you will find sample objects to be indispensable.

    Creating a Sample Object

    Declare a sample object named period1 with the command sample period1 1970 1980. Note that a sample object cannot be declared without an assignment (up through EViews 4).

    Using a Sample Object

    Type the keyword smpl followed by the name of the sample object: smpl period1.

    You can also type the keyword smpl followed by the name of the sample string: smpl 1955:1 1958:12 if rc>3.6.