Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: re: Troubleshooting 'not sorted' and 'not regularly spaced' errors


From   "Thomas Jacobs" <thomasjacobs@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: re: Troubleshooting 'not sorted' and 'not regularly spaced' errors
Date   Mon, 13 Oct 2008 13:44:03 -0500

Mike,

Thanks once again as that was very helpful.  I missed the robust small
command in the help file for ivreg2.  As all my work is with trading
data I always create a trading day date index similar to a business
day counter but including holidays as in your number 4.  The only gaps
(or missing information) I have relate to missing values of the
primary index I am regressing on as opposed to my firm specific
information.  Thus there are no gaps in the date index as I have
defined it.

Tom

On Mon, Oct 13, 2008 at 1:19 PM, Michael Hanson <mshanson@mac.com> wrote:
> Tom:
>
> Kit is, of course, correct that one can use -ivreg2- (from SSC; runs in
> Stata 9) or -ivregress- (Stata 10 only) to mimic the -newey- and -newey2-
> estimators, as all allow you to get Newey-West style heteroskedasticity and
> autocorrelation consistent (HAC) standard errors.  There are a few
> additional points worth noting in order to make sure these various Stata
> commands are delivering the HAC estimator that you have in mind.  And when
> you have time series with "gaps" and use lagged regressors, you may need to
> pay close attention to whether you -tsset- or -xtset- to a Stata date
> variable (with gaps) or a linear time trend (without gaps).
>
> 1. If m is the number of lags you would specify in -newey- or -newey2-, then
> use m for the -ivregress, vce(hac nw m)- command, but n=m+1 for the -ivreg2,
> bw(n)- command.  As you point out, it takes some effort or experimentation
> to extract this information from the -ivreg2- help file.
>
> 2. To match the HAC SE estimates of -newey- or -newey2-, you will need to
> add the options -robust small- to an -ivreg2- estimation and the option
> -small- to an -ivregress- estimation.
>
> 3. If you -tsset- (or -xtset-) your data to a Stata date variable with gaps,
> you may not get the same HAC SE estimates from -newey2, force- as from
> -ivreg2- or -ivregress- when lagged regressors are included.  You can modify
> my earlier example program to demonstrate that fact (left as an exercise).
>  This problem may or may not occur in your dataset.
>
> 4. If you instead -tsset- (or -xtset-) to a sequential linear time trend
> (-gen t = _n-), then you will get the same results for all three commands --
> but you will have, in effect, told Stata that there are no gaps in your
> data.  Indeed, you likely will have included a larger set of observations in
> your regressions, so both the coefficient estimates and the SE estimates are
> likely to differ from those in (3).
>
> Which of (3) or (4) above is preferable depends on how you think the "gaps"
> should be handled.  Stata constructs lags by strictly using the prior
> observation at the frequency specified.  For example, if you have business
> daily data (as in the example program in my prior message) and -tsset- to a
> daily Stata date variable, Stata will not construct any lags for a Monday,
> as the prior daily observation (Sunday) is missing in that financial data
> set.  However, you may well want Stata to treat Friday as the prior
> observation -- which will require you to pay close attention to the
> construction of your data and then to -tsset- to a time trend.  (Other
> statistical packages that specialize in time series estimation, such as RATS
> and (IIRC) EViews, have an explicit "business daily" frequency as this
> problem arises regularly in applications with financial data.  One still has
> to think about how to handle holidays in that case.)  If instead you have
> data with regular gaps -- such as every two or every five years of annual
> data -- you can use the -delta- option of -tsset- or -xtset- to have Stata
> treat the prior two- or five-year observation as the lagged value.
>
> HTH,
> Mike
>
> On Oct 13, 2008, at 12:27 PM, Thomas Jacobs wrote:
>
>> Kit,
>>
>> Thanks for introducing me to ivregress and ivreg2 for use in newey
>> west estimation.  I was unfamiliar with both commands.  I confirmed
>> they run just as you indicated with both the examples Michael Hanson
>> provided as well as the questions from my original post.  No problems
>> with either time series commands or gaps.
>>
>> Is the translation between newey west lags and bartlett kernel
>> bandwidth simply bandwidth = lags +1 as it appears?  I was unsure from
>> the ivreg2 help file.  Thanks again.
>>
>> Tom
>>
>> On Sat, Oct 11, 2008 at 3:07 PM, Kit Baum <baum@bc.edu> wrote:
>>>
>>> < >
>>> Re Michael Hanson's comments on David Roodman's -newey2-:  David has on
>>> more
>>> than one occasion suggested that those wanting to calculate Newey-West
>>> standard errors in an OLS regression should just use -ivreg2- of Baum,
>>> Schaffer, Stillman. Despite its name it is happy to estimate OLS models
>>> without any instruments, and it can estimate Newey-West standard errors
>>> as
>>> well as a variety of other HAC models. E.g.
>>>
>>> ivreg2 irx t, robust bw(9)
>>>
>>> Notice that it reports the presence of gaps but does not choke on them.
>>> -ivreg2- requires Stata 9.2.
>>>
>>> In fact, contradictory to its syntax diagram, -ivregress- can do this as
>>> well. The -ivregress- syntax states that the (varlist2 = varlist_iv)
>>>  component is mandatory, but the program does not enforce this:
>>>
>>> ivregress 2sls irx t, vce(hac bartlett 8)
>>>
>>> works, making no mention of gaps.  -ivregress- requires Stata 10.
>>>
>>> Kit Baum, Boston College Economics and DIW Berlin
>>> http://ideas.repec.org/e/pba1.html
>>> An Introduction to Modern Econometrics Using Stata:
>>> http://www.stata-press.com/books/imeus.html
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>



-- 
Thomas Jacobs
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index