Chapter 6. Panel data

Table of Contents
Panel structure
Dummy variables
Lags and differences with panel data
Pooled estimation
Illustration: the Penn World Table

Panel structure

Panel data are inherently three dimensional — the dimensions being variable, cross-sectional unit, and time-period. For representation in a textual computer file (and also for gretl's internal calculations) these three dimensions must somehow be flattened into two. This "flattening" involves taking layers of the data that would naturally stack in a third dimension, and stacking them in the vertical dimension.

Gretl always expects data to be arranged "by observation", that is, such that each row represents an observation (and each variable occupies one and only one column). In this context the flattening of a panel data set can be done in either of two ways:

You may use whichever arrangement is more convenient. Under gretl's Sample menu you will find an item "Restructure panel" which allows you to convert from stacked cross section form to stacked time series.

When you import panel data into gretl from a spreadsheet or comma separated format, the panel nature of the data will not be recognized automatically (most likely the data will be treated as "undated"). Getting the data recognized correctly is a two-step process: first, establish the periodicity of the data and the starting observation; second, establish the structure of the data (stacked time series or stacked cross-sections).

  1. In the context of panel data the periodicity equals the number of rows per block of data. In the case of stacked time series, this is the number of time periods; in the case of stacked cross-sections it is the number of cross-sectional units.

    In most cases the starting observation should be set as 1:1. In this colon-separated pair of numbers, the leading number represents the data-block and the trailing number represents the entry within that block. (Thus for example, with stacked time series the observation label 3:2 denotes the observation for unit 3, period 2.)

    The periodicity and starting observation can be set using the script command setobs or the GUI menu item "Sample, Set frequency, startobs…".

  2. Once the periodicity and starting observation are set appropriately, you can impose the correct interpretation of the data structure using the script command panel or the GUI menu item "Sample, interpret as panel". The panel takes an option, either --time-series (for stacked time series) or --cross-section (for stacked cross-sections). If no option is given, stacked time series is assumed. The "interpret as panel" menu item brings up a dialog box where you select stacked time series or stacked cross sections.