Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newey West Wald Test

    Hello everyone,

    I am running two separate time-series regressions using Newey.

    y1= a1 + b1 x1 + e
    y2= a2 + b2 x1+ e

    I would like to test whether b1=b2 . How can I run a Wald test to do this? I checked many other posts but the only solution offered there was to calculate

    z= (b1-b2) / ((stnd err b1)^2+( stnd err b2)^2))^1/2 by hand but this is not exactly the Wald test. I appreciate your help.

  • #2
    Code:
    webuse idle2, clear
    tsset time
    set seed 2018
    gen idle2= runiformint(60, 120)
    newey usr idle, lag(3)
    newey usr idle2, lag(3)
    rename idle idle1
    reshape long idle, i(time) j(group)
    replace time=_n
    tsset time
    gen cons=1
    newey usr (c.idle c.cons)#i.group, nocons lag(3)
    test _b[1.group#c.idle]= _b[2..group#c.idle]
    Individual and joint regressions

    Code:
    . newey usr idle, lag(3)
    
    Regression with Newey-West standard errors      Number of obs     =         30
    maximum lag: 3                                  F(  1,        28) =      10.90
                                                    Prob > F          =     0.0026
    
    ------------------------------------------------------------------------------
                 |             Newey-West
             usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            idle |  -.2281501   .0690927    -3.30   0.003    -.3696801     -.08662
           _cons |   23.13483   6.327031     3.66   0.001     10.17449    36.09516
    ------------------------------------------------------------------------------
    
    . newey usr idle2, lag(3)
    
    Regression with Newey-West standard errors      Number of obs     =         30
    maximum lag: 3                                  F(  1,        28) =       0.01
                                                    Prob > F          =     0.9285
    
    ------------------------------------------------------------------------------
                 |             Newey-West
             usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           idle2 |  -.0031678    .034996    -0.09   0.929    -.0748539    .0685182
           _cons |   4.106188   3.745698     1.10   0.282    -3.566527     11.7789
    ------------------------------------------------------------------------------
    
    . newey usr (c.idle c.cons)#i.group, nocons lag(3)
    
    Regression with Newey-West standard errors      Number of obs     =         60
    maximum lag: 3                                  F(  4,        56) =      31.59
                                                    Prob > F          =     0.0000
    
    ------------------------------------------------------------------------------
                 |             Newey-West
             usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    group#c.idle |
              1  |  -.2281501    .077743    -2.93   0.005     -.383888   -.0724121
              2  |  -.0031678   .0393758    -0.08   0.936    -.0820471    .0757115
                 |
    group#c.cons |
              1  |   23.13483   7.119611     3.25   0.002     8.872533    37.39712
              2  |   4.106188   3.959958     1.04   0.304     -3.82656    12.03894
    ------------------------------------------------------------------------------
    
    . test _b[1.group#c.idle]= _b[2..group#c.idle]
    
     ( 1)  1b.group#c.idle - 2.group#c.idle = 0
    
           F(  1,    56) =    8.22
                Prob > F =    0.0058
    Last edited by Andrew Musau; 24 Oct 2018, 08:50.

    Comment


    • #3
      Just to add to #2, because we are combining two time-series, you need to appropriately adjust the lag length so that the Newey-West standard errors match. In my example above, the lag length should be set at 7 to match a lag length of 3 in the individual regressions.

      Code:
      . newey usr idle, lag(3)
      
      Regression with Newey-West standard errors      Number of obs     =         30
      maximum lag: 3                                  F(  1,        28) =      10.90
                                                      Prob > F          =     0.0026
      
      ------------------------------------------------------------------------------
                   |             Newey-West
               usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
              idle |  -.2281501   .0690927    -3.30   0.003    -.3696801     -.08662
             _cons |   23.13483   6.327031     3.66   0.001     10.17449    36.09516
      ------------------------------------------------------------------------------
      
      . 
      . newey usr idle2, lag(3)
      
      Regression with Newey-West standard errors      Number of obs     =         30
      maximum lag: 3                                  F(  1,        28) =       0.01
                                                      Prob > F          =     0.9285
      
      ------------------------------------------------------------------------------
                   |             Newey-West
               usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             idle2 |  -.0031678    .034996    -0.09   0.929    -.0748539    .0685182
             _cons |   4.106188   3.745698     1.10   0.282    -3.566527     11.7789
      ------------------------------------------------------------------------------
      
      
      . 
      . newey usr (c.idle c.cons)#i.group, nocons lag(7)
      
      Regression with Newey-West standard errors      Number of obs     =         60
      maximum lag: 7                                  F(  4,        56) =      37.09
                                                      Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
                   |             Newey-West
               usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      group#c.idle |
                1  |  -.2281501   .0690927    -3.30   0.002    -.3665595   -.0897406
                2  |  -.0031678    .034996    -0.09   0.928    -.0732732    .0669376
                   |
      group#c.cons |
                1  |   23.13483   6.327031     3.66   0.001     10.46026    35.80939
                2  |   4.106188   3.745698     1.10   0.278    -3.397347    11.60972
      ------------------------------------------------------------------------------
      
      . 
      . test _b[1.group#c.idle]= _b[2..group#c.idle]
      
       ( 1)  1b.group#c.idle - 2.group#c.idle = 0
      
             F(  1,    56) =   10.49
                  Prob > F =    0.0020

      Comment


      • #4
        Thank you very much for your help. In your example, the dependent variable is the same in both regressions and you run the regression on two different independent variables (idle and idle2). In my question, it is the opposite. I regress y1 and y2 separately on the same independent variable. I wonder if this affects your answer.

        Comment


        • #5
          Not at all, but I guess seeing is believing...

          Code:
          clear
          webuse idle2
          tsset time
          set seed 2018
          gen usr2= runiformint(0,15)
          newey usr idle, lag(3)
          newey usr2 idle, lag(3)
          rename usr usr1
          reshape long usr, i(time) j(group)
          gen cons=1
          replace time=_n
          tsset time
          newey usr (c.idle c.cons)#group, nocons lag(7)
          test 1.group#c.idle= 2.group#c.idle
          Result

          Code:
          . newey usr idle, lag(3)
          
          Regression with Newey-West standard errors      Number of obs     =         30
          maximum lag: 3                                  F(  1,        28) =      10.90
                                                          Prob > F          =     0.0026
          
          ------------------------------------------------------------------------------
                       |             Newey-West
                   usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                  idle |  -.2281501   .0690927    -3.30   0.003    -.3696801     -.08662
                 _cons |   23.13483   6.327031     3.66   0.001     10.17449    36.09516
          ------------------------------------------------------------------------------
          
          . newey usr2 idle, lag(3)
          
          Regression with Newey-West standard errors      Number of obs     =         30
          maximum lag: 3                                  F(  1,        28) =       0.64
                                                          Prob > F          =     0.4308
          
          ------------------------------------------------------------------------------
                       |             Newey-West
                  usr2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                  idle |  -.0579036   .0724355    -0.80   0.431    -.2062811    .0904739
                 _cons |   12.23198   6.166846     1.98   0.057    -.4002351    24.86419
          ------------------------------------------------------------------------------
          
          . 
          . newey usr (c.idle c.cons)#group, nocons lag(7)
          
          Regression with Newey-West standard errors      Number of obs     =         60
          maximum lag: 7                                  F(  4,        56) =      64.66
                                                          Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
                       |             Newey-West
                   usr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          group#c.idle |
                    1  |  -.2281501   .0690927    -3.30   0.002    -.3665595   -.0897406
                    2  |  -.0579036   .0724355    -0.80   0.427    -.2030094    .0872022
                       |
          group#c.cons |
                    1  |   23.13483   6.327031     3.66   0.001     10.46026    35.80939
                    2  |   12.23198   6.166846     1.98   0.052    -.1217007    24.58566
          ------------------------------------------------------------------------------
          
          . 
          . test 1.group#c.idle= 2.group#c.idle
          
           ( 1)  1b.group#c.idle - 2.group#c.idle = 0
          
                 F(  1,    56) =    3.03
                      Prob > F =    0.0875

          Comment


          • #6
            Thank you! I use a lag length of 12 in individual regressions. How do you decide on the lag for the combined regression? Unlike your example, my coefficients and std. errors are different for the individual and combined regressions (lag=25).

            Comment


            • #7
              Without seeing your data, I cannot know what is going on. It could be several things, including improper implementation of the procedure. In addition, this method relies on the set of independent variables being the same across both models, with only the dependent variable being different. Bottom line, you should get the same coefficients irrespective of the number of lags. Double plus one lags works in my example, and I think is a good approximation. Thus if revisiting your implementation does not yield anything fruitful, you can post a sample of your data here using dataex, after verifying that results do not match based on that sample. If you cannot publicly post the data, you can send it to me via email (available at my webpage linked to my Statalist profile). If this is not feasible, I cannot help and maybe you can ask a colleague to read this post and try it out.

              Comment

              Working...
              X