Long run variances

Econometrics questions and discussions
Anna
Posts: 21
Joined: Fri Sep 18, 2009 12:17 pm

Long run variances

Unread post by Anna »

Hey Tom,

I am trying to compute the quadratic spectral density estimator to get the long run variance of a certain process. In one of the procedures (I think it was KPSS), you used mcov for this. My problem is that my cognitive abilities are strongly limited so that I don't get what I have to do (and I am not very familiar with the spectral stuff...).

In that procedure, you wrote something like:

mcov(lwindow=name) start end resids
# constant

mcov generates %cmom and you seemingly used %cmom(1,1) as the long run variance estimator.

Could you please make some thinks clear for me:
You only used a constant. Seemingly, this does not have to be altered if the deterministic components of the regression that formed the resids include more than a constant, for instance a trend. Is this correct? Is there any case where more than just a constant has to be taken?

You used cmom(1,1) which is quite natural since its dimension is 1x1. However, assume the answer to my first question was negative and I have to include a trend if resids were created in a regression where a trend was used. cmon would be 2x2, then. The long run variance on the trend would be cmom(2,2), then?

Sorry for these stupid questions. Your help is, again, highly appreciated!

Best wishes
Anna
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Long run variances

Unread post by TomDoan »

If you're just doing the long run variance for a single time series, then you use only the constant. The other variables are used when you need to long run variance of a vector process like X(t)u(t).

The long run variance estimate actually is (1.0/%nobs) %cmom(1,1). However, in most applications, all the factors of T net out and you end up using just the sum (%cmom(1,1)).
Anna
Posts: 21
Joined: Fri Sep 18, 2009 12:17 pm

Re: Long run variances

Unread post by Anna »

Ok, thank you very much Tom! You are very helpful, thanks a lot.

I just wondered: If I am trying to use the long run variance to conduct a simple hypothesis test, like a simple t-test, is there any difference between using the mcov function to get the long run variance and using the robustregression-option in linreg (with the same window-option) and looking at the normal t-statistic there? I tried this and I get different numerical values for both procedures. Is this what I should expect or did I do some mistake in the coding?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Long run variances

Unread post by TomDoan »

You'll have to show me what you did. They should be similar, but there can be slight differences due to 1/T vs 1/(T-k) scaling for instance.
Anna
Posts: 21
Joined: Fri Sep 18, 2009 12:17 pm

Re: Long run variances

Unread post by Anna »

I did the following:

Code: Select all

linreg series start end res
# constant trend s2 s3 s4
comp b = %beta(2)

mcov(lwindows=quadratic) start end res
# constant
comp omega = 1.0/%nobs* %cmom(1,1)
statistics trend start end
comp tlr = b/sqrt(omega(1,1)/(%nobs*%variance))

linreg(robusterrors, lwindow=quadratic) series start end res
# constant trend s2 s3 s4
comp tlr2 = %tstats(2)

disp tlr tlr2
I probably did some stupid mistake in the coding above, because the results are very different. Do you see it?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Long run variances

Unread post by TomDoan »

Those won't be the same. The calculation done by the ROBUSTERRORS option in LINREG allows for a more general form of autocorrelation, as it computes the long-run variance of the full vector X(t)u(t), where X(t) is the vector of regressors at t. What you're doing would only be correct if
  1. u is independent of X, and
  2. X is serially independent
The CONSTANT and TREND are likely to be fine on both counts (assuming no tendency for the variance to increase over time). You'll have to judge whether the assumptions are reasonable for the other regressors. Note, however, that even if you had just the two deterministic variables, the results wouldn't be identical because LINREG with ROBUSTERRORS will still be computing sample values for the long-run variance of TREND x u.
Anna
Posts: 21
Joined: Fri Sep 18, 2009 12:17 pm

Re: Long run variances

Unread post by Anna »

Ok, thanks a lot, Tom. I am much indebted.

To make thinks clear for me:
Are you saying that for hypothesis-testing in such a framework, I should use the robusterrors version or are you saying the opposite that I should use the mcov version? Moreover, I also need to get "omega", i.e. the long run error variance. Can I assume that %seesq after a linreg(robusterrors) command gives me that omega or does it give me the OLS estimate for sigma (e'e/(T-k)) again? Or should I use mcov with just the constant as described above?

Again, thanks a lot for your patience and your help.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Long run variances

Unread post by TomDoan »

Use ROBUSTERRORS. The conditions under which what you tried would be correct are fairly rare (pretty much met only with deterministic regressors). And if what you did was correct, so would be the calculation done by ROBUSTERRORS, that is, both would be justifiable, just different.
Anna
Posts: 21
Joined: Fri Sep 18, 2009 12:17 pm

Re: Long run variances

Unread post by Anna »

Ok, thank you very much Tom. I am very much indebted to you. Thanks for your help!
Could you, however, probably loose one or two words on the long run residual variance?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Long run variances

Unread post by TomDoan »

%SEESQ is the standard regression estimator whether or not you use ROBUSTERRORS. The long-run variance is computed with

Code: Select all

mcov(options) / %resids
# constant
compute lrvar=%cmom(1,1)/%nobs
LeCaptain
Posts: 7
Joined: Fri Sep 07, 2012 3:46 am

Re: Long run variances

Unread post by LeCaptain »

Dear Tom,

sorry to bother you, but I have read this topic a few times now and I am still a little bit confused...

Let's assume I want to estimate the long-run (HAC robust) covariance matrix of the residuals from a VAR model (I am only interested in the residuals' (co)variance, not in the standard errors of the VAR coefficients). Could I do this as follows?

Code: Select all

mcov(lwindow=neweywest,lags=nwlags) * * resids
# constant
compute sigmahac = %cmom/%nobs
where resids is the vector of residuals from the estimated VAR model.

Kind regards
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Long run variances

Unread post by TomDoan »

Assuming RESIDS is the VECT[SERIES] of residuals from the VAR, that's correct. Either of these will work:

mcov(lwindow=neweywest,lags=nwlags) / resids
# constant

mcov(lwindow=neweywest,lags=nwlags)
# resids
LeCaptain
Posts: 7
Joined: Fri Sep 07, 2012 3:46 am

Re: Long run variances

Unread post by LeCaptain »

Thanks for the swift reply. Just a short follow-up: Is there any procedure in RATS to do automatic bandwidth selection?
Post Reply