Econometrics Eviews 1
Econometrics Eviews 1
TUTORIAL 0
The first tutorial explains the basic commands of the EViews software
(version 10). No prior knowledge of the software is required; students are only
supposed to have a basic knowledge of the computer room and of econometric
principles.
We will use the data contained in the gasoline.xls file (you can access
the file from the moodle page of the course). This file contains 76 quarterly
observations and 4 variables (the data relate to the United States): 1) OBS,
(observation identifier, from 1959 : 1 to 1977 : 4); 2) Q, real term per capita
expenditure on gasoline; 3) P , gasoline price (in real terms); 4) M , real term
per capita disposable income.
ln qi = β0 + β1 ln pi + β2 ln mi + εi (1)
where:
ln q is the variable to be explained (dependent variable);
ln p and ln m are the explanatory variables (independent variables or regres-
sors);
β0 , β1 and β2 are the parameters to estimate;
ε is the error term, normally distributed with 0 mean and unknown variance
σ2.
Notice that
∂q p ∂ ln q
ηqp = = = β1
∂p q ∂ ln p
∂q m ∂ ln q
ηqm = = = β2 (2)
∂m q ∂ ln m
1
so that the parameters β1 and β2 are demand elasticities with respect to
price and disposable income. Do you have any theoretical reason to suppose
something about the sign and magnitude of these coefficients?
y = β0 i + β1 x1 + β2 x2 + ε (3)
Notice the on line Help (from the main menu), the manuals in pdf version and
the web site http://www.eviews.com, where you can also find information
about two student versions of the software (one of them, Eviews Student
version Lite, is completely free).
2
1.2 How to create a workfile
The usual“file” has been substituted in EViews by the so-called “workfile”. A
workfile is a object container, i.e. “a collection of information and operations
interrelated the one with the others and linked in an user friendly way”.
EViews creates an empty workfile with no name and show the workfile win-
dow.
Notice the range and the sample. The only objects in the workfile are the
coefficient vector (c) and the residual series (resid), which are contained by
default in any workfile.
NB: the excel file is ordered by observation and contains a row with variable
names.
The command to import a file is the following (from the workfile or the
EViews menu):
3
Proc...
Import from file...
Search your desktop / pendrive folder in the shown window and click on the
gasoline.xls file.
NB: From version 6 onwards, you can also create a new workfile by opening
files saved with other econometric/statistical/database programs. In such a
case, the command to use is:
File...
Open...
Foreign Data as Workfile...
Check that the data have been correctly imported. Click twice on
the “q” series and check that observations go from 1959, first quarter to 1977,
last quarter.
4
Subsample selection Modify the sample by selecting from 1959:1 to 1966:2
The command to use is (you can access it from the workfile or the EViews
menu)
Proc...
Set Sample...
New series generation EViews allows the user to create new series by
transforming the original ones. To this end, you can use the operations
sum (“+”), substraction (“-”), power elevation (“ˆ”), multiplication (“*”),
division (“/”), natural logarithms (“log”), etc.
There are also logical operators: (“>”, “≥”, “<”, “≤”, “=”, “<>”, “or”
(union), “and” (intersection)). The program also allows you to easily create
lags and leads and differences of the original variables.
Quick...
Generate series...
or
Genr...
Example 1 Create three new variables: the logarithms of the quantity (LNQ),
the logarithms of the prices (LNP) and the logarithms of disposable income
(LNM).
NB: set back the workfile sample before creating the three new variables.
5
2 Descriptive statistics and tests on mean and
variance
2.1 Single series
Open the “lnq” series with a double click, or after selecting the series, with:
View...
Open selected...
One window...
from the workfile menu.
choosing afterwards
Histogram and stats
or
Stats table
or, if you want to perform test on the mean or on the variance:
Simple hypothesis tests...
Example 2 Suppose the population from which the sample has been drawn
follows a Normal distribution. Test with a significance level α of 5% that the
mean µ of the log quantity is equal to −10 and that the variance σ 2 is equal
to 0.0225 (i.e. the standard deviation σ is equal to 0.15).
EViews shows the value of the statistics and the corresponding p-value. As
the p-value is lower than α for the first test and higher for the second, we
reject the null only in the first case.
6
2.2 Multiple series
EViews allows to compute descriptive statistics and to perform tests on
means and variances for groups of variables as well. To this end, you have
to create a new object: a group, i.e. a list of variables that allows one to
simultaneously access all the elements of the list.
1) select the series to insert into the group, click with the right button and
select:
open...
as group
2) select the series to insert into the group, click (from the workfile or the
EViews menu) on:
Object...
New Object...
Group...
and then click on the OK button.
3 Graphs
3.1 Single series
To create a graph, open the series and click on
View...
Graph...
and choose one the following options: “Line & Symbols, “Bar, “Spike”,
“Area”, “Dot plot” (four different types of graphs, with the observation iden-
tifier in the x-axis and the value of the variable in the y-axis), “Distribution”,
“Quantile-quantile”, “Boxplot”, “Seasonal graph” (overlapping or separate
graphs with a line for each season against the number of observation).
Once you have chosen the graph type, you can modify the settings through:
7
Objects...
View Options...
Options
or double click on the graph area or push the right button of the mouse and
choose “options”
View...
choosing then
Graph...
Some of the options are: “Line & Symbols”, “Bar”, “Spike”, “Scatter”,
“XY line” (graphs where subsequent observations are linked by lines), “Error
bar” (useful when one wants to make predictions), “High-low (open-close)”
(useful for describing assets’ price movements), “Pie” (proportion of each
variable on the group total), “Distribution” (characteristics of each series).
Example 3 Make a graph with “lnp” in the x-axis and “lnq” in the y-axis
with the corresponding regression line.
Notice that graphs and tables can be easily exported, for instance in Excel
and/or Word.
8
5 Regression Analysis
The command to perform a regression in EViews is the following (from the
EViews menu):
Quick...
Estimate equation...
Alternatively, you can use the command (from the EViews menu or from the
workfile toolbar)
Objects...
New object...
Equation...
and subsequently writing the dependent variable (lnq) followed by c (to in-
clude a constant) and by the independent variables (the logs of price and
disposable income).
9
The regression output is composed of three parts:
10
Different visions of the equation
• Representations
• Estimation output
• ARMA structure
• Covariance matrix
• Specify/estimate
• Forecast
• Make model
Example 4 Save the residuals in a series (“residuals 1”) and plot the de-
scriptive statistics and the histogram. Verify the following algebraic property
(stemming from the first normal equation):
n
X
ei = 0 (5)
i=1
11
Example 5 Create a new variable equal to the product of the residuals and
the log price (residuals x lnp = residuals 1 * lnp). Verify the following alge-
braic property (stemming from the second normal equation)
n
X
xi ei = 0 (6)
i=1
i.e. the sum of the product of residuals and each regressor equals 0.
In our case, the F statistics, which under the null follows an F2,73 distribution,
is 1064.125 with a p-value of 0.0000.
12
5.2 Linear restrictions on coefficients
Linear restrictions on the parameters can be tested with two different ap-
proaches: the t test and the F test.
The first method relies on the fact that the linear restriction–being a function
of random variables (the estimators of the coefficients)–is a random variable
as well. As such, it has an expected value under the null and a standard
deviation; in turn, it is possible to evaluate how plausible is–in statistical
terms–the restriction by evaluating the restriction in the sample and assessing
how distant it is (in terms of the estimated standard deviation) from the
expected value under the null.
The second method relies on the comparison of the Sum of Squared Residuals
of the restricted model (i.e. the one estimated with the restriction imposed)
and the Sum of Squared Residuals of the unrestricted model, whose param-
eters are free to take any value.
Needless to say, when only one restriction is tested both methods lead to the
same statistical test decision.
View...
Coefficient Diagnostics...
Wald - coefficient restrictions...
and specify the restriction in the dialog window. Notice how the coefficients
must be identified with c(1), c(2), c(3), etc. and how you can recognize the
coefficient associated at each variable through the command:
View...
Representations...
EViews shows both the value of the F -statistics and of the corresponding
p-value and the elements for the computation of the t-statistics (estimated
13
restriction minus the value of the restriction under the null, estimated stan-
dard error of the restriction).
Example 6 Test the linear restriction that the income elasticity equals the
opposite of the price elasticity, i.e. the null hypothesis to test is : H0 : −β1 =
β2 vs H1 : −β1 6= β2 .
Notice that the command for testing linear restrictions allows one to test
single and joint hypotheses on the coefficients.
After opening from your directory the gasoline.wf1 file, follow the follow-
ing operations by a) writing the command in the command window and b)
pressing enter in the keyboard:
series constant=1
14
vector y=lnq
matrix x = regressors
5. create X0
matrix xprime=@transpose(x)
matrix xprimexinv=@inverse(xprimex)
vector xprimey=xprime*y
vector b=xprimexinv*xprimey
vector res=y-x*b
15
15. compute the coefficients’ variance covariance matrix
matrix varcovb=s2*xprimexinv
16