Dougherty5e Gretlguide
Dougherty5e Gretlguide
gretl
gretl
gretl (GNU Regression, Econometrics and Time-Series Library) is
the official econometrics application for 2020 Elements of
Econometrics. It is free (obviously, a major consideration for
distance learning students) and very powerful. It does everything
that is required in the computer regression exercises in the course
text Introduction to Econometrics (C. Dougherty, Oxford
University Press, fifth edition 2016). In fact, we use only a small
fraction of its features. It is similar to major econometrics
applications such as Stata, EViews, SPSS, and SAS, with the crucial
difference that you do not have to pay for it. If you already have
access to one of the commercial applications just mentioned, there
is no need to change. However, if you are struggling to fit
regressions with a regression feature built into a spreadsheet
application such as Microsoft Excel, quit now and switch to gretl.
Spreadsheet applications can do only very basic regressions and are
quite unsuitable for this course.
gretl should be downloaded from the its home page
http://gretl.sourceforge.net/. See that page for its history and
current status.
This manual provides just the information needed to undertake the
regression exercises in the text. The information is provided as you
need it, so that you are not overwhelmed by too much information
too soon. By the time that you have completed the exercises, you
will have a good basic working knowledge of the application.
Comprehensive reference information can be found in the gretl
manual gretl-guide.pdf located in the Help section of gretl. The
Help section also provides direct access to information about the
commands and functions used by gretl.
It is assumed that you have downloaded and installed gretl and that
you have downloaded the necessary data sets from the OUP website
at
http://global.oup.com/uk/orc/busecon/economics/dougher
ty5e/
(The OUP link is likely to appear if you type ‘Dougherty 5e’
into your search engine.)
GUI/CLI/Batch mode
In common with other sophisticated econometrics packages, gretl
may be operated in three ways: via a graphical user interface (GUI),
via a command line interface (CLI), and in batch mode.
The GUI involves menus and windows, is intuitively designed, and
provides an excellent starting point for experimenting with gretl.
However, it will mostly be ignored here, for two reasons. One, the
less important, is that operations with menus and windows can be
cumbersome to describe. The other is that serious researchers
always primarily use batch mode.
The CLI involves using a special command line window, called the
‘command console’ in the gretl manual, instead of the GUI. The
command line window may be opened by clicking on the Tools tab
University of London International Programmes 1
20 Elements of econometrics
Common operations
Here are a few commands that will be useful in the exercises: You
will learn other commands as you work your way through the
exercises. In fact, doing the exercises is a relatively painless way of
acquiring a basic understanding of how to use gretl.
open followed by a path and then the name of a data set. This
opens the data set.
store followed by a path and the name of the current data set.
This saves the data set. The command should be used
after generating new variables, to save the enlarged data
set for future use. In general, there is no need to give the
enlarged data set a different name.
ols followed by a variable name, then const, and further
variable names. The first variable is regressed on the
rest. Omit const if there is no intercept in the model.
where ** is the number of your data set. Thus if you are using data
set 7 and have stored the data set in subfolder ‘data’ of folder
‘gretl’ on your C: drive, path will be C:\gretl\data and the
command will be
open c:\gretl\data\eawe07.gdt
Note that gretl is case sensitive. ols and const must always be
lower case. S and ASVABC must be upper case because they are
defined as upper case in the data set.
Y Y
n
2
TSS i
i 1
but TSS is not reported either. To get around this, regress the
dependent variable on a constant only, fitting the model
Y 1 u
The estimator of 1 will be Y . The fitted value of Y in all
observations will be Y . The residual in observation i will be
Yi Y , and hence RSS for this regression will be Y Y . By
n 2
1 i
on path\. You should always save a data file after defining new
variables if you think that you will need them again.
genr CHILDREN = SIBLINGS + 1
ols CHILDREN const SM SF
corr SM SF
genr SP = SM + SF
ols CHILDREN const SP
store path\eawe**.gdt
In the last command, you should replace path\ by the path to the
location where you have downloaded the CES2013 data file. See
Exercise 3.15 for remarks on saving data files.
Note that the command for the first regression is so long that it has
wrapped to a second line. This is fine if you are using the command
line (console box). However, if you are writing a batch file, gretl
treats each line as a separate command. To indicate that a second
line is a continuation of the first, one needs to insert a backslash at
the end of the first line.
The corr command computes the correlations between the
variables listed. It has also wrapped and would need a backslash at
the end of the first line if you were writing a batch file.
smpl full
smpl 313 500
ols EARNINGS const S EXP MALE
smpl full
The first command fits the regression using all the observations,
including the zero observations. The next two commands do the
same, restricting the sample to the non-zero observations. The last
performs the tobit regression.
hausman
panel LGEARN const S ASVABC EXP MALE ETHBLACK ETHHISP UNION
panel LGEARN const S ASVABC EXP MALE ETHBLACK ETHHISP UNION --random-
effects