Anda di halaman 1dari 5

AEB 4931 Econometrics (Summer 2015)

G. Onel

A Quick Guide to Using GRETL


I. Introduction
The Gretl is a powerful freeware available for download from the SourceForge website. It is
an open source econometrics software and will operate on computers running the Windows,
MAC OS X or Linux operating systems. The manual for Gretl is available at:
http://ricardo.ecn.wfu.edu/pub/gretl/gretl-guide.pdf

II. Downloading and Installing the Gretl


A. Gretl for Windows is available for download at the following links:
http://prdownloads.sourceforge.net/gretl/gretl-1.9.92.exe for 32-bit Window
http://prdownloads.sourceforge.net/gretl/gretl-1.9.92-64.exe for 64-bit Windows
To install the software, click on the link above (when in doubt use the 32-bit version), save
the file to your hard drive and then click on * Run * when prompted. At the prompts, accept the
installation defaults and the program will then create an icon on your desktop
for Gretl. Double-click on the desktop icon to start Gretl.
B. Instructions for installing Gretl on MAC OS are available at the following link:
http://gretl.sourceforge.net/osx.html
Click on the appropriate version of Gretl that conforms to the MAC OS that your computer
is using and follow the installation steps prior to installing the Latest Release that corresponds to
your OS version.

III. Preparing and Importing Excel data files


The "recommended" way to analyze data using Gretl is to first create an MS Excel comma
delimited file (csv), and then "import" the data into Gretl .
NOTE: Like most statistical programs, importing data works best when the data have been
saved as MS Excel comma delimited file (csv) worksheets.
A. To create and save data into a MS Excel comma delimited file (csv) worksheets:
1

i. Start the MS-Excel program and either (a) type in the data to a blank worksheet or (b)
open a saved Excel file and click on the worksheet containing the data to be imported.
ii. Make sure that each column of data is headed by a variable name that (a) begins with
a letter and (b) is no longer than eight contiguous characters in length.
iii. Make sure that, aside from the column headings, all of the data consists of
numbers. Gretl will ignore alphanumeric values so be sure to first convert categorical variables
(e.g., yes, no) into numerical variables (e.g., 1, 0). NOTE: you can use Excel's *Edit* Replace*
to do the conversion.
iv. To save the data, click on * File * Save As * and then type in a file name and click
on MS Excel Comma Delimited File (csv) as the file type.
B. To import the saved Excel (csv) worksheet into Gretl :
Start Gretl and click on * File * Open Data * User File *, change the file type (bottom
right) to CSV, and then point to the folder containing the data. Next respond to the query on
whether the data is undated or time-series or panel. If the data is either time-series or panel,
you'll have to enter additional information regarding how the data is measured, i.e., the starting
date for the data, the number of time-periods, etc. After you have imported the data, doubleclick on the variable names to check that the program processed the data correctly.

IV. Descriptive Statistics and Simple Plots


To obtain Descriptive Statistics, highlight the variable names that you want statistics for and
then click on * View * Summary Statistics * OK *. To obtain correlation coefficients, click
on * View * Correlation Matrix * *OK*.
To obtain Simple Bivariate Plots, click * View * Graph specified vars * X-Y scatter * and
then identify the variables you want to plot on the X and Y axes.

V. Ordinary Least Squares Regression


To run an Ordinary Least Squares (OLS) regression in Gretl , click on * Model * *
Ordinary Least Squares *, identify the dependent variable and independent variables, and then
click on * OK *. The * Analysis * tab will generate additional statistics including predicted
values and residuals and confidence intervals for the coefficients. The * Graphs * tab will
generate differing plots of the residuals.

VI. Testing and correcting for serial (auto) correlation


Gretl will generate the Durbin Watson Statistic after an ordinary least squares regression is
estimated. The results for the Breusch-Godfrey test for autocorrelation can also be obtained by
clicking on * Tests * Autocorrelation * and entering the desired number of lags. To estimate
Generalized Least Squares (GLS) corrected results, click on * Model * Times Series *, select
2

the estimation method (e.g., Autoregressive Estimation) and then identify the dependent and
independent variables and the number of AR term lags (usually 1). To estimate Newey-West
corrected standard error results, run an Ordinary Least Squares (OLS) regression but also click
on * Robust standard errors * Configure * and on the * HCCE * tab make sure that * HAC
* is highlighted for * time series data *.

VII. Testing and correcting for heteroskedasticity


After an ordinary least squares regression is estimated, you can test for heteroskedasticity
by clicking on * Tests * Heteroskedasticity * and entering the desired test, e.g., White
Test. To estimate corrected results, run an Ordinary Least Squares regression but also click
on * Robust standard errors * Configure * and on the * HCCE * tab make sure that the
desired correction method (e.g., HC1) is highlighted for * cross sectional data *.

VIII. Logit regression models


To generate a logit regression model on a binary dummy (1,0) dependent variable, click
on *Model* * Limited Dependent Variable * Logit * Binary *, and then identify the
dependent and independent variables. Gretl will then generate logit results, including
transformed coefficients measuring the marginal impacts of the explainers evaluated at their
mean values.

IX. Creating New Variables


New variables can be created out of existing ones by clicking on * Add * New Variable
* and then typing in the formula for computing the new variable. For example if you wanted to
multiple X1 times X2 to create an interactive variable namedX1X2, then click on * Add * New
Variable * and type in the formula box
X1X2 = X1 * X2 . Make sure that if the variable
names are capitalized, your formula includes capitalized names.

X. Subsamples
To select subsamples of the data set, click on * Sample * and * Set Range * and then
define the range of observations that you want to include in the analyses that will follow. You
can also use the * Sample * command to include a random sample of observations or to define
expressions that will select/reject those cases that conform to the expression.
XI. Panel Data Regressions
To analyze panel data in Gretl , click on * Model * * Panel * * Fixed or Random
Effects*, identify the dependent variable and independent variables and the model you wish to
estimate, indicate whether you want time dummies included, and then click on * OK *. The *
3

Tests * tab will generate additional statistics including tests for heteroskedasticity and serial
correlation.
XII. Saving Projects
If you want to save an Gretl session for future analysis, and want to avoid re-importing
the Excel data worksheet and recreating any data transformations that you've already done, then
you must get Gretl to save your project. To do so, click on * File * Save Data *, point to the
folder where you want the project saved, and name the project. Then you can reopen the
project by starting Gretl , clicking on * File * Open Data * User File *, and then entering the
saved project's name.Gretl will recreate all of the variables that were available at the time the
project was saved.
XIII. Exercise
In the following data, Y is the weight (in pounds) of each customer and X is the height (in inches
above 5 feet):
Y
140
157
205
198
162
174
150
165
170
180
170
162
165
180
160
155
165
190
185
155

X
5
9
13
12
10
11
8
9
10
12
11
9
10
12
8
9
10
15
13
11

a-) Create a data set, using EXCEL, containing the above data. Put the two variable names,
i.e., Y and X, on the first line of the data file. Type in the numbers on the next 20 lines,
organized into two columns. This is organizing the file's data by observation. Save the data into
a file formatted as an MS Excel Comma Delimited File (csv) worksheet.
b-) Use the Gretl program to generate descriptive statistics, i.e., means, standard deviations and
correlation coefficients for the Y and X variables. Note: this data is cross-sectional data, i.e., it's
measured across individuals at a point of time.
c-) Explain what the descriptive statistics mean.
d-) Generate a scatterplot of Y and X and discuss what it shows.
e-) Write a regression model (equation) that describes the likely relationship between Y and X.
Which is the dependent variable? The independent variable? Why so? Discuss what the
equation hypothesizes.
f-) Estimate your regression model and also generate predicted Y values and residuals.
g-) Specifically, what do the observed Y, fitted (predicted) Y, and residual columns tell you?
How are they computed?
h-) Interpret the estimated coefficients.

Anda mungkin juga menyukai