Announcement

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

  • Testing for a known break date in a time series with yearly data

    I have a data set that contains variables for economic growth (called "dgdp") and the change of unemployment rate (called "dUR") for a variety of countries over time in yearly increments from 1991 to 2017. Previously, I tested for a break in time series with an unknown break date successfully using the following code:
    Code:
        regress dUR dgdp if compldata_dgdp_dUR ==1 & country == "Germany", vce(robust)
        tsset ilo_code year
        estat sbsingle
    Now, I would like to perform the test with known break dates, so replacing sbsingle with sbknown, break(possible break date). However, the following code does not work:
    Code:
        regress dUR dgdp if compldata_dgdp_dUR ==1 & country == "Germany", vce(robust)
        tsset ilo_code year
        estat sbknown, break(2007)
    It keeps giving me the following error message:
    . tsset ilo_code year
    panel variable: ilo_code (unbalanced)
    time variable: year, 1991 to 2017
    delta: 1 unit

    . estat sbknown, break(2007)
    no such variables;
    the specified varlist does not identify any testable coefficients
    r(111);
    I suspect that the problem is the date format, but browsing the STATA documentation, I could not find a way to tell STATA that I would like to test for a break in the year 2007. In my data set, year is an integer variable ranging from 1991 to 2017.

    Could you please help? Thank you very much for your time.

  • #2
    Try

    Code:
    tempfile data
    save `data'
    keep if compldata_dgdp_dUR ==1 & country == "Germany"
    tsset year
    regress dUR dgdp
    estat sbknown, break(2007)
    use `data', clear

    Comment


    • #3
      Dear Andrew, yes, that worked very well. Thank you very much.

      Would it make sense to derive a general lesson for working with STATA from this? That it is better to create and work with a temporary sub-data set, rather than trying to directly work on a complete data set that includes multiple panels?

      Comment


      • #4
        #3 Not really. Many tasks require Stata to be able to look at all panels together.

        Comment


        • #5
          Also, note that estat sbknown requires time-series data and not panel data.

          estat sbknown performs a Wald or a likelihood-ratio (LR) test of whether the coefficients in a time-series regression vary over the periods defined by known break dates.
          That is the root of your problem in #1.

          Comment


          • #6
            Thank you very much for the explanations. Yes, in my data set I have time series data for about 100 different countries (or "panels").

            So far, I could only find a way of testing for a break in these time series one country at a time, using estat sbsingle or estat sbknown. I could not find a STATA command that would allow to do this for multiple countries / panels at the same time. Is there a way this can be done in STATA that I might have missed?

            Comment


            • #7
              You can always override the panel settings, although you need to make sure that if there are holes in your panel, these are reflected in your new time variable. Here, I assume that you have a balanced panel.

              Code:
              sort ilo_code year
              gen time=_n
              tsset time
              regress dUR dgdp if compldata_dgdp_dUR ==1 & country == "Germany", vce(robust)
              estat sbknown, break(11)
              where, for example, time=11 corresponds to year=2007 in your data.

              Comment


              • #8
                I could not find a STATA command that would allow to do this for multiple countries / panels at the same time.

                You need a loop over parallel lists (country and break) to do all countries at once. Here is an example using the Grunfeld data set where after a regression command, I test whether there is a break in 1945 based on the pooled method in #7. Note that you will need to change the code if you have holes in your panel.


                Code:
                webuse grunfeld
                sort company year
                gen time2=_n
                tsset time2
                levelsof company, local(cnames)
                levelsof time2 if year==1945, local(breaks)
                local n : word count `cnames'
                forvalues i = 1/`n' {
                local x : word `i' of `cnames'
                local y : word `i' of `breaks'
                regress invest mvalue kstock if company==`x'  
                estat sbknown, break(`y')
                }

                Comment

                Working...
                X