Announcement

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

  • Estimating ARDL with Structural Break


    Hi....
    My data is stored in a panel data format. I want to estimate the ARDL with a structural break. The break dates are identified using the Bai-Perron test. Suppose I have data for 3 countries (identified by "ID" variable). The break dates are 2006 2001 2004.
    The ARDL command with ONE structural break is:

    set more off
    foreach i of numlist 1/3 {
    forvalues j = 2006 2001 2004{
    gen trend=_n
    gen DU=0
    replace DU=1 if year>`j'
    gen DTB=0
    replace DTB= DU*trend if year>`j'

    ardl x y, exo(DU DTB) maxcombs() if id==`i'
    ardl x y, exo(DU DTB) ec maxcombs()
    estat btest, n(30)
    }
    }
    *
    When I run the above command, it is not running successfully. The dataex is the following:

    clear all
    input int id year x y
    1 1993 1.3 16.32229
    1 1994 1.19 16.37688
    1 1995 0.87 16.43435
    1 1996 0.97 16.49549
    1 1997 1.04 16.48168
    1 1998 1.04 16.59641
    1 1999 1.01 16.64122
    1 2000 1.05 16.7197
    1 2001 1 16.76099
    1 2002 0.98 16.78788
    1 2003 0.95 16.87725
    1 2004 0.84 16.95561
    1 2005 0.83 17.00773
    1 2006 0.82 17.11077
    1 2007 0.92 17.23401
    1 2008 0.96 17.25514
    1 2009 0.98 17.32504
    1 2010 1.03 17.39092
    1 2011 1.11 17.45152
    1 2012 1.01 17.45475
    1 2013 1.04 17.52202
    1 2014 0.7 17.61002
    1 2015 0.6 17.71079
    1 2016 0.67 17.81573
    1 2017 0.58 17.92209
    2 1993 1.57 15.89891
    2 1994 1.53 16.00251
    2 1995 1.08 15.85265
    2 1996 0.95 16.06596
    2 1997 0.95 16.02667
    2 1998 0.95 16.09982
    2 1999 1.42 16.13595
    2 2000 1.16 16.28473
    2 2001 0.85 16.23624
    2 2002 0.81 16.34799
    2 2003 0.76 16.29516
    2 2004 0.64 16.41004
    2 2005 0.91 16.39299
    2 2006 0.83 16.54298
    2 2007 0.86 16.59703
    2 2008 0.71 16.73281
    2 2009 0.71 16.78492
    2 2010 0.61 16.92499
    2 2011 0.61 17.0229
    2 2012 0.54 17.06142
    2 2013 0.55 17.11005
    2 2014 0.85 17.14586
    2 2015 0.84 17.20201
    2 2016 0.98 17.29607
    2 2017 1.16 17.4032
    3 1993 1.42 13.74485
    3 1994 1.26 13.79311
    3 1995 1.2 13.86607
    3 1996 1.19 14.00822
    3 1997 1.09 14.0362
    3 1998 1.1 14.23988
    3 1999 1.09 14.26074
    3 2000 1.08 14.22263
    3 2001 1.08 14.26661
    3 2002 1.01 14.33512
    3 2003 0.99 14.40737
    3 2004 0.89 14.50444
    3 2005 0.87 14.57711
    3 2006 0.82 14.67261
    3 2007 0.76 14.72656
    3 2008 0.87 14.82205
    3 2009 0.94 14.91921
    3 2010 0.98 15.07526
    3 2011 0.87 15.25929
    3 2012 1.06 15.09228
    3 2013 1.21 14.96508
    3 2014 1 15.20471
    3 2015 0.96 15.34354
    3 2016 0.95 15.46122
    3 2017 1.07 15.58947
    end



    Any help will be much appreciated.
    Last edited by Santosh Dash; 13 Nov 2019, 04:11.

  • #2
    Your forvalues-loop specification is invalid. Try to replace it with
    Code:
    foreach j of numlist 2006 2001 2004 {
    https://www.kripfganz.de/stata/

    Comment


    • #3

      Thank you Sebastian Kripfganz. I corrected the code. But i now face two problems.
      1. foreach code is not generating break dummies for each country according to each country's break date. It is creating the break dummies for the year 2006 only.
      2. When i ran the following code, it is telling the following:
      "sample may not include multiple panels"

      set more off
      foreach i of numlist 1/3 {
      foreach j of numlist 2006 2001 2004{
      tsset id year, yearly
      egen trend=group(year)
      gen DU=0
      replace DU=1 if year>`j'
      gen DTB=0
      replace DTB= DU*trend if year>`j'
      ardl lrphe_def lpcgsdp, exo(DU DTB) maxcombs(), if id==`i'
      ardl lrphe_def lpcgsdp, exo(DU DTB) ec maxcombs()
      estat btest, n(25)
      }
      }
      *

      Any help will be much appreciated.

      Comment


      • #4
        Hi...
        The following code works. But I am not able to solve TWO problems:
        1. The following code does not create a break date for each country. It just takes the lowest break date as common for all countries.
        2. How to modify the code when a country does not have a break date

        set more off
        egen trend=group(year)
        gen DU=0
        gen DTB=0

        forvalues i = 1/3 {
        foreach j of numlist 2001 2004 2006 {
        xtset id year, yearly
        replace DU=1 if id==`i' & year>`j'
        replace DTB= DU*trend if id==`i' & year>`j'
        ardl lrphe_def lpcgsdp, exo(DU DTB) maxcombs(), if id==`i'
        ardl lrphe_def lpcgsdp, exo(DU DTB) ec maxcombs(), if id==`i'
        estat btest, n(25)
        outreg2 using "ARDL_lrphe", excel dec(2) br adjr2
        }
        }
        *

        Kindly help.
        Thank you.

        Comment


        • #5
          Hi...
          The corrected code is given below:
          The following code works. But I am not able to solve TWO problems:
          1. The following code does not create a break date for each country. It just takes the lowest break date as common for all countries.
          2. How to modify the code when a country does not have a break date

          set more off
          egen trend=group(year)
          gen DU=0
          gen DTB=0

          forvalues i = 1/3 {
          foreach j of numlist 2001 2004 2006 {
          xtset id year, yearly
          replace DU=1 if id==`i' & year>`j'
          replace DTB= DU*trend if id==`i' & year>`j'
          ardl x y, exo(DU DTB) maxcombs(), if id==`i'
          ardl x y, exo(DU DTB) ec maxcombs(), if id==`i'
          estat btest, n(25)
          outreg2 using "ARDL_lrphe", excel dec(2) br adjr2
          }
          }
          *

          Kindly help.
          Thank you.

          Comment


          • #6
            Originally posted by Santosh Dash View Post
            The break dates are identified using the Bai-Perron test.
            What command have you used to run the Bai-Perron test?

            Comment


            • #7
              Hello Nihar,

              Apologies for the delayed response.
              I utilized an ado file for the Bai-Perron test. However, a new package called "xtbreak," developed by JanDitzen, has recently been introduced that specializes in testing and estimating structural breaks in both time series and panel data.

              Please see the following links:
              https://janditzen.github.io/xtbreak/
              https://sites.google.com/site/jandge...ode?authuser=0

              All the best!

              Comment

              Working...
              X