Oh, you are right. Here is the correct file. I sure have botched this query, thanks for catching it Robert! Sorry for so many posts to the list.<br><br>Regards,<br>Steve<br><br><br><br><div class="gmail_quote">On Tue, May 19, 2009 at 12:19 PM, Robert Iquiapaza <span dir="ltr"><<a href="mailto:rbali@ufmg.br">rbali@ufmg.br</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="padding-left: 10px; padding-right: 10px; padding-top: 15px;" name="Compose message area">
<div><font size="2" face="Arial">Stev,</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">The data you provided is not complete, <font size="3" face="Times New Roman">lagdlfdi and laglnstock2000 are not in the csv
file</font></font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">Robert</font></div>
<div style="font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
<div><br></div>
<div style="background: rgb(245, 245, 245) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<div><b>From:</b> <a title="mailto:archstevej@gmail.com
CTRL + Clique para seguir o link" href="mailto:archstevej@gmail.com" target="_blank">Steven Archambault</a> </div>
<div><b>Sent:</b> Monday, May 18, 2009 5:06 PM</div>
<div><b>To:</b> <a title="Giovanni_Millo@generali.com" href="mailto:Giovanni_Millo@generali.com" target="_blank">Millo Giovanni</a> </div>
<div><b>Cc:</b> <a title="mailto:r-sig-finance@stat.math.ethz.ch
CTRL + Clique para seguir o link" href="mailto:r-sig-finance@stat.math.ethz.ch" target="_blank">r-sig-finance@stat.math.ethz.ch</a>
; <a title="mailto:yves.croissant@let.ish-lyon.cnrs.fr
CTRL + Clique para seguir o link" href="mailto:yves.croissant@let.ish-lyon.cnrs.fr" target="_blank">Yves Croissant</a> ; <a title="mailto:christian.kleiber@unibas.ch
CTRL + Clique para seguir o link" href="mailto:christian.kleiber@unibas.ch" target="_blank">Christian Kleiber</a> </div>
<div><b>Subject:</b> Re: [R-SIG-Finance] R: [Fwd: R-SIG-Finance Digest, Vol 60,
Issue 18]</div></div></div><div><div></div><div class="h5">
<div><br></div>I just realized I used Robust in my Stata 9.2 analysis. When I
remove this, the Chi-sq values are much closer to the values I get in R (but
negative, as the consistent model must be listed first in a chi-sq calculation).
However, with my own data I do get this positive definite error in Stata. Is
this a result of unbalanced data? R doesn't give an error, so I am inclined to
ignore it in Stata. I am posting my own results from R and Stata, and attaching
the data as a csv.<br><br>Thanks, hope I am not wasting too much of your time
here.<br><br>-Steve<br><br>###R-Output###<br>> library("plm")<br>>
<br>> fdi <- read.csv("C:/data/mydata.csv", na.strings=".")<br>>
fdiplm<-plm.data(fdi, index = c("id_code_id",
"year"))<br>series are constants and have been removed<br>>
<br>> fdi_test<-(lfdi_2000~ lagdlfdi+ laglnstock2000+ lagtradegdp
+lagdlgdp)<br>> <br>> fdi_test_fe <- plm(fdi_test, data=fdiplm,
model="within")<br>> fdi_test_re <- plm(fdi_test, data=fdiplm,
model="random")<br>> <br>> summary (fdi_test_fe)<br>Oneway (individual)
effect Within Model<br><br>Call:<br>plm(formula = fdi_test, data = fdiplm, model
= "within")<br><br>Unbalanced Panel: n=149, T=3-27, N=2697<br><br>Residuals
:<br> Min. 1st Qu. Median 3rd Qu. Max.
<br>-8.2100 -0.4760 0.0452 0.5670 4.8700 <br><br>Coefficients
:<br>
Estimate Std. Error t-value Pr(>|t|)
<br>lagdlfdi 0.1564759 0.0180645
8.6621 < 2.2e-16 ***<br>laglnstock2000 0.7621350 0.0246798 30.8809 <
2.2e-16 ***<br>lagtradegdp 0.0178568 0.0025859
6.9055 5.003e-12 ***<br>lagdlgdp
0.2601477 0.0427744 6.0818 1.188e-09 ***<br>---<br>Signif.
codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 <br><br>Total Sum of
Squares: 4606.7<br>Residual Sum of Squares:
2938<br>F-statistic: 361.237 on 4 and 2544 DF, p-value: < 2.22e-16<br>>
summary (fdi_test_re)<br>Oneway (individual) effect Random Effect Model
<br> (Swamy-Arora's transformation)<br><br>Call:<br>plm(formula =
fdi_test, data = fdiplm, model = "random")<br><br>Unbalanced Panel: n=149,
T=3-27,
N=2697<br><br>Effects:<br>
var std.dev share<br>idiosyncratic 1.15487 1.07465
0.6617<br>individual 0.59044 0.76840 0.3383<br>theta :
<br> Min. 1st Qu. Median Mean 3rd
Qu. Max. <br> 0.3718 0.6700 0.7081
0.6955 0.7355 0.7401 <br><br>Residuals :<br>
Min. 1st Qu. Median Mean 3rd
Qu. Max. <br>-9.15000 -0.47900 0.07270
-0.00713 0.59800 3.95000 <br><br>Coefficients
:<br>
Estimate Std. Error t-value Pr(>|t|)
<br>(Intercept) 16.7744214 0.1552868 108.0222 <
2.2e-16 ***<br>lagdlfdi
0.1632388 0.0181005 9.0185 < 2.2e-16
***<br>laglnstock2000 0.8314432 0.0196444 42.3247 < 2.2e-16
***<br>lagtradegdp 0.0119453 0.0020737
5.7605 8.386e-09 ***<br>lagdlgdp
0.2558009 0.0424599 6.0245 1.696e-09 ***<br>---<br>Signif.
codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 <br><br>Total Sum of
Squares: 9522.3<br>Residual Sum of Squares:
3140.8<br>F-statistic: 1367.42 on 4 and 2692 DF, p-value: < 2.22e-16<br>>
<br>> phtest(fdi_test_re,
fdi_test_fe)<br><br> Hausman
Test<br><br>data: fdi_test <br>chisq = 23.7021, df = 4, p-value =
9.164e-05<br>alternative hypothesis: one model is inconsistent
<br><br><br>###end R output###<br><br>###Stata 9.2 Output--canned###<br>xtreg
lfdi_2000 lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, fe;<br><br>Fixed-effects
(within)
regression
Number of obs =
2697<br>Group variable (i):
id_code_id
Number of groups =
149<br><br>R-sq: within =
0.3622
Obs per group: min =
3<br> between =
0.8234
avg = 18.1<br>
overall =
0.6998
max =
27<br><br>
F(4,2544)
= 361.24<br>corr(u_i, Xb) =
0.3536
Prob > F
=
0.0000<br><br>------------------------------------------------------------------------------<br>
lfdi_2000 | Coef. Std.
Err. t
P>|t| [95% Conf.
Interval]<br>-------------+----------------------------------------------------------------<br>
lagdlfdi | .1564758 .0180645
8.66 0.000 .1210532
.1918985<br>laglnst~2000 | .762135
.0246798 30.88 0.000
.7137404 .8105295<br> lagtradegdp |
.0178568 .0025859 6.91
0.000 .0127861
.0229274<br> lagdlgdp | .2601478
.0427744 6.08 0.000
.1762716 .3440241<br>
_cons | 17.01131 .1701713
99.97 0.000
16.67762
17.345<br>-------------+----------------------------------------------------------------<br>
sigma_u | .93048942<br> sigma_e |
1.0746505<br> rho |
.42847396 (fraction of variance due to
u_i)<br>------------------------------------------------------------------------------<br>F
test that all u_i=0: F(148, 2544) =
10.73 Prob > F =
0.0000<br><br>. estimates store FIX, title(The FE) ;<br><br>. xtreg lfdi_2000
lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, re;<br><br>Random-effects GLS
regression
Number of obs =
2697<br>Group variable (i):
id_code_id
Number of groups =
149<br><br>R-sq: within =
0.3606
Obs per group: min =
3<br> between =
0.8402
avg = 18.1<br>
overall =
0.7128
max = 27<br><br>Random effects u_i ~
Gaussian
Wald chi2(4) =
2225.46<br>corr(u_i, X) = 0
(assumed)
Prob > chi2 =
0.0000<br><br>------------------------------------------------------------------------------<br>
lfdi_2000 | Coef. Std.
Err. z
P>|z| [95% Conf.
Interval]<br>-------------+----------------------------------------------------------------<br>
lagdlfdi | .1631662 .0180937
9.02 0.000 .1277032
.1986291<br>laglnst~2000 | .830845
.0196843 42.21 0.000
.7922645 .8694255<br> lagtradegdp |
.011992 .0020779 5.77
0.000 .0079195
.0160645<br> lagdlgdp | .2558113
.0424486 6.03 0.000
.1726136 .3390091<br>
_cons | 16.77702 .1556693 107.77
0.000 16.47191
17.08212<br>-------------+----------------------------------------------------------------<br>
sigma_u | .77431228<br> sigma_e |
1.0746505<br> rho |
.34173973 (fraction of variance due to
u_i)<br>------------------------------------------------------------------------------<br><br>.
estimates store RAND, title(The RE) ;<br><br>. hausman FIX
RAND;<br><br>
---- Coefficients
----<br>
|
(b)
(B)
(b-B)
sqrt(diag(V_b-V_B))<br>
|
FIX
RAND
Difference
S.E.<br>-------------+----------------------------------------------------------------<br>
lagdlfdi | .1564758
.1631662
-.0066903
.<br>laglnst~2000 |
.762135
.830845
-.06871
.014887<br> lagtradegdp |
.0178568
.011992
.0058648
.0015393<br> lagdlgdp |
.2601478
.2558113
.0043365
.0052695<br>------------------------------------------------------------------------------<br>
b = consistent under Ho and Ha; obtained from
xtreg<br> B =
inconsistent under Ha, efficient under Ho; obtained from
xtreg<br><br> Test: Ho: difference in coefficients
not
systematic<br><br>
chi2(4) =
(b-B)'[(V_b-V_B)^(-1)](b-B)<br>
=
22.94<br>
Prob>chi2 =
0.0001<br>
(V_b-V_B is not positive definite)<br>###End Stata
9.2####<br><br><br><br><br><br><br><br>
<div class="gmail_quote">On Mon, May 18, 2009 at 12:26 PM, Steven Archambault
<span dir="ltr"><<a href="mailto:archstevej@gmail.com" target="_blank">archstevej@gmail.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div>Giovani,</div>
<div> </div>
<div>Thank you so much for your comments. I am a bit new to R, and to
these mailing lists, so I apologize for being sparse on the details and
examples. I am using Stata 9.2, which might be the answer to my problem, as
you described. I have done quite a bit of internet searching, and did not read
anywhere about the use of a different method for calculating the chi-sq value,
so thanks for that. </div>
<div> </div>
<div>
<div>One more issue I have been thinking about. I am assuming your
Plm package knows that the FE is the consistient model, as the same results
arrive if the code is phtest(femod, remod) or phtest(remod, femod). The
order does matter in Stata.</div>
<div> </div></div>
<div>For complteness I am going to post my results using the same Grumfeld
dataset for both stata 9.2 (by hand calculation and canned procedure) and
R. I am using the Plm package version 1 1-2.</div>
<div> </div>
<div>Regards,</div>
<div>Steve</div>
<div> </div>
<div> </div>
<div> </div>
<div><font size="2" face="NimbusRomNo9L-Regu"><font size="2" face="NimbusRomNo9L-Regu"></font></font> ## begin Stata9.2
output##</div>
<div>xtreg inv value capital, robust re;</div>
<p></p>
<div>Random-effects GLS
regression
Number of obs
= 200<br></div>Group variable (i):
firmid
Number of groups = 10
<div>
<p>R-sq: within =
0.7668
Obs per group: min =
20<br> between =
0.8196
avg =
20.0<br> overall =
0.8061
max = 20</p></div>
<p>Random effects u_i ~
Gaussian
Wald chi2(3) =
77.70</p>
<div><br>corr(u_i, X) = 0
(assumed)
Prob > chi2 =
0.0000</div>
<p>------------------------------------------------------------------------------<br>
|
Robust<br> invest
| Coef. Std.
Err. z
P>|z| [95% Conf.
Interval]<br>-------------+----------------------------------------------------------------<br>
value | .1097811 .0197587
5.56 0.000 .0710547
.1485076<br> capital |
.308113 .0418387 7.36
0.000 .2261107
.3901153<br> _cons |
-57.83441 24.67795 -2.34
0.019 -106.2023
-9.466507<br>-------------+----------------------------------------------------------------</p>
<div><br> sigma_u |
84.20095<br> sigma_e |
52.767964<br> rho |
.71800838 (fraction of variance due to
u_i)<br>------------------------------------------------------------------------------</div>
<p>. matrix bfe=e(b);</p>
<p>. matrix vfe=e(V);</p>
<p>. estimates store remod;</p>
<p>. xtreg inv value capital, robust fe;</p>
<p></p>
<div>Fixed-effects (within)
regression
Number of obs
= 200<br></div>Group variable (i):
firmid
Number of groups = 10
<div>
<p>R-sq: within =
0.7668
Obs per group: min =
20<br> between =
0.8194
avg =
20.0<br> overall =
0.8060
max = 20</p></div>
<p>
F(2,188)
= 40.23</p>
<div><br>corr(u_i, Xb) =
-0.1517
Prob > F
= 0.0000</div>
<div>------------------------------------------------------------------------------<br>
|
Robust<br> invest
| Coef. Std.
Err. t
P>|t| [95% Conf.
Interval]<br>-------------+----------------------------------------------------------------<br>
value | .1101238 .019378
5.68 0.000 .0718975
.1483501<br> capital |
.3100653 .042795 7.25
0.000 .2256452
.3944854<br> _cons |
-58.74393 23.37422 -2.51
0.013 -104.8534
-12.63449<br>-------------+----------------------------------------------------------------
<div><br> sigma_u |
85.732501<br> sigma_e |
52.767964<br> rho |
.72525012 (fraction of variance due to
u_i)<br>------------------------------------------------------------------------------</div></div>
<div> </div>
<div> ###Hausman by hand### </div>
<p>. estimates store femod;</p>
<p>. matrix vre=e(V);</p>
<p>. matrix bre=e(b);</p>
<p>. matrix bdif=bfe-bre;</p>
<p>. matrix list bdif;</p>
<p>bdif[1,3]<br>
value capital
_cons<br>y1 -.00034265 -.00195236 .90952273</p>
<p>. matrix bdifp=bdif';</p>
<p>. matrix dv=vfe-vre;</p>
<p>. matrix dvi=inv(dv);</p>
<p>. matrix list bdif;</p>
<p>bdif[1,3]<br>
value capital
_cons<br>y1 -.00034265 -.00195236 .90952273</p>
<p>. matrix list bdifp;</p>
<p>bdifp[3,1]<br>
y1<br> value -.00034265<br>capital -.00195236<br>
_cons .90952273</p>
<p>. matrix list dvi;</p>
<p>symmetric
dvi[3,3]<br>
value capital
_cons<br> value -7739.3615<br>capital
5808.2905 -5305.811<br> _cons
3.6641311 .98569198 -.00051157</p>
<p>. matrix chisq=bdif*dvi*bdifp;</p>
<p>. matrix list chisq;</p>
<p>symmetric
chisq[1,1]<br>
y1<br>y1 -.01956929</p>
<div>###Hausman canned###</div>
<div>. hausman femod remod;</div>
<p></p>
<div>
---- Coefficients
----<br>
|
(b)
(B)
(b-B)
sqrt(diag(V_b-V_B))<br>
| femod
remod
Difference
S.E.<br>-------------+----------------------------------------------------------------<br>
value | .1101238
.1097811
.0003427
.<br></div> capital |
.3100653
.308113
.0019524
.0089965<br>------------------------------------------------------------------------------
<div><br>
b = consistent under Ho and Ha; obtained from
xtreg<br> B
= inconsistent under Ha, efficient under Ho; obtained from xtreg</div>
<div>
<p> Test: Ho: difference in coefficients not
systematic</p></div>
<p></p>
<div>
chi2(2) =
(b-B)'[(V_b-V_B)^(-1)](b-B)<br></div>
= -0.01 chi2<0 ==> model fitted on
these<br>
data fails to meet the
asymptotic<br>
assumptions of the Hausman
test;<br>
see suest for a generalized test
<div>## end Stata9.2 output ##</div>
<div> </div>
<div>##begin Output R, using PLM 1.1-2###<font size="2" face="NimbusRomNo9L-Regu"><font size="2" face="NimbusRomNo9L-Regu">
<p align="left">> test<-data(Grunfeld, package="Ecdat")<br>> <br>>
fm <- inv~value+capital<br>> femod <- plm(fm, Grunfeld,
model="within")<br>> summary(femod)<br>Oneway (individual) effect Within
Model</p>
<p align="left">Call:<br>plm(formula = fm, data = Grunfeld, model =
"within")</p>
<p align="left">Balanced Panel: n=10, T=20, N=200</p>
<p align="left">Residuals :<br> Min. 1st Qu.
Median 3rd Qu. Max. <br>-184.000
-17.600 0.563 19.200 251.000 </p>
<p align="left">Coefficients :<br>
Estimate Std. Error t-value Pr(>|t|)
<br>value 0.110124 0.011857 9.2879 < 2.2e-16
***<br>capital 0.310065 0.017355 17.8666 < 2.2e-16
***<br>---<br>Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘
’ 1 </p>
<p align="left">Total Sum of Squares: 2244400<br>Residual Sum
of Squares: 523480<br>F-statistic: 309.014 on 2 and 188 DF, p-value: <
2.22e-16</p>
<div><br>> remod <- plm(fm, Grunfeld, model="random")<br></div>>
summary(remod)<br>Oneway (individual) effect Random Effect Model
<br> (Swamy-Arora's transformation)
<p align="left">Call:<br>plm(formula = fm, data = Grunfeld, model =
"random")</p>
<p align="left">Balanced Panel: n=10, T=20, N=200</p>
<p align="left">Effects:<br>
var std.dev share<br>idiosyncratic 2784.458 52.768
0.282<br>individual 7089.800 84.201
0.718<br>theta: 0.86122 </p>
<p align="left">Residuals :<br> Min. 1st Qu. Median 3rd
Qu. Max. <br>-178.00 -19.70
4.69 19.50 253.00 </p>
<p align="left">Coefficients
:<br>
Estimate Std. Error t-value Pr(>|t|) <br>(Intercept)
-57.834415 28.898935 -2.0013 0.04536 *
<br>value 0.109781
0.010493 10.4627 < 2e-16
***<br>capital 0.308113
0.017180 17.9339 < 2e-16 ***<br>---<br>Signif. codes: 0 ‘***’
0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 </p>
<p align="left">Total Sum of Squares: 2381400<br>Residual Sum
of Squares: 548900<br>F-statistic: 328.837 on 2 and 197 DF, p-value: <
2.22e-16<br>> phtest(femod, remod)</p>
<div>
<p align="left"> Hausman Test</p>
<p align="left">data: fm <br>chisq = 2.3304, df = 2, p-value =
0.3119<br>alternative hypothesis: one model is inconsistent </p></div>
<p align="left">###end Plm###</p>
<p align="left"> </p></font></font><br><br><br></div>
<div>
<div></div>
<div>
<div class="gmail_quote">On Mon, May 18, 2009 at 6:01 AM, Millo Giovanni <span dir="ltr"><<a href="mailto:Giovanni_Millo@generali.com" target="_blank">Giovanni_Millo@generali.com</a>></span> wrote:<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;" class="gmail_quote">Dear Steve,<br><br>I got your inquiry courtesy of
Christian Kleiber, who brought it to our<br>attention: please next time you
post anything re a given package,<br>include the maintainer's address. We
cannot guarantee to parse all the<br>daily digests of the R
system!<br><br>Your problem: can you please provide a reproducible example?
Else it is<br>difficult to help, not knowing your data, your results and
even the<br>Stata version you're using.<br><br>In the following I replicate
what you might have done on a well-known<br>dataset.<br><br>From Stata10, on
the usual Grunfeld data taken from package "Ecdat":<br><br>## begin Stata10
output ##<br>. xtreg inv value capital<br><br>Random-effects GLS regression
Number of obs
=<br>200<br>Group variable: firm
Number of groups =<br>10<br><br>R-sq: within =
0.7668
Obs per group: min =<br>20<br> between =
0.8196
avg
=<br>20.0<br> overall = 0.8061
max =<br>20<br><br>Random effects
u_i ~ Gaussian
Wald chi2(2) =<br>657.67<br>corr(u_i, X)
= 0 (assumed)
Prob > chi2
=<br>0.0000<br><br>------------------------------------------------------------------------<br>------<br>
inv | Coef. Std. Err.
z P>|z| [95%
Conf.<br>Interval]<br>-------------+----------------------------------------------------------<br>------<br>
value | .1097811 .0104927 10.46
0.000 .0892159<br>.1303464<br> capital |
.308113 .0171805 17.93 0.000
.2744399<br>.3417861<br> _cons | -57.83441
28.89893 -2.00 0.045
-114.4753<br>-1.193537<br>-------------+----------------------------------------------------------<br>------<br>
sigma_u | 84.20095<br> sigma_e |
52.767964<br> rho | .71800838
(fraction of variance due to
u_i)<br>------------------------------------------------------------------------<br>------<br><br>.
estimates store remod<br><br>. xtreg inv value capital,
fe<br><br>Fixed-effects (within) regression
Number of obs =<br>200<br>Group
variable: firm
Number of groups
=<br>10<br><br>R-sq: within = 0.7668
Obs per group: min
=<br>20<br> between = 0.8194
avg =<br>20.0<br>
overall = 0.8060
max =<br>20<br><br>
F(2,188)
=<br>309.01<br>corr(u_i, Xb) = -0.1517
Prob
> F
=<br>0.0000<br><br>------------------------------------------------------------------------<br>------<br>
inv | Coef. Std. Err.
t P>|t| [95%
Conf.<br>Interval]<br>-------------+----------------------------------------------------------<br>------<br>
value | .1101238 .0118567 9.29
0.000 .0867345<br>.1335131<br> capital |
.3100653 .0173545 17.87 0.000
.2758308<br>.3442999<br> _cons | -58.74393
12.45369 -4.72 0.000
-83.31086<br>-34.177<br>-------------+----------------------------------------------------------<br>------<br>
sigma_u | 85.732501<br> sigma_e |
52.767964<br> rho | .72525012
(fraction of variance due to
u_i)<br>------------------------------------------------------------------------<br>------<br>F
test that all u_i=0: F(9, 188) = 49.18
Prob > F =<br>0.0000<br><br>.
estimates store femod<br><br>. hausman femod remod<br><br>
---- Coefficients ----<br>
| (b)
(B)
(b-B)<br>sqrt(diag(V_b-V_B))<br>
| femod remod
Difference
S.E.<br>-------------+----------------------------------------------------------<br>------<br>
value | .1101238 .1097811
.0003427 .0055213<br>
capital | .3100653 .308113
.0019524
.0024516<br>------------------------------------------------------------------------<br>------<br>
b = consistent under Ho and Ha; obtained from<br>xtreg<br>
B = inconsistent under Ha, efficient under
Ho; obtained from<br>xtreg<br><br> Test: Ho:
difference in coefficients not systematic<br><br>
chi2(2) =
(b-B)'[(V_b-V_B)^(-1)](b-B)<br>
=
2.33<br>
Prob>chi2 = 0.3119<br><br>.<br>## end Stata10
output ##<br><br>while from plm I get<br><br>## begin R putput ##<br>>
data(Grunfeld, package="Ecdat")<br>> fm <-
inv~value+capital<br>><br>> femod <- plm(fm, Grunfeld)<br>>
remod <- plm(fm, Grunfeld, model="random")<br>><br>> phtest(femod,
remod)<br><br> Hausman Test<br><br>data:
fm<br>chisq = 2.3304, df = 2, p-value = 0.3119<br>alternative
hypothesis: one model is inconsistent<br><br>## end R output
##<br><br>which, besides testifying to the goodness and parsimony of
an<br>object-oriented approach as far as screen output is concerned,
looks<br>rather consistent to me.<br><br>I cannot but guess that the problem
might stem from different RE<br>estimates: previous versions of Stata used
the Wallace-Hussein method by<br>default for computing the variance of
random effects. Now Stata uses<br>Swamy-Arora, which has been the default of
'plm' since the beginning.<br>Yet as plm() allows to choose, you can
experiment with different values<br>for the 'random.method' argument in
order to see if you get the Stata<br>result. I suggest you start by
comparing the coefficient estimates you<br>get from Stata and R: FE should
be unambiguous, RE might vary as said<br>above, and for good
reason.<br><br>You also didn't tell us whether your by-hand calculation
agrees with<br>phtest() output? (I guess it does not)<br><br>Please let us
know, possibly with a reproducible example and providing<br>all the above
info<br>Giovanni<br><br>PS please also make sure you're not using any
VEEEEERY old version of<br>'plm' (prior to, say, 0.3): these had a bug in
the p-value calculation<br>which made it depend on the order of models
compared (so that in the<br>wrong case you got p.value=1).<br><br>Giovanni
Millo<br>Research Dept.,<br>Assicurazioni Generali SpA<br>Via Machiavelli
4,<br>34132 Trieste (Italy)<br>tel. +39 040 671184<br>fax +39 040
671160<br><br>>
----------------------------------------------------------------------<br>>
--<br>><br>> Subject:<br>> [R-SIG-Finance] Chi-sq Hausman test---R
vs Stata<br>> From:<br>> Steven Archambault <<a href="mailto:archstevej@gmail.com" target="_blank">archstevej@gmail.com</a>><br>> Date:<br>> Sun, 17 May
2009 23:14:13 -0600<br>> To:<br>> <a href="mailto:r-sig-finance@stat.math.ethz.ch" target="_blank">r-sig-finance@stat.math.ethz.ch</a><br>><br>>
To:<br>> <a href="mailto:r-sig-finance@stat.math.ethz.ch" target="_blank">r-sig-finance@stat.math.ethz.ch</a><br>><br>><br>> Hi
all,<br>><br>> I am running a panel time series regression testing
Fixed Effects and<br>> Random Effects. I decided to calculate the chi-sq
value for the<br>> Hausman test in both R (Phtest) and Stata. I get
different results.<br>> Even within Stata, calculating the Chi-sq value
with the canned<br>> procedure or by hand (using<br>> matrices) gives
different results. So, the question should come up<br>there as<br>>
well.<br>><br>> Does anybody have any insight on how to pick which
results to use? I<br>> guess the one that gives the result I want? Having
different programs<br>> give quite different values for the same tests is
frustrating me. I'd<br><br>> be interested in any feedback folks
have!<br>><br>> Thanks,<br>> Steve<br>><br>>
[[alternative HTML version
deleted]]<br></blockquote></div><br></div></div></blockquote></div><br>
</div></div><p>
</p><hr>
<p></p>_______________________________________________<br><a href="mailto:R-SIG-Finance@stat.math.ethz.ch" target="_blank">R-SIG-Finance@stat.math.ethz.ch</a>
mailing list<br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a><br>--
Subscriber-posting only.<br>-- If you want to post, subscribe
first.</div>
</blockquote></div><br>