Beruflich Dokumente
Kultur Dokumente
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
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
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?
x = xt / T
t =1
_ 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
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.
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.
1
ut
s=
t =1 T k
1
1
1
10
T
2
)
(
y
ut
t
t =1
t =1
k 1
~ F(k - 1, T - k)
2
T
ut
t =1 T k
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.
11
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.
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.
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
14
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)
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
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
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
The workfile that you should obtain after running this program should be the
following:
18
19