Sie sind auf Seite 1von 19

Applied Statistics and Econometrics Eviews Class

Birkbeck College
Department of Economics,
Mathematics, and Statistics.
Graduate Certificates and Diplomas
Economics, Finance, Financial Engineering

2011-2012
Applied Statistics and Econometrics
Eviews Class

Raphael Brun-Aguerre
rbrun-aguerre@econ.bbk.ac.uk
Elisa Cavatorta
ecavatorta@ems.bbk.ac.uk

Applied Statistics and Econometrics Eviews Class

CONTENTS
1. Presentation
1.1 Before Eviews: the data
1.2 Eviews: the main window
1.3 How to use Eviews: graphical user interface vs. programming
2. Starting with Eviews
2.1 Creating a workfile
2.2 Importing Data
2.3 Looking at the data
2.4 Descriptive statistics
2.5 Stationarity
2.6 Transforming and creating series
2.7. Doing a regression in Eviews
3. Interpreting, modifying and testing a regression
3.1 Regression output
3.2 A different specification: ratios and dynamics
3.3 Misspecification / Diagnostic tests
3.4 Specification tests
3.5 Using a dummy variable
4. Programming in Eviews

Applied Statistics and Econometrics Eviews Class

1. Presentation
1.1 Before Eviews: the data
Eviews is a statistical software and needs data to work with. The data can be stored in
different formats: Excel spreadsheets, text files, etc... It is essential to understand the
specificities of such formats to import the data correctly in Eviews. In this course, the
underlying
data
is
saved
in
an
Excel
file
(http://www.ems.bbk.ac.uk/for_students/grad_dip_economics/ase_EMEC002U/index
_html then Data for exercise). You should be familiar with the Excel environment
and should be able to answer the following questions: Where is the data saved? What
is the name of the file? What is the name of the page? In which range (cells) is the
data located? In which range (cells) are the series names located? In which range
(cells) are the dates located?

1.2 Eviews: the main window


This course assumes that Eviews is installed on your machine. To open the software
in Windows, just click all programs/Eviews7 (If you are using Eviews7).
The opening Eviews window is composed of 3 blocks:
1/ At the top, the main menu offers a selection of drop-down menus: File,
Edit, Object, View, Proc, Quick, Options, Window and Help.
2/ Just below the menu is the white command window. EViews commands
may be typed in this window. The command is executed as soon as you hit
ENTER.
3/ The remaining grey area is the work area where EViews displays the
various objects it creates.

1.3 How to use Eviews: Graphical user interface vs. programming


There are 3 ways to use Eviews:
1/ Graphical user interface: by clicking on objects and menus.
2/ Line-by-line commands: by writing in the comand window (white area
below the main Eviews menu).
3/ Writing a complete program with a number of commands to be executed as
soon as you run the program file (File / New / Program...).

Applied Statistics and Econometrics Eviews Class

2. Starting with Eviews


2.1 Creating a workfile
Click File / New / Workfile to open the dialog box:
In the dialog box, choose Dated regular Frequency from the workfile structure
type scroll-down menu. In the date specification menu, choose Annual
frequency, and insert 1871 and 2000 for the start date and end date respectively.
On the right-hand side, you can optionally give a name to the workfile and a name for
workfile page you will be using (leave these fields empty for the moment).
Click OK and the workfile will be created.
A workfile is simply a container for Eviews objects. When you create the workfile,
two objects appear automatically: a constant labelled c and a series for residuals
labelled resid. On the top of the workfile, a series of scrolled down menus is
available: view, Proc, object, print, save, details, show, fetch, etc...

2.2 Importing data


Eviews is a statistical software and needs data to work with. Therefore the first task of
any project is to import data. There are various procedures to do it. To get you started,
do the following:
1/ The data is contained in an Excel file, Shiller.xls, available from
http://www.ems.bbk.ac.uk/for_students/grad_dip_economics/ase_EMEC002U
/index_html (See the graduate diploma student webpage, and look for the
Data for exercises in the applied statistics and econometrics section).
2/ Importing in Eviews from the main Eviews menu: Click on File / Import /
Read Text-Lotus-Excel to open the import wizard then browse the file you
want to import.
CAREFUL: the source data file needs to be closed otherwise Eviews cannot
import the data.
Once the file is selected, you will need to fill in the dialog box. Data order
should be in columns (same as your Excel spreadsheet). The upper left data
cell should be B2 as presented in the Excel file. The sheet name is Shiller.
CAREFUL: dates will not be imported but have been inserted when you
created the workfile and entered the start date and end date.
In the name for series or number if named in file, you can either write the
name of each series, NSP, ND, NE, R and PPI with a space in between or
4

Applied Statistics and Econometrics Eviews Class


write the number five, as there are five series to import and their name is
already included in the Excel file. The import sample is already established.
Click OK to import the data.

2.3 Looking at the data: basic charts


The workfile now contains annual US data from 1871 to 2000 on:
ND nominal dividends for the year
NE nominal earnings for the year
NSP nominal Standard and Poors stock price index, January value
PPI producer price index, January Value
R average interest rate for the year
The data is updated from Robert J Shiller Market Volatility, MIT Press (1989).
A few basic steps can be done to look at the series:
1/ double-click the first series nd. A spreadsheet-type window opens where
the values of the series are available from 1871 up to the end of the sample
2000. From the view menu, select Graph then Line & Symbol to display a
chart of the dividends. Does the series look stationary (mean-reverting)? Do
you think there is a unit root (non-stationary)? Do you think there is trend in
the data?
2/ Highlight nd and ne (click each of them once holding down the Ctrl
keyboard key). Right-click your selection and choose open then as group.
The two series appear in one spreadsheet-type window. Again, click View,
select Graph then Line & Symbol. You will get a chart of dividends and
earnings. Close it.
3/ Another interesting graph is the scatter plot. Highlight nd and ne (click
each of them once holding down the Ctrl keyboard key). Right-click your
selection and choose open then as group. The two series appear in one
spreadsheet-type window. Again, click View, select Graph then Scatter.

2.4 Descriptive statistics


It is important to understand and describe your series with descriptive statistics. This
section looks at different descriptive statistics.
1/ The mean is a measure of the average value of the sample distribution. In EViews
you can write in the command window (below the EViews main menu) show
@mean(nd) to get the mean of the nd variable. Doing so, a new series is created
where each cell contains the value of the mean whose definition is given by:
T

x = xt / T
t =1

Applied Statistics and Econometrics Eviews Class


NOTE: a perhaps better way to obtain the mean would be to create a scalar, for
example called nd_mean whose value contains the mean. To do so, you could type
in the command window, scalar nd_mean=@mean(nd). In the workfile, a new
object nd_mean is then created. When you double-click on this object the value of
the scalar is given at the very left-bottom part of the EViews window, in the grey
status line. This way the descriptive statistic is saved into the workfile.
2/ The variance measures the dispersion of the observations. The standard deviation is
just the square root of the variance and is in the same unit as the original variable. In
Eviews, you can write in the command window (below the Eviews main menu)
scalar nd_var=@var(nd) and scalar nd_stdev=@stdev(nd), respectively for the
variance and the standard deviation. The definitions for these descriptive statistics are:
^ 2

_ 2

Var ( x) = = ( xt x) / T
t =1

SD( x) =
The preceding definition of the variance is also called the population variance and
should not be confused with the sample variance where the sum of squared mean
deviations is divided by T-1 (see ASE notes). In Eviews the sample variance is
obtained with the following command: scalar nd_vars=@vars(nd). You can look for
variance in the index help file for more information.
3/ The descriptive statistics window: you can obtain these descriptive statistics using
the View menu of the Series window. Double-click the series nd, click View,
Descriptive Statistics & Tests then Histogram and Stats. Along with the mean,
variance and standard deviation, Eviews presents the histogram, other descriptive
statistics such as the skewness and the kurtosis, and a test for the normality of the
distribution sample, the Jarque-Bera test (bottom right).
The skewness measures whether the sample distribution is symmetrical or not. The
kurtosis gives an indication on the tails of the sample distribution (how fat they are).
For the normal distribution, the skewness and kurtosis parameters are equal to 0 and 3
respectively. The definitions are the following:
3

( xt x )
SK ( x) =
/T
s
t =1

( xt x)
KU ( x) =
/T
s
t =1

where s is the unbiased standard deviation (the sample standard deviation).

Applied Statistics and Econometrics Eviews Class


4/ When looking at two series you might want to have a measure of association such
as the covariance and the correlation:
T

cov( x, y ) = ( xt x)( y t y ) / T
t =1

cor ( x, y ) =

cov( x, y )
SD( x) SD ( y )

In Eviews, you can select two series clicking each of them separately and holding the
Ctrl key down on your keyboard. Then right click your selection and select Open
and as Group. In the new opened windows, choose View, Covariance Analysis,
making sure both Covariance and Correlation are ticked in the Statistics menu.
Always graph the data and transformations of it and look at the descriptive statistics
before starting any empirical work. Make sure series are in comparable units before
putting them on the same graph.

2.5 Stationarity
An important concern in econometrics is to know whether a series is stationary (i.e.
do not contain a unit root) or not stationary (i.e. contains a unit root). This concern is
important because you want both the left hand side and right-hand side variables of
your regressions to balance.
You can test for stationarity: double click the series you are interested in, then click
on the View menu and choose Unit Root Test. You can for example use the
Augmented Dickey-Fuller test leaving the settings unchanged before clicking OK.
Look at the different options in the Unit root test window. You might want to test
whether the 1st difference of your series is stationary, etc
NOTE: If you do not remember how to interpret a test, you can use the Eviews help
file. From the views menu, click help/Eviews help topics and type the name of the
test you are looking for.

2.6 Transforming and creating series


In many cases, we remove the effects of trends, changes in price levels etc by
working with either growth rates or ratios.
1/ In Eviews, you can create growth rates series from level variables. To generate new
series click Quick in the Eviews menu, then choose Generate Series. In the
dialog box type:
nd_yy=(nd/nd(-1)-1)*100

where nd(-1) is the lagged value of nd.

Applied Statistics and Econometrics Eviews Class


NOTE: remember that the formula for the period on period growth rate is
( y t / y t 1 1) * 100 so that we are looking here at the year-on-year growth rate of
nominal dividends.
2/ It is often useful to form ratios. A useful financial ratio is the Price-Earnings Ratio.
You can create such ratio clicking Quick in the Eviews menu, then choose
Generate Series and type
PE = NSP/NE.
NOTE: this ratio removes the common trend in the variables and is more stationary.

2.7 Doing a regression in Eviews


To run a static regression, click Quick and choose Estimate equation from the
scroll down menu. Into dialog box, type the following (uppercase or lower case letters
are equivalent):
ND C NE
NOTE: in the equation, ND is your dependent variable (the left hand side variable).
The two right-hand side variables are the constant C and the exogenous variable LE.
NOTE: look at the dialogue window and note the options. Notice the default
estimation method is LS - Least Squares (NLS and ARMA). NLS is non-linear least
squares, arma, autoregressive moving average. If you click the arrow on the right of
LS - Least Squares (NLS and ARMA), you will see that there are other methods
you could choose including Two stage Least Squares and GARCH. There is an
Options tag at the top, which you can use to get Heteroskedasticity and
Autocorrelation Consistent (HAC) Standard Errors.
Click OK and you would get the following output:

Applied Statistics and Econometrics Eviews Class

Both the constant and the coefficient of NE are very significant, t ratios much bigger
than 2 in absolute values and P-values (Prob) of zero. The P-value gives you the
probability that the null hypothesis (in this case that the coefficient is zero) is true. It
is conventional to reject the null hypothesis if the P-value is less than 0.05. However,
the Durbin-Watson Statistic is 0.53 and indicates severe serial correlation (the DurbinWatson statistic should be close to 2). This suggests dynamic misspecification.
Type View in the equation window and choose Actual Fitted Residual, then
Actual Fitted Residual Graph. You will get a graph of the actual line in red and the
fitted line in green. The difference between the two lines, the residuals, is shown in
blue. Notice the large outliers at the end of the sample.
NOTE: to copy the results, highlight what you want to copy, then right-click and
select copy. You can then paste into a Word File if necessary.

Applied Statistics and Econometrics Eviews Class

3. Interpreting, modifying and testing a regression


3.1 Regression Output
When running a regression, Eviews will give you: estimates of the coefficients, their
standard errors, t ratios (ratio of coefficient to the standard error which is a test
statistic for testing the null hypothesis that the coefficient is zero) and the P-values for
the null hypothesis that the coefficients are zero.
The program also gives you various descriptive statistics such as:
The mean of the dependent variable:

  





Its sample standard deviation:




 


The Sum of Squared Residuals:

  
1

 


The standard error of regression:


T

ut
s=
t =1 T k

where k is the number of


regressors.

The ordinary coefficient of determination (R squared) and the version


corrected for degrees of freedom (R bar squared):

  1 

 
   



 
  1 
  
 
  1


10

Applied Statistics and Econometrics Eviews Class

R 2 measures the proportion of variation in the dependent variable


explained by the regression.
Eviews also gives you an F test for the hypothesis that all the slope coefficients (i.e.
other than the intercept) are equal to zero at the very bottom left:
T 2
_

T
2
)
(
y

ut
t

t =1

t =1
k 1
~ F(k - 1, T - k)
2
T
ut

t =1 T k

The Maximised Log-likelihood


likelihood and some model selection criteria
criteria such as Schwarz or
Akaike are also given. In Eviews you choose the model with the smallest value (this
can differ across softwares where the maximum value is sometimes chosen).
chosen)
T

The Durbin Watson statistic is:

DW =

ut
t =2
T

ut
t =1

This measures serial correlation in the residuals. It should be about 2 and is roughly
equal to 2(1-) where is the serial correlation coefficient. It is only appropriate for
first order serial correlation when there are no lagged dependent variables in the
equation. Use an LM test otherwise.

3.2 A different specification: ratios and dynamics


In section 2.7,, the regression used the level of dividends and earning. The serial
correlation in the original regression suggested dynamic misspecification. This was
seen looking at the Durbin-Watson
Durbin Watson statistic. We now construct a dynamic
specification with ratios.
To generate ratios, click Quick, Generate Series and type the following in the
dialog box: LRD=log(ND/PPI). You will see a new variable in the workfile, lrd, the
log of real dividends. Repeat this procedure for the log of real earnings,
LRE=log(NE/PPI). Graph the series. Are the series more stationary?
Click, Quick, Estimate Equation and type in:
LRD C LRE LRD(-1)
LRD(
This estimates an equation of the form:
for
Yt = + X t + Yt 1
+ t

11

Applied Statistics and Econometrics Eviews Class

where the dependent variable is influenced by its value in the previous period. The
estimates are:

This regression should be compared to the previous one with caution, because the two
equations have different dependent variables. In the preceding equation (section 2.7),
the dependent variable was nominal dividends, here it is the log of real dividends. The
Durbin Watson statistic for this equation is 1.77 which is much better.
This is a dynamic equation since it includes the lagged dependent variable. The longrun elasticity of dividends to earnings is 0.253/(1-0.667) = 0.76. A 1% increase in
earnings is associated with a 0.76% increase in dividends in the long-run.
NOTE: a lag dependent variable is included in this regression so that the LM test for
serial correlation should be preferred instead of the Durbin-Watson statistic.
Click View on the equation box; then Actual, Fitted, Residual; then Actual,
Fitted, Residual Graph.

3.3 Misspecification/Diagnostic tests


Click View on the equation box, choose Residual Tests, Serial Correlation LM
Test, and accept the default number of lags to include 2. You will get the LM
serial correlation test. Note that neither lagged residual is individually significant (t
value less than 2 in absolute value and P-value >0.05) nor are they jointly significant
F stat p value is 0.29. So we do not have any serial correlation problem with this
equation.
12

Applied Statistics and Econometrics Eviews Class

Click View, Residual Tests, Histogram- Normality Test. You will get the
histogram and the Jarque-Bera test of 45.29 with a P-value of 0.0000 (bottom right
hand side). There is clearly a failure of normality, caused by some outliers.
Click View, Residual Tests, Heteroskedasticity Tests, and choose BreushPagan-Godfrey. The P-value for the F-statistic is 0.005, so there is indication of
heteroskedasticity, i.e. we reject the hypothesis of constant variance.
NOTE: diagnostic tests examine whether the assumptions made about the errors hold.
The null is always that the model is well-specified: the assumption, e.g. normality,
holds. P-values below 0.05 indicate that there is a problem.

3.4 Specification tests


Given that the model is well-specified (to be argued in our case), we can test
restrictions on the coefficients of the model. We can use the likelihood ratio test or the
Wald test:
1/ Click View, Coefficient Tests, Redundant Variables Likelihood Ratio, then
enter:
LRD(-1)
Click OK, you will get and F statistic with its P-value and a Likelihood Ratio test with
P-value. Both P-values are 0.00, so we reject the hypothesis that the coefficient of this
variable is zero.
2/ Click View, Coefficient Tests, Wald Coefficient Restrictions and type in
to the box:
C(3)=0
This is exactly the same restriction as above and we get the same answer from the
Wald test.

3.5 Using a dummy variable

The sample period includes the First World War. This could shift the log of real
dividends and earnings. Such shift can be allowed by estimating:
Yt = + X t + Yt 1 + Dt + t

Where Dt is a Dummy variable that takes the value one between 1914 and 1918 and
zero otherwise. You can create such dummy variable in two steps.

13

Applied Statistics and Econometrics Eviews Class


1/ First, click Quick, Generate Series and type dummy=0. This command
will create a series with value zero for the whole sample.
2/ Second, double click on the series in the workfile to open the series, click View,
then Spreadsheet. You can replace the zero-values using the Edit +/- button and
type manually 1 in each of the cells between 1914 and 1918.

Click, Quick, Estimate Equation and type in:


LRD C LRE LRD(-1) DUMMY
The estimation result is the following:

14

Applied Statistics and Econometrics Eviews Class

4. Programming in Eviews
A more efficient way to use Eviews is to create programs. Programs contain a number
of commands that are going to be run successively.
In order to create a new program, click File in the main Eviews menu, then chose
New then Program. A new untitled window program is opening in the work area.
This window has a selection of menus on the top: Run, Print, Save, SaveAS, Cut
NOTE: In Eviews programs you can write comments if there are preceded by the
apostrophe symbol .
What has been done until now can be resumed in the following commands:
1/ Creating a workfile: you can create a workfile writing wfcreate(wf=shiller) a 1871
2000. The option in parenthesis says that the name of workfile should be shiller.
The sample of the workfile is then set by the letter a (annual data), the start date
1871 and the end date 2000.
2/ Importing data: to import the data, write read(b2,s=shiller) H:\data\shiller.xls 5.
The command tells Eviews to read the data from an Excel file called shiller.xls (it is
assumed here that the data is saved into the H:\ drive of your computer but you can
obviously change it). Eviews will start reading the data from the cell b2 (with data in
columns) and the number of series to be imported is 5.
NOTE: the name of the series will be imported directly in Eviews because they
already are in the Excel spreadsheet above the first value of each series.
3/ Descriptive statistics: as mentioned above (section 2.4), you can create scalar
objects that will contain the value of some descriptive statistics such as the mean, the
variance or the standard deviation:
scalar nd_mean=@mean(nd)
scalar nd_var=@var(nd)
scalar nd_vars=@vars(nd)
scalar nd_stdev=@stdev(nd)
scalar nd_skew=@skew(nd)
scalar nd_kurt=@kurt(nd)
scalar ndne_cov=@cov(nd,ne)
scalar ndne_cor=@cor(nd,ne)

for the mean


for the population variance
for the sample variance
for the standard deviation
for the skewness
for the kurtosis
for the covariance
for the correlation

Note: you can see the values of the scalar in the status line (bottom left below the
work area) after double-clicking on the objects.
4/ Stationarity: you can test whether a series is stationary using one of the unit root
tests provided in Eviews. For example type in:
nd.uroot(adf,const,lag=12,save=matrixout)

15

Applied Statistics and Econometrics Eviews Class


This tells Eviews to perform and Augmented Dickey-Fuller unit root test that includes
12 lags and save the results in an object matrix called matrixout. If you open the
matrixout object (double-click on it), the first line is the number of observations,
here 116 (12 lags have been excluded), the number of lags 12, the value of the tstatistic 1.28 and the P-value 0.999. in that case, the null of a unit root is not rejected,
i.e. the series is not stationary.
5/ Transforming and creating series: to get the series created in the notes, type in:
series nd_yy=(nd/nd(-1)-1)*100
series LRD=log(ND/PPI)
series LRE=log(NE/PPI)

for the year-on-year growth rate of nd


for the log of real dividends
for the log of real earnings

6/ Dummy variable: can you create your dummy variable using the smpl (sample)
command in a few steps:
smpl @all
series dummy=0
smpl 1914 1918
series dummy=1
smpl @all
This says that you first select your whole sample and then create a series called
dummy whose value is 0 over the whole sample period. You then reduce the sample
to the smallest 1914-1918 period and give the value 1 to the dummy series over this
period. DONT forget to put the entire back sample back using smpl @all.
7/ Doing regressions: It is easy to redo the regressions presented earlier using the
Quick, Estimate equation menu. Just type in the program:
equation eq_level.ls nd c ne
equation eq_ratios.ls lrd c lre lrd(-1)
equation eq_dummy.ls lrd c lre lrd(-1)
Three equation objects will then be created in your workfile corresponding to each of
these equations.
Interpretation of the regressions: you can obviously use the program to include
misspecification and specification tests but this it not shown here. The View menu
of each equation is a good way to proceed.
The whole program is given below and can also be found on the webpage. You can
either write the commands in a new program or copy them from the webpage in a new
program. To create a new program, click File in the main Eviews menu, then chose
New then Program. Once the commands are written (or pasted), just click Run
on the program window. You can save the program with the Eviews File menu then
using Save As.
NOTE: remember that the program is looking for an Excel file located into the
H:\data\ directory. You will have to change this accordingly.
16

Applied Statistics and Econometrics Eviews Class

This is how the program should look like in Eviews 6 (Eviews 5 or any earlier
versions do not have different color types and some commands might not work):

17

Applied Statistics and Econometrics Eviews Class

The workfile that you should obtain after running this program should be the
following:

18

Applied Statistics and Econometrics Eviews Class

19

Das könnte Ihnen auch gefallen