Gretl Manual: Gnu Regression, Econometrics and Time-series Library
Prev | Chapter 4. Data files | Next

# Data file collections

If you're using `gretl` in a teaching context you may be interested in adding a collection of data files and/or scripts that relate specifically to your course, in such a way that students can browse and access them easily.

This is quite easy as of `gretl` version 1.2.1. There are three ways to access such collections of files:

- For data files: select the menu item "File, Open data, sample file", or click on the folder icon on the `gretl` toolbar.

- For script files: select the menu item "File, Open command file, practice file".

When a user selects one of the items:

- The data or script files included in the gretl distribution are automatically shown (this includes files relating to Ramanathan's Introductory Econometrics and Greene's Econometric Analysis).

- The program looks for certain known collections of data files available as optional extras, for instance the datafiles from various econometrics textbooks (Wooldridge, Gujarati, Stock and Watson) and the Penn World Table (PWT 5.6). (See the data page at the gretl website for information on these collections.) If the additional files are found, they are added to the selection windows.

- The program then searches for valid file collections (not necessarily known in advance) in these places: the "system" data directory, the system script directory, the user directory, and all first-level subdirectories of these. (For reference, typical values for these directories are shown in Table 4-1.)

Table 4-1. Typical locations for file collections

| Linux | MS Windows
--- | --- | ---
system data dir | `/usr/share/gretl/data` | `c:\userdata\gretl\data`
system script dir | `/usr/share/gretl/scripts` | `c:\userdata\gretl\scripts`
user dir | `/home/me/gretl` | `c:\userdata\gretl\user`

Any valid collections will be added to the selection windows. So what constitutes a valid file collection? This comprises either a set of data files in `gretl` XML format (with the `.gdt` suffix) or a set of script files containing gretl commands (with `.inp` suffix), in each case accompanied by a "master file" or catalog. The `gretl` distribution contains several example catalog files, for instance the file `descriptions` in the `misc` sub-directory of the `gretl` data directory and `ps_descriptions` in the `misc` sub-directory of the scripts directory.

If you are adding your own collection, data catalogs should be named `descriptions` and script catalogs should be be named `ps_descriptions`. In each case the catalog should be placed (along with the associated data or script files) in its own specific sub-directory (e.g. `/usr/share/gretl/data/mydata` or `c:\userdata\gretl\data\mydata`).

The syntax of the (plain text) description files is straightforward. Here, for example, are the first few lines of gretl's "misc" data catalog:

          # Gretl: various illustrative datafiles
          "arma","artificial data for ARMA script example"
          "ects_nls","Nonlinear least squares example"
          "hamilton","Prices and exchange rate, U.S. and Italy"

The first line, which must start with a hash mark, contains a short name, here "Gretl", which will appear as the label for this collection's tab in the data browser window, followed by a colon, followed by an optional short description of the collection.

Subsequent lines contain two elements, separated by a comma and wrapped in double quotation marks. The first is a datafile name (leave off the `.gdt` suffix here) and the second is a short description of the content of that datafile. There should be one such line for each datafile in the collection.

A script catalog file looks very similar, except that there are three fields in the file lines: a filename (without its `.inp` suffix), a brief description of the econometric point illustrated in the script, and a brief indication of the nature of the data used. Again, here are the first few lines of the supplied "misc" script catalog:

          # Gretl: various sample scripts
          "arma.inp","ARMA modeling","artificial data"
          "ects_nls","Nonlinear least squares (Davidson)","artificial data"
          "leverage","Influential observations","artificial data"
          "longley","Multicollinearity","US employment"

If you want to make your own data collection available to users, these are the steps:

1. Assemble the data, in whatever format is convenient.

2. Convert the data to `gretl` format and save as `gdt` files. It is probably easiest to convert the data by importing them into the program from plain text, CSV, or a spreadsheet format (MS Excel or Gnumeric) then saving them. You may wish to add descriptions of the individual variables (the "Variable, Edit attributes" menu item), and add information on the source of the data (the "Data, Edit info" menu item).

3. Write a descriptions file for the collection using a text editor.

4. Put the datafiles plus the descriptions file in a subdirectory of the `gretl` data directory (or user directory).

5. If the collection is to be distributed to other people, package the data files and catalog in some suitable manner, e.g. as a zipfile.

If you assemble such a collection, and the data are not proprietary, I would encourage you to submit the collection for packaging as a `gretl` optional extra.

Prev | Home | Next
Missing data values | Up | Special functions in genr