You are on page 1of 3

Intermediate EViews Tutorial

1. Introduction/Objectives

In Introduction, you learnt to…


• Open data in EViews
• Examine your data and perform simple statistical analysis
• Run a simple regression and plot results
• Perform specification and hypothesis tests
In this tutorial, you learn to…
• Program EViews (learn about EViews syntax)
• Generate data sets

2. Using commands interactively

Reference: “Commands and Programming”


The command window is located just below the main menu bar at the top of the EViews window.

Click on the window, and make sure a blinking insertion cursor appears in the first line.
Type “wfcreate(wf=unstruct) u 1000” and hit enter (denoted ¶), to create a new workfile with 1000
observations.
(In general, commands have three components: Command, Option, and Argument. For example, in the line
you just typed, wfcreate is a command, (wf=unstruct) is an option, and “u 1000” is an argument. For more
information, please read the help file.)
Type “series var_1=1” ¶, to create a new constant.
Type “series var_2=nrnd” ¶, to generate a variable drawn from standard normal distribution.
Type “var_2.line” ¶, to create a graph object.
Type “freeze(fig1) var_2.line” ¶, to freeze the graph object.
Type “cd G://”¶, to change the directory.
Type “wfsave temp”¶, to save the change in the workfile.
Type “close temp”¶, to close the workfile.
Type “open temp”¶, to open the saved workfile.
Type “exit”¶, to exit from the EViews.
3. Writing a simple program

a. Creating a program file and workfile


Save excel file “Intro_Eviews.xls” under G: drive, we will import this file as a data source.
Back to EViews screen.
Type “program simple”¶, to create a new program.
From now on, type your commands in your program file.
Type a single quote ‘ followed by your name. This is how you write comments in EViews. Ex)’John Smith
Type “cd G://”¶, to change the directory (folder) you are working on.
Type “wfcreate(wf=intro) q 1952:1 1996:4”¶, to create a new workfile named intro.
Type “read Intro_Eviews.xls 5”¶, to import the excel file.
Run the program. Confirm that you imported the data properly.

b. Examine the data


Type “freeze(d1) gdp.stats”¶, to examine the descriptive statistics.
(“freeze” command create an object, instead of merely displaying the result. The option (ex. “(d1)” is a name
of the object newly created. In this case, we created a new object named “d1” that contains the descriptive
statistics of the variable “gdp”).
Type “freeze(g1) gdp.line”¶, to generate a line graph.
Type “g1.addtext(t) “Fig.1 : Real GDP” “¶, to add a description into the graph.
Type “gdp.uroot(adf,const)”¶, to test the variable against the unit-root process.
Run the program. By typing “show a1”¶ and “show g1”¶, confirm that the descriptive stats and the graph
are generated properly. Does the unit root test confirm the series is stationary?

c. Editing the data


Type “gdp.label(d) Real GDP”¶, to add a display name of the variable gdp.
Similarly, type “gdp.label(u) Index (1950:1 = 100)”¶, and “gdp.label(d) Real GDP”¶.
Add descriptions for other variables as well.
Type “series lgdp=log(gdp)”¶, to generate the log-transformed variable.
Run the program. Confirm that the labels are changed, and the new variables are created.

d. Running a regression
Type “equation eq1.ls log(m1) c log(gdp) rs log(pr)”¶, to specify a model.
Type “group gp1 log(m1) c log(gdp) rs log(pr)”¶, to group the variables.
Type “freeze(g2) gp1.line”, to plot the variables over the time.
Run the program. Is the estimation good? Is there a possibility of spurious regression? How can you test it?

*See the sample code at the end of this document.


4. More commands and tips
a. Working with a “Working File”
Type “wfopen intro_eviews”¶, to open the workfile we have just saved.
Type “wfsave temp”¶, to save a working file and keep the original workfile untouched.
Type “close intro_eviews”.

b. Unit-root test
Type “freeze(u1) gdp.uroot(adf,trend)”¶, to test the variable against unit-root process. (By default, constant
term is included.)
See command reference “uroot” for more options.

c. Scatter Plots
Type “group gp2 gdp m1”¶, to group two variables.
Type “gp2.scat”¶, to get a scatter plot of three series.
Type “gp2.scat linefit”¶, to get a fitted (regression) line for those plotted variables.
See “Optional Graph Components - Auxiliary Spec” for more detail of “linefit”

d. Execute the program without error


When you run the same program again, EViews may return a error message such as “xxx already exists”. In
order to avoid this, try the following procedures.
Type “run(integer) program_filename”¶ in interactive window, to execute the program while suppressing
errors. EViews avoids error as many times as specified in the option. Any error message suppressed will be
shown after running the program.

Sample code:
'John Smith
‘Last modified: 4/5/2008
cd G:/
wfcreate(wf=intro) q 1952:1 1996:4
read Intro_Eviews.xls 5

freeze(a1) gdp.stats
freeze(g1) gdp.line
g1.addtext(t) "Fig1: Real GDP (1950:1 = 100) 1952:1-1996:4"

gdp.label(d) Real GDP


gdp.label(u) Index (1950:1 = 100)
gdp.label(d) Real GDP

equation eq1.ls log(m1) c log(gdp) rs log(pr)


group gp1 log(m1) log(gdp) rs log(pr)
freeze(g2) gp1.line

wfsave intro_eviews

You might also like