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

Robert Iquiapaza rbali at ufmg.br
Thu May 21 03:10:02 CEST 2009


See "The Hausman test statistic can be negative even asymptotically" 
 Schreiber, S. 2008 Jahrbucher fur Nationalokonomie und Statistik 228 (4), pp. 394-405 

http://econ.schreiberlin.de/papers/schreiber_hausmantest_aug2008.pdf



From: Steven Archambault 
Sent: Wednesday, May 20, 2009 5:18 PM
To: Robert Iquiapaza ; r-sig-finance at stat.math.ethz.ch 
Subject: Re: [R-SIG-Finance] R: [Fwd: R-SIG-Finance Digest, Vol 60, Issue 18]


Thanks Robert. I have been playing around with sigmamore sigmaless. I cannot seem to duplicate the canned results when I do it by hand. Any ideas?

###STATA 9.2####

quietly xtreg lfdi_2000 lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, fe;

. estimates store FIX, title(The FE);

. matrix bfe=e(b);

. matrix vfe=e(rmse);

. quietly xtreg lfdi_2000 lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, re sa;

.  estimates store RAND, title(The RE);

. matrix bre=e(b);

. matrix vre=e(rmse);

. matrix bdif=bfe-bre;

. matrix bdifp=bdif';

. matrix dv=vre-vfe;

. matrix dvi=inv(dv);

. matrix chi1=bdif*dvi;

. matrix chisq=chi1*bdifp;

. matrix list chisq;

symmetric chisq[1,1]
           y1
y1  11.105892

. hausman FIX RAND, sigmamore;

                 ---- Coefficients ----
             |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
             |      FIX          RAND        Difference          S.E.
-------------+----------------------------------------------------------------
    lagdlfdi |    .1564758     .1632387       -.0067629        .0014297
laglnst~2000 |     .762135     .8314432       -.0693082        .0151471
 lagtradegdp |    .0178568     .0119453        .0059115        .0015669
    lagdlgdp |    .2601478      .255801        .0043468        .0067502
------------------------------------------------------------------------------
                           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(4) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                          =       31.32
                Prob>chi2 =      0.0000











On Wed, May 20, 2009 at 11:22 AM, Robert Iquiapaza <rbali at ufmg.br> wrote:

  Stev,

  You will get the same Chi-sq for Hausman test if you use Swamy-Arora's transformation for RE in stata. To avoid the variance not positive definite maybe you should use options sigmamore or sigmaless  in Stata (see http://www.stata.com/help.cgi?hausman), the results don't change. 
  I wonder why plm doesn't alert the variance not being positive definite.

  Robert

   # Stata 10.1
  xtreg lfdi_2000 lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, re sa

  estimates store RANDsa, title(The REsa)

  hausman FIX RANDsa

   ---- Coefficients ----
   (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))

   FIX         RANDsa       Difference          S.E.
   
  lagdlfdi .1564759     .1632388       -.0067629               .
  laglnst~2000 .762135     .8314432       -.0693082        .0149396
  lagtradegdp .0178568     .0119453        .0059115        .0015449
  lagdlgdp .2601477     .2558009        .0043468        .0051777 

   
   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(4) = (b-B)'[(V_b-V_B)^(-1)](b-B)

   =       23.70 

   Prob>chi2 =      0.0001
   (V_b-V_B is not positive definite)



  From: Steven Archambault 
  Sent: Tuesday, May 19, 2009 4:16 PM
  To: Robert Iquiapaza 
  Cc: r-sig-finance at stat.math.ethz.ch 
  Subject: Re: [R-SIG-Finance] R: [Fwd: R-SIG-Finance Digest, Vol 60, Issue 18]


  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.

  Regards,
  Steve




  On Tue, May 19, 2009 at 12:19 PM, Robert Iquiapaza <rbali at ufmg.br> wrote:

    Stev,

    The data you provided is not complete, lagdlfdi and laglnstock2000 are not in the csv file

    Robert


    From: Steven Archambault 
    Sent: Monday, May 18, 2009 5:06 PM
    To: Millo Giovanni 
    Cc: r-sig-finance at stat.math.ethz.ch ; Yves Croissant ; Christian Kleiber 
    Subject: Re: [R-SIG-Finance] R: [Fwd: R-SIG-Finance Digest, Vol 60, Issue 18]


    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.

    Thanks, hope I am not wasting too much of your time here.

    -Steve

    ###R-Output###
    > library("plm")
    > 
    > fdi <- read.csv("C:/data/mydata.csv", na.strings=".")
    > fdiplm<-plm.data(fdi, index = c("id_code_id", "year"))
    series    are constants and have been removed
    > 
    > fdi_test<-(lfdi_2000~ lagdlfdi+ laglnstock2000+ lagtradegdp +lagdlgdp)
    > 
    > fdi_test_fe <- plm(fdi_test, data=fdiplm, model="within")
    > fdi_test_re <- plm(fdi_test, data=fdiplm, model="random")
    > 
    > summary (fdi_test_fe)
    Oneway (individual) effect Within Model

    Call:
    plm(formula = fdi_test, data = fdiplm, model = "within")

    Unbalanced Panel: n=149, T=3-27, N=2697

    Residuals :
       Min. 1st Qu.  Median 3rd Qu.    Max. 
    -8.2100 -0.4760  0.0452  0.5670  4.8700 

    Coefficients :
                    Estimate Std. Error t-value  Pr(>|t|)    
    lagdlfdi       0.1564759  0.0180645  8.6621 < 2.2e-16 ***
    laglnstock2000 0.7621350  0.0246798 30.8809 < 2.2e-16 ***
    lagtradegdp    0.0178568  0.0025859  6.9055 5.003e-12 ***
    lagdlgdp       0.2601477  0.0427744  6.0818 1.188e-09 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

    Total Sum of Squares:    4606.7
    Residual Sum of Squares: 2938
    F-statistic: 361.237 on 4 and 2544 DF, p-value: < 2.22e-16
    > summary (fdi_test_re)
    Oneway (individual) effect Random Effect Model 
       (Swamy-Arora's transformation)

    Call:
    plm(formula = fdi_test, data = fdiplm, model = "random")

    Unbalanced Panel: n=149, T=3-27, N=2697

    Effects:
                      var std.dev  share
    idiosyncratic 1.15487 1.07465 0.6617
    individual    0.59044 0.76840 0.3383
    theta  : 
       Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
     0.3718  0.6700  0.7081  0.6955  0.7355  0.7401 

    Residuals :
        Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
    -9.15000 -0.47900  0.07270 -0.00713  0.59800  3.95000 

    Coefficients :
                     Estimate Std. Error  t-value  Pr(>|t|)    
    (Intercept)    16.7744214  0.1552868 108.0222 < 2.2e-16 ***
    lagdlfdi        0.1632388  0.0181005   9.0185 < 2.2e-16 ***
    laglnstock2000  0.8314432  0.0196444  42.3247 < 2.2e-16 ***
    lagtradegdp     0.0119453  0.0020737   5.7605 8.386e-09 ***
    lagdlgdp        0.2558009  0.0424599   6.0245 1.696e-09 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

    Total Sum of Squares:    9522.3
    Residual Sum of Squares: 3140.8
    F-statistic: 1367.42 on 4 and 2692 DF, p-value: < 2.22e-16
    > 
    > phtest(fdi_test_re, fdi_test_fe)

            Hausman Test

    data:  fdi_test 
    chisq = 23.7021, df = 4, p-value = 9.164e-05
    alternative hypothesis: one model is inconsistent 


    ###end R output###

    ###Stata 9.2 Output--canned###
    xtreg lfdi_2000 lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, fe;

    Fixed-effects (within) regression               Number of obs      =      2697
    Group variable (i): id_code_id                  Number of groups   =       149

    R-sq:  within  = 0.3622                         Obs per group: min =         3
           between = 0.8234                                        avg =      18.1
           overall = 0.6998                                        max =        27

                                                    F(4,2544)          =    361.24
    corr(u_i, Xb)  = 0.3536                         Prob > F           =    0.0000

    ------------------------------------------------------------------------------
       lfdi_2000 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        lagdlfdi |   .1564758   .0180645     8.66   0.000     .1210532    .1918985
    laglnst~2000 |    .762135   .0246798    30.88   0.000     .7137404    .8105295
     lagtradegdp |   .0178568   .0025859     6.91   0.000     .0127861    .0229274
        lagdlgdp |   .2601478   .0427744     6.08   0.000     .1762716    .3440241
           _cons |   17.01131   .1701713    99.97   0.000     16.67762      17.345
    -------------+----------------------------------------------------------------
         sigma_u |  .93048942
         sigma_e |  1.0746505
             rho |  .42847396   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0:     F(148, 2544) =    10.73           Prob > F = 0.0000

    . estimates store FIX, title(The FE) ;

    . xtreg lfdi_2000 lagdlfdi laglnstock2000 lagtradegdp lagdlgdp, re;

    Random-effects GLS regression                   Number of obs      =      2697
    Group variable (i): id_code_id                  Number of groups   =       149

    R-sq:  within  = 0.3606                         Obs per group: min =         3
           between = 0.8402                                        avg =      18.1
           overall = 0.7128                                        max =        27

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

    ------------------------------------------------------------------------------
       lfdi_2000 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        lagdlfdi |   .1631662   .0180937     9.02   0.000     .1277032    .1986291
    laglnst~2000 |    .830845   .0196843    42.21   0.000     .7922645    .8694255
     lagtradegdp |    .011992   .0020779     5.77   0.000     .0079195    .0160645
        lagdlgdp |   .2558113   .0424486     6.03   0.000     .1726136    .3390091
           _cons |   16.77702   .1556693   107.77   0.000     16.47191    17.08212
    -------------+----------------------------------------------------------------
         sigma_u |  .77431228
         sigma_e |  1.0746505
             rho |  .34173973   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------

    .  estimates store RAND, title(The RE) ;

    . hausman FIX RAND;

                     ---- Coefficients ----
                 |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
                 |      FIX          RAND        Difference          S.E.
    -------------+----------------------------------------------------------------
        lagdlfdi |    .1564758     .1631662       -.0066903               .
    laglnst~2000 |     .762135      .830845         -.06871         .014887
     lagtradegdp |    .0178568      .011992        .0058648        .0015393
        lagdlgdp |    .2601478     .2558113        .0043365        .0052695
    ------------------------------------------------------------------------------
                               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(4) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                              =       22.94
                    Prob>chi2 =      0.0001
                    (V_b-V_B is not positive definite)
    ###End Stata 9.2####

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20090520/15a64240/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 43 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20090520/15a64240/attachment.gif>


More information about the R-SIG-Finance mailing list