Allin Cottrell <cottrell(a)wfu.edu> replied:
You can get that quite easily if you want it. Example:
open greene14_1.gdt
logs C Q PF
list X = l_Q l_PF LF
panel l_C 0 X --fixed
series ai = $ahat
# correlation matrix of ai and regressors
corr ai X
matrix b = $coeff[2:]
series Xb = {X}*b
# correlation reported by Stata
corr ai Xb
The last correlation is the one that is reported by Stata as
corr(u_i, Xb). I'm not aware of programs that print the first
correlation matrix.
Thank you for this: it did indeed work for the example you gave (including
Jack's later correction).
However, when I ran this for my own (unbalanced) panel dataset (N=47, T-36,
NT=823), -gretl- choked:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
? logs lavggdp pop
Listing 67 variables:
0) const 1) country 2) year
3) score 4) max 5) adjscore
6) order 7) first 8) size
9) visits 10) language 11) host
12) border_countrie 13) links 14) eu
15) nato 16) icc 17) kyoto
18) fh_pr 19) fh_cl 20) fhscore
21) iraq1 22) iraq2 23) polindex
24) lagwbgdp 25) lagungdp 26) lavggdp
27) pop 28) l_lavggdp 29) l_pop
30) dt_1 31) dt_2 32) dt_3
33) dt_4 34) dt_5 35) dt_6
36) dt_7 37) dt_8 38) dt_9
39) dt_10 40) dt_11 41) dt_12
42) dt_13 43) dt_14 44) dt_15
45) dt_16 46) dt_17 47) dt_18
48) dt_19 49) dt_20 50) dt_21
51) dt_22 52) dt_23 53) dt_24
54) dt_25 55) dt_26 56) dt_27
57) dt_28 58) dt_29 59) dt_30
60) dt_31 61) dt_32 62) dt_33
63) dt_34 64) dt_35 65) dt_36
66) dt_37
Warning: generated missing values
? list X = order first visits language host links fhscore l_lavggdp l_pop
dt_2-dt_36
Generated list X
? panel adjscore 0 X --robust
Model 4: Fixed-effects, using 823 observations
Included 47 cross-sectional units
Time-series length: minimum 1, maximum 37
Dependent variable: adjscore
Robust (HAC) standard errors
Omitted due to exact collinearity: dt_37
coefficient std. error t-ratio p-value
-----------------------------------------------------------
const -275.214 1101.01 -0.2500 0.8027
order 1.08344 0.259419 4.176 3.32e-05 ***
first 8.12990 14.4472 0.5627 0.5738
visits -4.30177 0.973728 -4.418 1.15e-05 ***
language -18.4580 6.61705 -2.789 0.0054 ***
host 15.3185 8.62230 1.777 0.0760 *
links 11.3360 2.38579 4.751 2.43e-06 ***
fhscore 4.84832 4.56374 1.062 0.2884
l_lavggdp -14.6571 10.3819 -1.412 0.1584
l_pop 5.48696 66.0810 0.08303 0.9338
dt_1 119.389 41.8247 2.855 0.0044 ***
dt_2 132.488 40.3803 3.281 0.0011 ***
dt_3 141.034 40.5656 3.477 0.0005 ***
dt_4 123.957 35.0240 3.539 0.0004 ***
dt_5 143.473 36.8987 3.888 0.0001 ***
dt_6 154.050 34.4538 4.471 9.01e-06 ***
dt_7 145.373 33.1778 4.382 1.35e-05 ***
dt_8 179.338 35.8883 4.997 7.29e-07 ***
dt_9 150.118 31.1913 4.813 1.81e-06 ***
dt_10 165.977 29.3945 5.647 2.34e-08 ***
dt_11 169.547 32.2387 5.259 1.90e-07 ***
dt_12 164.780 32.7179 5.036 5.98e-07 ***
dt_13 143.035 27.0339 5.291 1.61e-07 ***
dt_14 162.187 27.7669 5.841 7.81e-09 ***
dt_15 154.748 23.8133 6.498 1.50e-10 ***
dt_16 159.761 22.4501 7.116 2.65e-12 ***
dt_17 165.958 24.1232 6.880 1.29e-11 ***
dt_18 156.266 19.6676 7.945 7.33e-15 ***
dt_19 135.978 22.1994 6.125 1.48e-09 ***
dt_20 149.205 19.2219 7.762 2.82e-14 ***
dt_21 177.119 19.9124 8.895 4.54e-18 ***
dt_22 187.884 18.3915 10.22 5.42e-23 ***
dt_23 157.278 17.5641 8.955 2.79e-18 ***
dt_24 167.432 14.2153 11.78 1.92e-29 ***
dt_25 188.551 16.9743 11.11 1.34e-26 ***
dt_26 185.966 15.8267 11.75 2.54e-29 ***
dt_27 184.989 17.7171 10.44 6.97e-24 ***
dt_28 178.747 15.4103 11.60 1.13e-28 ***
dt_29 154.438 18.2544 8.460 1.45e-16 ***
dt_30 57.9160 19.2844 3.003 0.0028 ***
dt_31 25.7587 18.6302 1.383 0.1672
dt_32 45.6746 18.4930 2.470 0.0137 **
dt_33 3.04816 16.8308 0.1811 0.8563
dt_34 -5.74523 15.7867 -0.3639 0.7160
dt_35 13.7708 18.4558 0.7461 0.4558
dt_36 42.4965 14.1809 2.997 0.0028 ***
Mean dependent var -236.0365 S.D. dependent var 98.53478
Sum squared resid 1796860 S.E. of regression 49.57908
R-squared 0.774854 Adjusted R-squared 0.746827
F(91, 731) 27.64603 P-value(F) 2.3e-182
Log-likelihood -4331.643 Akaike criterion 8847.287
Schwarz criterion 9280.879 Hannan-Quinn 9013.630
rho -0.029294 Durbin-Watson 1.923296
Test for differing group intercepts -
Null hypothesis: The groups have a common intercept
Test statistic: F(46, 731) = 3.12977
with p-value = P(F(46, 731) > 3.12977) = 1.00693e-10
? series ai = $ahat
Generated series ai (ID 67)
? corr ai X
Correlation Coefficients, using the observations 1:01 - 47:37
(missing values were skipped)
ai order first visits language
1.0000 -0.1228 -0.2883 0.7048 0.3867 ai
1.0000 0.0955 -0.0049 -0.1280
order
1.0000 -0.2844 -0.0242
first
1.0000 0.0600
visits
1.0000
language
[...]
dt_36 dt_37
[...]
-0.0278 -0.0278 dt_33
-0.0278 -0.0278 dt_34
-0.0278 -0.0278 dt_35
1.0000 -0.0278 dt_36
1.0000 dt_37
? series Xb = lincomb(X, $coeff[2:])
Data error
? matrix b = $coeff[2:]
Generated matrix b
? series Xb = {X}*b
Matrices not conformable for operation
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Difficult to know how to fix this - my data is what it is!
Also, no information is given on the standard deviations of
> these FE error components which are used to compute \rho
> (which is shown): any reason as to why?
In the gretl output "rho" is the first-order autocorrelation
of the residuals. Perhaps you're thinking of the random
effects model, for which we have to calculate the within and
between error variances (to get what gretl calls "theta", the
quasi-demeaning coefficient). In that case we do print both
variances.
Sorry, but I don't see reference to a 'quasi-demeaning coeffiecent'
anywhere in the results, and any reference to 'theta' in the manual is in
the context of ARMA models, Kalman filters and matrices; I also looked at
the command reference as well - also nothing.
Clive Nicholas (
clivenicholas.posterous.com)
[Please DO NOT mail me personally here, but at <clivenicholas(a)hotmail.com>.
Please respond to contributions I make in a list thread here. Thanks!]
"My colleagues in the social sciences talk a great deal about methodology.
I prefer to call it style." -- Freeman J. Dyson