The specification for the twoway randomeffects model is

As in the oneway randomeffects model, the PANEL procedure provides four options for variance component estimators. Unlike the oneway randomeffects model, unbalanced panels present some special concerns.
Let and be the independent and dependent variables arranged by time and by cross section within each time period. (Note that the input data set used by the PANEL procedure must be sorted by cross section and then by time within each cross section.) Let be the number of cross sections observed in time and . Let be the matrix obtained from the identity matrix from which rows that correspond to cross sections not observed at time have been omitted. Consider

where and .
The matrix gives the dummy variable structure for the twoway model.
For notational ease, let






The Fuller and Battese method for estimating variance components can be obtained by setting VCOMP = FB (with the option RANTWO). FB is the default method for a RANTWO model with balanced panel. If RANTWO is requested without specifying the VCOMP= option, PROC PANEL proceeds under the Fuller and Battese method.
Following the discussion in Baltagi, et. al. (2002), the Fuller and Battese method forms the estimates as follows.
The estimator of the error variance is

where is the Wansbeek and Kapteyn within estimator for unbalanced (or balanced) panel in a twoway setting.
The estimator of the error variance is the same as that in the Wansbeek and Kapteyn method.
Consider the expected values












Just as in the oneway case, there is always the possibility that the (estimated) variance components will be negative. In such a case, the negative components are fixed to equal zero. After substituting the group sum of the within residuals for , the time sums of the within residuals for , and , the two equations are solved for and .
The Wansbeek and Kapteyn method for estimating variance components can be obtained by setting VCOMP = WK. The following methodology, outlined in Wansbeek and Kapteyn (1989) is used to handle both balanced and unbalanced data. The Wansbeek and Kapteyn method is the default for a RANTWO model with unbalanced panel. If RANTWO is requested without specifying the VCOMP= option, PROC PANEL proceeds under the Wansbeek and Kapteyn method if the panel is unbalanced.
The estimator of the error variance is

where the are given by if there is an intercept and by if there is not.
The estimation of the variance components is performed by using a quadratic unbiased estimation (QUE) method that involves computing on quadratic forms of the residuals , equating their expected values to the realized quadratic forms, and solving for the variance components.
Let


The expected values are







where





The quadratic unbiased estimators for and are obtained by equating the expected values to the quadratic forms and solving for the two unknowns.
When the NOINT option is specified, the variance component equations change slightly. In particular, the following is true (Wansbeek and Kapteyn 1989):


The Wallace and Hussain method for estimating variance components can be obtained by setting VCOMP = WH. Wallace and Hussain’s method is by far the most computationally intensive. It uses the OLS residuals to estimate the variance components. In other words, the Wallace and Hussain method assumes that the following holds:



Taking expectations yields



where the constants are defined by





























The PANEL procedure solves this system for the estimates , , and . Some of the estimated variance components can be negative. Negative components are set to zero and estimation proceeds.
The Nerlove method for estimating variance components can be obtained with by setting VCOMP = NL.
The estimator of the error variance is

The variance components for cross section and time effects are:

and

With the estimates of the variance components in hand, you can proceed to the final estimation. If the panel is balanced, partial mean deviations are used:


The estimates are obtained from



With these partial deviations, PROC PANEL uses OLS on the transformed series (including an intercept if so desired).
The case of an unbalanced panel is somewhat trickier. You could naively substitute the variance components in the equation below:

After inverting the expression for , it is possible to do GLS on the data (even if the panel is unbalanced). However, the inversion of is no small matter because the dimension is at least .
Wansbeek and Kapteyn show that the inverse of can be written as

with the following:












Computationally, this is a much less intensive approach.
By using the inverse of the variancecovariance matrix of the error, it becomes possible to complete GLS on the unbalanced panel.