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-
[/CODE]
Error shown-
Would appreciate your help a lot! Thank you in advance.
Best,
Zaeem-Al Ehsan
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:
///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
}
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

Comment