# Panel data

Gretl Manual: Gnu Regression, Econometrics and Time-series Library
Prev |  | Next

# Chapter 7. Panel data

# 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:

- Stacked cross-sections: the successive vertical blocks each comprise a cross-section for a given period.

- Stacked time-series: the successive vertical blocks each comprise a time series for a given cross-sectional unit.

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 or vice versa.

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"). A panel interpretation can be imposed on the data in either of two ways.

1. Use the GUI menu item "Sample, Dataset structure". In the first dialog box that appears, select "Panel". In the next dialog, make a selection between stacked time series or stacked cross sections depending on how your data are organized. In the next, supply the number of cross-sectional units in the dataset. Finally, check the specification that is shown to you, and confirm the change if it looks OK.

2. Use the script command `setobs`. For panel data this command takes the form `setobs` `freq` `1:1` `structure`, where `freq` is replaced by the "block size" of the data (that is, the number of periods in the case of stacked time series, or the number of cross-sectional units in the case of stacked cross-sections) and `structure` is either `--stacked-time-series` or `--stacked-cross-section`. Two examples are given below: the first is suitable for a panel in the form of stacked time series with observations from 20 periods; the second for stacked cross sections with 5 cross-sectional units.

       	    setobs 20 1:1 --stacked-time-series
       	    setobs 5 1:1 --stacked-cross-section

Prev | Home | Next
The Sample menu items |  | Dummy variables