There's a user-written panel version of the random effects SUR estimator that you can obtain with ssc install xtsur
. I am assuming you are using a RE estimator since that is the default with xtreg
. The "add a constant" part is a bit of a hack, and I can't quite tell if it is in fact a bad idea.
Here's an toy example of what this would look like:
. webuse nlswork
(National Longitudinal Survey. Young Women 14-26 years of age in 1968)
. gen constant=1
. xtsur (ln_wage constant age) (hours constant age)
(running multi-step estimates...)
Calculating multi-step estimates...
Iteration 1 : relative difference = .00761817
Iteration 2 : relative difference = 6.278e-11
Seemingly unrelated regression (SUR) in panel data set
One-way random effect estimation:
------------------------------------------------------------------------------
Number of Group variable: 15 Number of obs = 28443
Panel variable: idcode Number of eqn = 2
Time variable : year Number of panels = 15
Random effects u_i ~ Gaussian
corr(u_i, e_it) = 0 (assumed)
Panel type : unbalanced
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
ln_wage |
constant | 1.091836 .0125271 87.16 0.000 1.067283 1.116388
age | .0192946 .0002957 65.26 0.000 .0187151 .019874
-------------+----------------------------------------------------------------
hours |
constant | 37.04146 .2495206 148.45 0.000 36.55241 37.53052
age | -.0271416 .0071549 -3.79 0.000 -.0411649 -.0131183
-------------+----------------------------------------------------------------
sigma_u | see e(sigma_u)
sigma_e | see e(sigma_e)
------------------------------------------------------------------------------
Dependent variables: ln_wage hours
Independent variables: age
------------------------------------------------------------------------------
. test [ln_wage]age=[hours]age
( 1) [ln_wage]age - [hours]age = 0
chi2( 1) = 42.51
Prob > chi2 = 0.0000
lincom
would also work here:
. lincom [ln_wage]age - [hours]age
( 1) [ln_wage]age - [hours]age = 0
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | .0464362 .0071221 6.52 0.000 .0324772 .0603951
------------------------------------------------------------------------------
The coefficients match the output of xtreg
pretty closely in this case, though they won't be identical:
. xtreg ln_wage age, re
Random-effects GLS regression Number of obs = 28510
Group variable: idcode Number of groups = 4710
R-sq: within = 0.1026 Obs per group: min = 1
between = 0.0877 avg = 6.1
overall = 0.0774 max = 15
Wald chi2(1) = 3140.35
corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000
------------------------------------------------------------------------------
ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0185667 .0003313 56.04 0.000 .0179174 .0192161
_cons | 1.120439 .0112038 100.01 0.000 1.09848 1.142398
-------------+----------------------------------------------------------------
sigma_u | .36972456
sigma_e | .30349389
rho | .59743613 (fraction of variance due to u_i)
------------------------------------------------------------------------------
. xtreg hours age, re
Random-effects GLS regression Number of obs = 28443
Group variable: idcode Number of groups = 4709
R-sq: within = 0.0005 Obs per group: min = 1
between = 0.0007 avg = 6.0
overall = 0.0002 max = 15
Wald chi2(1) = 7.81
corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0052
------------------------------------------------------------------------------
hours | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0240426 .0086031 -2.79 0.005 -.0409043 -.0071809
_cons | 36.97867 .2717048 136.10 0.000 36.44613 37.5112
-------------+----------------------------------------------------------------
sigma_u | 6.4129132
sigma_e | 8.2312259
rho | .37771867 (fraction of variance due to u_i)
------------------------------------------------------------------------------
xtreg
code with the, fe
option. $\endgroup$