Announcement

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

  • Markov-Switching Model- discontinuous region with missing values encountered

    Hi all,

    I am trying to use the Markov switching dynamic regression on predicted values of district GDP for Bangladesh for 64 districts across 1992-2018. From my master file of 64 districts, I created 64 separate .dta files for each district to perform the Markov regression on each of the districts. However, for a number of the districts, Stata encounters error r(430)- could not calculate numerical derivatives -- discontinuous region with missing values encountered.

    I am attaching a snippet of a district where the Markov regression encounters this problem. I am also showing the code I am running. What am I doing wrong here?

    Data example-

    Code:
    input str16 Dist int Yr double PredictedGDP
    "Chittagong" 1992  73116.08628670633
    "Chittagong" 1993  75196.10103755869
    "Chittagong" 1994  78633.72219248657
    "Chittagong" 1995   75319.5726215966
    "Chittagong" 1996  75722.71015760388
    "Chittagong" 1997   85615.2393593051
    "Chittagong" 1998  88506.45198042238
    "Chittagong" 1999  86874.64511171897
    "Chittagong" 2000  87039.91536322085
    "Chittagong" 2001  93707.27116092443
    "Chittagong" 2002  93373.99459338482
    "Chittagong" 2003 106860.37216786623
    "Chittagong" 2004 100034.18184686825
    "Chittagong" 2005 106905.90442885183
    "Chittagong" 2006 120375.29765753397
    "Chittagong" 2007 122733.94924886379
    "Chittagong" 2008 127388.01149392803
    "Chittagong" 2009 145662.79935964334
    "Chittagong" 2010 153045.87489917077
    "Chittagong" 2011 163366.03945853031
    "Chittagong" 2012 177975.57812602696
    "Chittagong" 2013 191817.29965183546
    "Chittagong" 2014 138472.55849696806
    "Chittagong" 2015 143332.69055244426
    "Chittagong" 2016 162551.01578202768
    "Chittagong" 2017 162201.01574324755
    "Chittagong" 2018 176780.88298414022
    "Chittagong" 2019 199586.84822327754
    "Chittagong" 2020 215344.19238562946
    Code-
    Code:
    ///Markov Switching Dynamic Regression
    
    clear all
    
    /// Importing the data
    import excel "/Users/zaeemehsan/Desktop/EWU Research Assistant work/Night Light-GDP BD/Main Data/NL data_till 2020.xlsx", sheet("markov") firstrow clear
    
    /// Setting working directory
    
    cd "/Users/zaeemehsan/Desktop/EWU Research Assistant work/Night Light-GDP BD/Markov Switch"
    
    /// Declaring panel data
    
    xtset  Zonecode Yr, yearly
    encode Dist, gen(Dist1)
    
    ///Creating 64 separate district files
    
    levelsof Zonecode, local(levels)
    set more off
    foreach 1 of local levels {
    save zone_`1'.dta, replace
    }
    
    set more off
    levelsof Zonecode, local(levels)
    foreach 1 of local levels {
    use zone_`1'.dta, clear
    keep if Zonecode==`1'
    save zone_`1', replace
    }
    
    /// Performing the Markov Switching Dynamic Regression
    set more off
    foreach n of numlist 1/64 {
    use zone_`n'.dta, clear
    mswitch ar PredictedGDP, ar(2) arswitch varswitch switch(,noconstant) constant nolog 
    }
    [/CODE]


    Error shown-

    Code:
    Performing EM optimization:
    
    could not calculate numerical derivatives -- discontinuous region with missing values encountered
    could not calculate numerical derivatives -- discontinuous region with missing values encountered
    r(430);
    
    end of do-file
    
    r(430);

    Would appreciate your help a lot! Thank you in advance.


    Best,
    Zaeem-Al Ehsan

  • #2
    Zaeem:
    the usual recipe in these instances is to start it all over again, adding one predictor at a time and see when Stata starts complaining.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thank you for your prompt response. While I will try and add one predictor at a time, I am confused as to what I should be looking for that points towards inconsistencies within my data. The error that arises says that Stata's maximization procedure failed to converge to a solution, and that it encountered discontinuous regions with missing values.

      However, I do not have any missing values within my data. What should I be looking out for when I am getting this error message? I do not see any discernible difference. I understand how it would be difficult to say accurately without looking at the data itself, but any sort of recommendations will be very helpful.

      Thank you again!

      Best,
      Zaeem

      Comment


      • #4
        Zaeem:
        puzzling indeed.
        My best guess is that EM estimator itself produces missing values.
        On a more practical side, can't you limit the set of your predictors to avoid that nuisance?
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          I guess limiting the set of predictors and doing it individually will be a way I can isolate the districts where I am running into this issue. I wanted to do it all together since that would just be faster.

          Thank you for your help! Your and Nick's answers on other posts have been helping me immensely since I started using Stata. Wishing the best for you both.

          Best,
          Zaeem

          Comment

          Working...
          X