Skip to content
Prev 4078 / 15274 Next

R: [Fwd: R-SIG-Finance Digest, Vol 60, Issue 18]

It seems that in STATA your are using a robust covariance-matrix
estimators meanwhile in R not. This might explain the difference in the
Hausman tests. I am not an expert in the PLM package, but there is a
function "vcovHC" which uses a robust covariance matrix estimator
(White). You might try this.

Sincerely,

Luis 
-----Mensaje original-----
De: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] En nombre de Steven
Archambault
Enviado el: Lunes, 18 de Mayo de 2009 01:27 p.m.
Para: Millo Giovanni
CC: r-sig-finance at stat.math.ethz.ch; Yves Croissant; Christian Kleiber
Asunto: Re: [R-SIG-Finance] R: [Fwd: R-SIG-Finance Digest, Vol 60, Issue
18]

Giovani,

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.

 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.

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.

Regards,
Steve



 ## begin Stata9.2 output##
xtreg inv value capital, robust re;

Random-effects GLS regression                   Number of obs      =
200
Group variable (i): firmid                      Number of groups   =
10

R-sq:  within  = 0.7668                         Obs per group: min =
20
       between = 0.8196                                        avg =
20.0
       overall = 0.8061                                        max =
20

Random effects u_i ~ Gaussian                   Wald chi2(3)       =
77.70
corr(u_i, X)       = 0 (assumed)                Prob > chi2        =
0.0000

------------------------------------------------------------------------
------
             |               Robust
      invest |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------
-------------+------
       value |   .1097811   .0197587     5.56   0.000     .0710547
.1485076
     capital |    .308113   .0418387     7.36   0.000     .2261107
.3901153
       _cons |  -57.83441   24.67795    -2.34   0.019    -106.2023
-9.466507
-------------+----------------------------------------------------------
-------------+------
     sigma_u |   84.20095
     sigma_e |  52.767964
         rho |  .71800838   (fraction of variance due to u_i)
------------------------------------------------------------------------
------

. matrix bfe=e(b);

. matrix vfe=e(V);

. estimates store remod;

. xtreg inv value capital, robust fe;

Fixed-effects (within) regression               Number of obs      =
200
Group variable (i): firmid                      Number of groups   =
10

R-sq:  within  = 0.7668                         Obs per group: min =
20
       between = 0.8194                                        avg =
20.0
       overall = 0.8060                                        max =
20

                                                F(2,188)           =
40.23
corr(u_i, Xb)  = -0.1517                        Prob > F           =
0.0000
------------------------------------------------------------------------
------
             |               Robust
      invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+----------------------------------------------------------
-------------+------
       value |   .1101238    .019378     5.68   0.000     .0718975
.1483501
     capital |   .3100653    .042795     7.25   0.000     .2256452
.3944854
       _cons |  -58.74393   23.37422    -2.51   0.013    -104.8534
-12.63449
-------------+----------------------------------------------------------
-------------+------
     sigma_u |  85.732501
     sigma_e |  52.767964
         rho |  .72525012   (fraction of variance due to u_i)
------------------------------------------------------------------------
------

 ###Hausman by hand###

. estimates store femod;

. matrix vre=e(V);

. matrix bre=e(b);

. matrix bdif=bfe-bre;

. matrix list bdif;

bdif[1,3]
         value     capital       _cons
y1  -.00034265  -.00195236   .90952273

. matrix bdifp=bdif';

. matrix dv=vfe-vre;

. matrix dvi=inv(dv);

. matrix list bdif;

bdif[1,3]
         value     capital       _cons
y1  -.00034265  -.00195236   .90952273

. matrix list bdifp;

bdifp[3,1]
                 y1
  value  -.00034265
capital  -.00195236
  _cons   .90952273

. matrix list dvi;

symmetric dvi[3,3]
              value     capital       _cons
  value  -7739.3615
capital   5808.2905   -5305.811
  _cons   3.6641311   .98569198  -.00051157

. matrix chisq=bdif*dvi*bdifp;

. matrix list chisq;

symmetric chisq[1,1]
            y1
y1  -.01956929
###Hausman canned###
.  hausman femod remod;

                 ---- Coefficients ----
             |      (b)          (B)            (b-B)
sqrt(diag(V_b-V_B))
             |     femod        remod        Difference          S.E.
-------------+----------------------------------------------------------
-------------+------
       value |    .1101238     .1097811        .0003427               .
     capital |    .3100653      .308113        .0019524        .0089965
------------------------------------------------------------------------
------
                           b = consistent under Ho and Ha; obtained from
xtreg
            B = inconsistent under Ha, efficient under Ho; obtained from
xtreg

    Test:  Ho:  difference in coefficients not systematic

                  chi2(2) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                          =    -0.01    chi2<0 ==> model fitted on these
                                        data fails to meet the
asymptotic
                                        assumptions of the Hausman test;
                                        see suest for a generalized test
## end Stata9.2 output ##

##begin Output R, using PLM 1.1-2###
Oneway (individual) effect Within Model

Call:
plm(formula = fm, data = Grunfeld, model = "within")

Balanced Panel: n=10, T=20, N=200

Residuals :
    Min.  1st Qu.   Median  3rd Qu.     Max.
-184.000  -17.600    0.563   19.200  251.000

Coefficients :
        Estimate Std. Error t-value  Pr(>|t|)
value   0.110124   0.011857  9.2879 < 2.2e-16 ***
capital 0.310065   0.017355 17.8666 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    2244400
Residual Sum of Squares: 523480
F-statistic: 309.014 on 2 and 188 DF, p-value: < 2.22e-16
Oneway (individual) effect Random Effect Model
   (Swamy-Arora's transformation)

Call:
plm(formula = fm, data = Grunfeld, model = "random")

Balanced Panel: n=10, T=20, N=200

Effects:
                   var  std.dev share
idiosyncratic 2784.458   52.768 0.282
individual    7089.800   84.201 0.718
theta:  0.86122

Residuals :
   Min. 1st Qu.  Median 3rd Qu.    Max.
-178.00  -19.70    4.69   19.50  253.00

Coefficients :
              Estimate Std. Error t-value Pr(>|t|)
(Intercept) -57.834415  28.898935 -2.0013  0.04536 *
value         0.109781   0.010493 10.4627  < 2e-16 ***
capital       0.308113   0.017180 17.9339  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    2381400
Residual Sum of Squares: 548900
F-statistic: 328.837 on 2 and 197 DF, p-value: < 2.22e-16
Hausman Test

data:  fm
chisq = 2.3304, df = 2, p-value = 0.3119 alternative hypothesis: one
model is inconsistent

###end Plm###





On Mon, May 18, 2009 at 6:01 AM, Millo Giovanni
<Giovanni_Millo at generali.com
=
beginning.
AVISO LEGAL: 
- Las opiniones que contenga este mensaje son exclusivas de su autor y no necesariamente representan la opini?n oficial del Banco de la Rep?blica o de sus autoridades.
- El receptor deber? verificar posibles virus inform?ticos que tenga el correo o cualquier anexo a ?l, raz?n por la cual el Banco de la Rep?blica no aceptar? responsabilidad alguna por da?os causados por cualquier virus transmitido en este correo.
- La informaci?n contenida en este mensaje y en los archivos electr?nicos adjuntos es confidencial y reservada, conforme a lo previsto en la Constituci?n y en la Ley del Banco de la Rep?blica, y est? dirigida exclusivamente a su destinatario, sin la intenci?n de que sea revelada o divulgada a 
otras personas. El acceso al contenido de esta comunicaci?n por cualquier otra persona diferente al destinatario no est? autorizado por el Banco de la Rep?blica y est? sancionado de acuerdo con las normas legales aplicables.
- El que il?citamente sustraiga, oculte, extrav?e, destruya, intercepte, controle o impida esta comunicaci?n, antes de que llegue a su destinatario, estar? sujeto a las sanciones penales correspondientes. Igualmente, incurrir? en sanciones penales el que, en provecho propio o ajeno o 
con perjuicio de otro, divulgue o emplee la informaci?n contenida en esta comunicaci?n. En particular, los servidores p?blicos que reciban este mensaje est?n obligados a asegurar y mantener la confidencialidad de la informaci?n en ?l contenida y, en general, a cumplir con los deberes de custodia, cuidado, manejo y dem?s previstos en el r?gimen disciplinario.
- Si por error recibe este mensaje, le solicitamos enviarlo de vuelta al Banco de la Rep?blica a la direcci?n de correo electr?nico que se lo envi? y borrarlo de sus archivos electr?nicos o destruirlo.
 
LEGAL NOTICE:
- Any opinions contained in this message are exclusive of its author and not necessarily represent the official position of Banco de la Rep?blica or of its authorities.
- The recipient must verify the presence of possible informatic viruses in the mail or in any annex thereto, and for this reason Banco de la Rep?blica shall not be made liable for any damages caused by viruses transmitted hereby.
- The information contained in this message and in any electronic files annexed thereto is
confidential and privileged, as per the Colombian Constitution and the Law that governs Banco de la Rep?blica, and is directed exclusively to its addressee, with no intention of it being disclosed or revealed to third parties. The access to the content of this communication by any person different from its addressee is not authorized by Banco de la Rep?blica and shall be penalized in accordance with the applicable legal dispositions.
- Any person who illicitly removes, hides, distracts, destroys, intercepts, controls, or otherwise prevents this communication from arriving to its addressee, shall be subject to the appropriate criminal penalties. Likewise, criminal penalties shall be incurred by any who, either for his/her own benefit or on behalf of third parties, or with prejudice of a third party, discloses or employs the information contained in this communication. In particular, public servants that may receive this message shall be obliged to ensure and keep the confidentiality of the information contained
therein and, in general, to comply with the duties of custody, care, handling and other provided under the disciplinary regime.
- If you should happen to receive this message by mistake, please send it back to Banco de la Rep?blica to the same e-mail address and either delete it from your electronic files or destroy it.