Lags and differences with panel data

If the time periods are evenly spaced you may want to use lagged values of variables in a panel regression; you may also with to construct first differences of variables of interest.

Once a dataset is properly identified as a panel (as described in the previous section), gretl will handle the generation of such variables correctly. For example the command genr x1_1 = x1(-1) will create a variable that contains the first lag of x1 where available, and the missing value code where the lag is not available.

When you run a regression using such variables, the program will automatically skip the missing observations.