Gretl Manual: Gnu Regression, Econometrics and Time-series Library
Prev | Chapter 6. Sub-sampling a dataset | Next

# Setting the sample

By "setting" the sample we mean defining a sub-sample simply by means of adjusting the starting and/or ending point of the current sample range. This is likely to be most relevant for time-series data. For example, one has quarterly data from 1960:1 to 2003:4, and one wants to run a regression using only data from the 1970s. A suitable command is then

    	smpl 1970:1 1979:4

Or one wishes to set aside a block of observations at the end of the data period for out-of-sample forecasting. In that case one might do

    	smpl ; 2000:4

where the semicolon is shorthand for "leave the starting observation unchanged". (The semicolon may also be used in place of the second parameter, to mean that the ending observation should be unchanged.) By "unchanged" here, we mean unchanged relative to the last `smpl` setting, or relative to the full dataset if no sub-sample has been defined up to this point. For example, after

    	smpl 1970:1 2003:4
    	smpl ; 2000:4

the sample range will be 1970:1 to 2000:4.

An incremental or relative form of setting the sample range is also supported. In this case a relative offset should be given, in the form of a signed integer (or a semicolon to indicate no change), for both the starting and ending point. For example

    	smpl +1 ;

will advance the starting observation by one while preserving the ending observation, and

    	smpl +2 -1

will both advance the starting observation by two and retard the ending observation by one.

An important feature of "setting" the sample as described above is that it necessarily results in the selection of a subset of observations that are contiguous in the full dataset. The structure of the dataset is therefore unaffected (for example, if it is a quarterly time series before setting the sample, it remains a quarterly time series afterwards).

Prev | Home | Next
Sub-sampling a dataset | Up | Restricting the sample