0% found this document useful (0 votes)
37 views16 pages

Econometrics Eviews 1

This document introduces the EViews software and provides instructions for basic operations within the software such as importing data, generating new variables, descriptive statistics, and graphing. It explains how to open EViews, create a workfile, import an Excel dataset, generate logarithm variables from the raw data, select a subsample, and request descriptive statistics and hypothesis tests on the mean and variance for single and multiple series. It also demonstrates how to create line, bar, and other graphs for single and multiple series within the software.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views16 pages

Econometrics Eviews 1

This document introduces the EViews software and provides instructions for basic operations within the software such as importing data, generating new variables, descriptive statistics, and graphing. It explains how to open EViews, create a workfile, import an Excel dataset, generate logarithm variables from the raw data, select a subsample, and request descriptive statistics and hypothesis tests on the mean and variance for single and multiple series. It also demonstrates how to create line, bar, and other graphs for single and multiple series within the software.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

ECONOMETRICS

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.

With these data we will estimate a demand function with disposable


income and price as explanatory variables (regressors), in a log-log specifica-
tion. Alongside with parameter estimation, we will perform hypothesis tests.
We will also learn how to use EViews by writing commands in its own syntax
and how to use it in the batch mode.

The equation to estimate is:

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?

For notational convenience let y = ln q, x1 = ln p and x2 = ln m. In matrix


notation, the model to estimate is:

y = β0 i + β1 x1 + β2 x2 + ε (3)

1 THE EVIEWS SOFTWARE (Version 10)


It is an econometric software with a thorough array of econometric func-
tions. These functions are built-in and can be accessed via menu and mouse.
However, the software can also be used through its own syntax and programs.

Alongside with purely econometric functions it also allows basic statistical


analyses (descriptive statistics, hypothesis tests).

1.1 How to open EViews


You can open it by double clicking on the Eviews10 icon on the desktop.
There are several areas in EViews:

• The title bar

• The main menu

• The command window

• The work area

• The status line

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”.

To create a workfile you can use the following command:


File...
New...
Workfile
and then specify a data structure: 1) Unstructured/Undated for cross sec-
tional data (and then specifying the number of observations); 2) Dated/regular
frequency for time series data (and then specifying the frequency: annual,
weekly, etc., and a range, i.e. the interval between the first and the last
observation in our sample); 3) Balanced panel for panel/longitudinal data
set (and then specifying alongside with the frequency and the range also the
number of cross sectional units).

Specify the Quarterly frequency and a range from 1959:1 to 1977:4.

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.

1.3 How to import an Excel data file


The gasoline.xls file contains 76 quarterly observations for four variables: 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.

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.

The workfile window contains 4 areas:

• The title bar

• The instrument bar

• The status information area

• The workfile directory area

Save the workfile into your desktop / pendrive by clicking on


File...
Save as...
or on
Save
in the instrument bar

EViews will save the file with the “.wf1” extention.

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...

specifying the data type and following EViews indications.

1.4 Some basic operations

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.

To create a new variable two alternatives are available:

• from the EViews menu:

Quick...
Generate series...
or

• from the workfile menu:

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.

To request descriptive statistics for a variable, the command to use is


View...
Descriptive statistics & tests...

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).

N.B.: if the variance of the population is known, the sampling distribution


of the sample mean duly transformed is the standard normal. Otherwise, the
sample mean duly transformed follows a Student t distribution with n − 1
degrees of freedom.

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.

There are two ways to create a group:

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.

To save the group as an object press on


name
from the group menu and specify a name.

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”

3.2 Multiple series


Open the group we have saved and click on

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.

4 How to create graphs and tables


A given vision of an object (series, groups, equations, etc.) can become a
new “autonomous”EViews object (graph or table) which is no more linked
to the original object. In this way, the table or the graph can be edited and
do not change once the original object is modified.
To create an EViews graph or table it is sufficient to use the command
“freeze” from the menu of the original object. EViews “snaps” the vision
of the object so that the vision becomes an object in itself and it can be
subsequently edited (through the “procs” button in the toolbar of the new
object or from the EViews menu bar).

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).

The regression output is:

9
The regression output is composed of three parts:

1. General information (dependent variable, estimation method, sample,


number of observations).

2. Variables, estimated coefficients, estimated standard errors of the esti-


mators, t-statistics of the null hypothesis that each coefficient equals 0
and the corresponding p-value.

3. Statistics of the regression (R2 , standard error of the regression, etc.).

Notice how R2 (the adjusted R2 ) is given by the formula:


 n−1 75
R2 = 1 − 1 − R2 = 1 − (1 − 0.966837) = 0.965928 (4)
n−K 73
where K is the number of estimated parameters, constant included.

Save the equation as an object (“equation 1”).

10
Different visions of the equation

• Representations

• Estimation output

• Actual, fitted, residual

• ARMA structure

• Gradients and derivatives

• Covariance matrix

• Coefficient tests, Residual tests and stability tests

Procedures with the equations

• Specify/estimate

• Forecast

• Make residual series

• Make regressor group

• Make gradient/derivative group

• Make model

• Update coefs from equation

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

i.e. the sum of residuals equals 0.

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.

5.1 Simple hypothesis testing on coefficients


We have to distinguish the case where the coefficient value under the null is
0 and the case where it is different from 0.
In the first case it is sufficient to read the p-value of this null hypothesis
in the output table. In the second case it is necessary to compute the test
bk −b∗k
statistics as se(bk ) and compare the obtained value with the critical values of
a t distribution with n − K degrees of freedom for a given α.
Hypothesis H0 : βi = 0 vs the alternative H1 : βi 6= 0 (with i = 0, 1, 2).
As
 it can  be seen in the output table the statistics for these null hypotheses
bi −0
se(bi )
are–respectively– −10.60, −4.288 and 43.904 with p-values lower
than 1%.
Hypothesis  H0 :β2 = 1 vs the alternative H1 : β2 6= 1
b2 −1
Under H0 , se(b 2)
∼ tn−3 ; in our case the statistics is 1.0865−1
0.0247
= 3.53 and
the critical values are (for α = 10%, 5% and 1%) t73;0,10 = ±1.666, t73;0,05 =
±1.993 and t73;0,01 = ±2.645. Therefore, we reject the null for any reasonable
significance level.
Notice also the F-statistics of the joint hypothesis H0 : β1 = β2 = 0 vs
the alternative H1 : β1 6= 0 and/or β2 6= 0. Under the null, the following
statistics follows a the Fisher F distribution with K − 1 degrees of freedom
in the numerator and n − K in the denominator:
ESS ESS
σ 2 (K−1) (K−1)
F = RSS
= RSS
(7)
σ 2 (n−K) (n−K)

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.

To perform a test in EViews, both methods can be “manually”used. In


the first case, it is sufficient to estimate the unrestricted model and use the
estimated coefficients and the corresponding estimated variance/covariance
matrix to compute the t-statistics. In the second case, you can estimate
both models (the unrestricted model and the restricted one) and compute
the corresponding F -statistics.

EViews allows to perform automatically this test. To this end, it is sufficient


to use the command:

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.

Example 7 Test H0 : β2 = 1 vs the alternative H1 : β2 6= 1

Example 8 Test H0 : β1 = 0 and β2 = 0 vs the alternative H1 : β1 6= 0


and/or β2 6= 0.

6 How to compute the OLS estimates with


matrix algebra (and how to use EViews in
the batch mode)
To perform operations on matrices in EViews it is necessary to use the com-
mand window.

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:

1. create the constant

series constant=1

2. create the group with the regressors

group regressors constant lnp lnm

3. create the vector with the dependent variable

14
vector y=lnq

4. create the regressor matrix X

matrix x = regressors

5. create X0

matrix xprime=@transpose(x)

6. create the inner product matrix X0 X

matrix xprimex= xprime * x

7. create the inverse matrix X0 X−1

matrix xprimexinv=@inverse(xprimex)

8. create the inner product matrix X0 y

vector xprimey=xprime*y

9. compute the coefficient vector

vector b=xprimexinv*xprimey

10. compute the residuals vector e = y − Xb

vector res=y-x*b

11. compute the sum of squared residuals


matrix res2=@inner(res)

12. transform the matrix into a scalar


scalar ssr=res2(1,1)

13. compute the degrees of freedom


scalar dof= @rows(x) - @columns(x)

14. compute s2 , estimate of the error variance


scalar s2=ssr/dof

15
15. compute the coefficients’ variance covariance matrix
matrix varcovb=s2*xprimexinv

16. compute the p-value for the intercept


scalar varcos=varcovb(1,1)
scalar secos=@sqrt(varcos)
scalar tcos=b(1,1)/secos
scalar pvcos=@tdist(tcos,dof)

17. compute the p-value for the lnp coefficient


scalar varlnp=varcovb(2,2)
scalar selnp=@sqrt(varlnp)
scalar tlnp=b(2,1)/selnp
scalar pvlnp=@tdist(tlnp,dof)

18. compute the 95% confidence interval for lnp


scalar inflnp=b(2,1)-@qtdist(0.025,dof)*selnp
scalar suplnp=b(2,1)+@qtdist(0.025,dof)*selnp

16

You might also like