Let and be the independent and dependent variables, respectively, that are arranged by time and by cross section within each time period. (Note that the input data set that the PANEL procedure uses must be sorted by cross section and then by time within each cross section.) Let be the number of cross sections that are observed in year , and let . Let be the matrix that is obtained from the identity matrix from which rows that correspond to cross sections that are not observed at time have been omitted. Consider
where and . The matrix contains the dummy variable structure for the two-way model.
Let
The estimate of the regression slope coefficients is given by
where is the matrix without the vector of 1s.
The estimator of the error variance is
where the residuals are given by if there is an intercept in the model and by if there is no intercept.
The actual implementation is quite different from the theory. For more information, see the section Two-Way Fixed-Effects Model.