# How to estimate a model with fixed and random effects for a long panel dataset?

NOTE: I am using Stata for doing this.

I have a long panel dataset, meaning my N is much smaller than my T. I have N = 5, T = 61. I tried to estimate my model, but I get an error related to the fact that I do not have enough degrees of freedom for calculating as many variables as I have.

This is what I get:

Wald chi2(4)       =         .
Prob > chi2        =         .


Stata's help tells me the following:

The VCE you have just estimated is not of sufficient rank to perform the model test. As discussed in [R] test, the model test with clustered or survey data is distributed as F(k,d-k+1) or chi2(k), where k is the number of constraints and d=number of clusters or d=number of PSUs minus the number of strata. Because the rank of the VCE is at most d and the model test reserves 1 degree of freedom for the constant, at most d-1 constraints can be tested, so k must be less than d. The model that you just fit does not meet this requirement.

To simplify the remaining discussion, let's consider the case of clustered data. This discussion applies to survey estimation in general by substituting, "PSUs - strata" for "clusters".

There is no mechanical problem with your model, but you need to consider carefully whether any of the reported standard errors mean anything. The theory that justifies the standard error calculation is asymptotic in the number of clusters, and we have just established that you are estimating at least as many parameters as you have clusters.

That concern aside, the model test statistic issue is that you cannot simultaneously test that all coefficients are zero because there is not enough information. You could test a subset, but not all, and so Stata refuses to report the overall model test statistic.

Here note the degrees of freedom reported for the chi2 or F. You might see chi2(6) or F(6, 5). If you were to count the number of coefficients that would be constrained to 0 in a model test in this case, you would find that number to be greater than 6. You could find out what that number is by re-estimating the model parameters without the vce(robust) and vce(cluster clustvar) options. In any case, the 6 reported is the maximum number of coefficients that could be simultaneously tested.

Reading the book "Microeconometrics using Stata", the author clearly indicates that the xtreg command, with the vce(cluster id) option for calculating robust errors, is mostly appropriate for short panels.

An alternative is to use the command xtregar for estimating random and fixed effects, which is based on an AR(1) process for the errors. However, we have tested, and our errors do not show an AR(1) pattern (xtserial test). The xtregar command has the option rhof(#), where # indicates the desired rho value (AR(rho)).

So the questions are two:

1) What is the right way to calculate Fixed and Random Effects for a long panel?

2) Would specifying rho = 0 completely eliminate the AR(1) process for the errors, and leave us with an estimation that fits our data?

• How many explanatory variables and what kind of fixed and random effects are included in the model? – mzuba Aug 1 '13 at 8:29
• I have the following model (D is a dummy that asks: is this a bank A or B?): beta=L.lev L.roa L.rwaa L.levD L.roaD L.rwaaD D i.year. In total, 6 + 2 dummies. The year dummies are 15. I also added an ID dummy, but it wasn't significant. The D dummy is not significant by itself either. – Herman Haugland Aug 1 '13 at 8:30
• This means that your model is actually two seperate models for bank A and bank B, the only restriction being that the year dummies are the same. Do you get the same problems if you specify independent regressions, i.e. if D and if !D ? – mzuba Aug 1 '13 at 9:16
• @Herman : In your question you said you have N = 5, T = 61 but in the comments you said you have N=2 and T=15. Am I missing something here? – Metrics Aug 1 '13 at 18:24
• @Metrics: No, I did not. My N is 5, and my T is 61. 2 are my dummies: year and "Is this bank A or B". 3 dummies if you include the ID variable. 16-1=15 is the number of year dummies, but my data is quarterly, so my T is 61. – Herman Haugland Aug 3 '13 at 10:30