Page **1** of **1**

### Newey - West covariance formula

Posted: **Fri Jan 11, 2013 9:06 am**

by **JoaoPereira**

Hello

I've been trying to get to the results of Newey West estimator with a formula but I didn´t succeed so far.I had a look in the manual (guide II) but it is confusing.

The exercise I' m dealing with is as follows

Lag specification - none

Kernell - Bartlett

Bandwith - Newey fixed

Truncate integer - Not selected

Can you please tell me witch formula is under the calculations in Eviews?

Is there any kind of document that can help?

Tks for your time

João Pereira

### Re: Newey - West covariance formula

Posted: **Fri Jan 11, 2013 9:50 am**

by **EViews Gareth**

In what context are you calculating a Newey-West covariance?

### Re: Newey - West covariance formula

Posted: **Sat Jan 12, 2013 6:54 pm**

by **JoaoPereira**

I´m just trying to see witch is the correct formula behind the calculation because the formulas I got didn't match.

So I started with a very simple case with only 4 obs ( consumption(cons) depending on salary(sal) )

cons sal

100 500

150 600

200 600

180 500

The outputs are OLS = cons c sal

β1=-35 β2=0,35

var(β)= 67862,5 -122,375 covariance and variance matrix

-122,375 0,2225

Accepting the default options (that are in my first post) ,the Newey West estimator according to Eviews is 35.412,50 -56,6250

-56,6250 0,091250

And mty goal is to check those values with the formula.

Of course I´m doing simething wrong,perhaps the lagged errors(u) are wrongly considered (see bellow)

cons n sal u4 SST u3 u 2 u1

100 1 500 -40 3306,25 0 0 0

150 1 600 -25 56,25 -40 0 0

200 1 600 25 1806,25 -25 - 40 0

180 1 500 40 506,25 25 -25 -40

In terms of bandwith Eviews tells that it is 2, but considering int[4*(4/100)^(2/9)] I get 1

Next step I made diagonal matrix with the product of errors in all combinations [(u4u4) (u4u3) (u4u2) (u4u1) (u3u2) (u3u1) (u2u1) ]

and four X lagged matrix like that

X4 X3 X2 X1

1 500 0 0 0 0 0 0

1 600 1 600 0 0 0 0

1 600 1 600 1 600 0 0

1 500 1 500 1 500 1 500

And I made the product of X's with uu's based on the formula and considering the weight 1- j(b+1) where b is bandwith ( I considered 1 (?)) and added to (XX')uu

Finally ((XX')^-1 *T*Result* (XX')^-1 should give the new covariance matrix (NW)

Sorry this is a little bit tedious and it was easier for me to send you the excel sheet with the calculations but I don´t know if it's possible .If so I'll very pleased to send it. Anyway I hope to have given an idea about my problem. As you know we have a better understanding about whatwe are doing if we understand the rational behind of calculation instead of only clicking some buttons.

Thks for your time

João Pereira

### Re: Newey - West covariance formula

Posted: **Sat Jan 12, 2013 7:01 pm**

by **JoaoPereira**

Hi

I´ve just send you a post and I notice that it's very badly formatted.The problem is that I don´t know how to do it.

I appologize for that

Tks

Joao Pereira

### Re: Newey - West covariance formula

Posted: **Sat Jan 12, 2013 8:54 pm**

by **EViews Gareth**

Which version of EViews are you using?

### Re: Newey - West covariance formula

Posted: **Sun Jan 13, 2013 3:01 pm**

by **JoaoPereira**

I'm using Eviews 7

Can I send my calculations in Excel to Help?

João Pereira

### Re: Newey - West covariance formula

Posted: **Sun Jan 13, 2013 4:04 pm**

by **JoaoPereira**

Hi

Just to help I attached an excel sheet with the example I've been trying to work out

Regards

João Pereira

### Re: Newey - West covariance formula

Posted: **Mon Jan 14, 2013 9:33 am**

by **EViews Gareth**

I'm not sure calculating NW standard errors in Excel is a good idea - you really need a proper matrix language, I would have thought. I couldn't make much sense of your Excel spreadsheet. However, I will note that Appendix E, of User Guide II does a pretty good job of describing all the issues involved with HAC estimation. With the exception of defining what the Newey West Fixed bandwidth estimator is, which for the Bartlett kernel is m=floor(4*(T/100)^2/9), where m is described in the first paragraph of page 779 of the PDF version of User Guide II.

### Re: Newey - West covariance formula

Posted: **Mon Jan 14, 2013 3:44 pm**

by **EViews Glenn**

One comment. I haven't looked carefully at the computations, but I will note that you're going to need to compute the long-run variance of Xi*ui so you're going to want the moments of that. My quick glance suggests that you are computing (sum X_t X_{t-j}' * sum u_t u_{t-j}') to feed into the kernel which isn't the same as sum X_t X_{t-j}' u_t u_{t-j}.

But it may be that I'm not understanding the steps that you are taking.

### Newey - West covariance formula for KPSS

Posted: **Sat Dec 07, 2013 2:34 am**

by **alunde**

Dear Gareth

Wrote at some time that " which for the Bartlett kernel is m=floor(4*(T/100)^2/9), where m is described in the first paragraph of page 779 of the PDF version of User Guide II".

I can get that to match the output attached. Here T is 59 and the auto bandwidth is 6, but floor(4*(59/100)^2/9) = 4.

I'm aware that one gets 4, when runnning regression, do you mind explaining how you select it for the KPSS test. I look

through the manuals ... couldn't find it?

Kind regards, Asger Lunde

### Re: Newey - West covariance formula

Posted: **Sat Dec 07, 2013 6:07 pm**

by **EViews Glenn**

Note that the formula you quote for the bandwidth is for the fixed Newey-West, not the automatic selection method as used in your computation and as described in some detail in the Appendix on long-run variance computation.