Skip to content
All library documents

Reproducing Markov-Switching VAR and DSGE Results

Article Quant Q&A · Author: MYaseen208

Summary

The document is a request for guidance reproducing results from a study of the Great Recession using Markov-switching vector autoregression and Markov-switching dynamic stochastic general equilibrium models. It identifies an archived R package that can fit an MSVAR and provides example model calls, including choices for lag order, regimes, priors, and iteration settings. The author reports that the fitted MSVAR results do not match the published results and asks about tools for the MSDSGE component.

A long quarterly dataset with four macroeconomic series is included, but the document supplies no diagnostic procedure, replication findings, or implementation advice for MSDSGE. The code and data make the replication context concrete, yet they do not establish why results differ. Reproduction would also depend on matching the paper’s data transformations, sample, priors, model specification, and estimation settings; those details are not resolved in the exchange.

Key ideas

  • Markov-switching VAR models can be estimated with an R package cited in the document.
  • Replication requires matching the original model specification, priors, data, and estimation settings.
  • The author reports a mismatch between their MSVAR output and the published results.
  • The document asks about MSDSGE software but provides no answer or implementation workflow.

Tags

Full text
# 65530


# Markov Switching Vector Autoregressive (MSVAR) and Markov Switching Dynamic Stochastic General Equilibrium (MSDSGE) Models












I want to reproduce the results of Bianchi et al (2017) Escaping the Great Recession using `R` and/or `Python`. Authors in the article used Markov Switching Vector Autoregressive (MSVAR) and Markov Switching Dynamic Stochastic General Equilibrium (MSDSGE) models. I found `MSBVAR` `R` package (archived) which can fit MSVAR model. However, yet not able to find any `R` and/or `Python` library to implement MSDSGE Model. The out of MSVAR model are not matching with the results of article. I would appreciate it if someone leads me to `R` and/or `Python` libraries to reproduce the results of Bianchi et al (2017) Escaping the Great Recession.

```
library(MSBVAR)
fm1 <- msvar(Y = Data1TS, p = 2, h = 2, niterblkopt = 10)
fm1
fm2 <- msbvar(
   Y              = Data1TS
 , p              = 2
 , h              = 2
 , lambda0        = 0.8
 , lambda1        = 0.15
 , lambda3        = 1
 , lambda4        = 0.25
 , lambda5        = 1
 , mu5            = 0
 , mu6            = 0
 , qm             = 12
 , alpha.prior    = c(100, 30)*diag(2) + matrix(12, 2, 2)
 , prior          = 0
 , max.iter       = 30
 , initialize.opt = NULL
 )

fm2
```

Here Data1TS is the data for MSVAR model and Data2TS the data for MSDSGE model.

Data

```
Data1TS <- 
structure(c(-0.00641658440276408, -0.0164288084965151, -0.0210843373493976, 
-0.0382387022016222, -0.0384359400998336, -0.0333504361210877, 
-0.0320715036803366, -0.0336134453781513, -0.025445733079453, 
-0.0218900160170849, -0.0183156760639253, 0.0115667718191378, 
0.0303706245710364, 0.0587434020091946, 0.0462833099579242, 0.0408268733850129, 
0.0132472826086957, -0.00256717439671405, 0.0168367346938775, 
0.0105864560578054, -0.0538653366583541, -0.0380316930775646, 
-0.0227535037098105, -0.00491883915395967, 0.00538951494365508, 
0.0103414313854236, 0.00487725573077549, -0.00433039294306323, 
0.00907065563335466, 0.00713832487309653, 0.00285532994923857, 
0.00373134328358215, -0.0134466769706337, -0.0238689547581904, 
-0.0165120301934266, -0.0202194357366772, -0.00560485754320408, 
0.0145494367959951, -0.0028116213683224, -0.0171402100061766, 
-0.0386740331491711, -0.0398624355166485, -0.00334128878281625, 
-0.0047333543704639, -0.0212297531058342, -0.0222580645161291, 
-0.00495949743759302, 0.00480923372875924, 0.0441106719367589, 
0.0361445783132532, 0.0464197530864199, 0.0307840307840307, 0.0102452654455138, 
0.0152308424559733, -0.0271281571562206, -0.0327459847185406, 
-0.0841942945258291, -0.0872483221476511, -0.0585149975413867, 
-0.0582053354890864, -0.0172111553784861, 0.020117762512267, 
0.0407004259346901, 0.0616250760803407, 0.0414523004556812, 0.0851917930419268, 
0.0787878787878787, 0.0616923718215922, 0.0316515622886515, 0.0660467660330918, 
0.00979991833401367, 0.0630334865397241, -0.0155561317085819, 
-0.00197550375345699, -0.0532015703262488, -0.0571504167217884, 
-0.0467326732673268, -0.0747562296858068, -0.0372469635627529, 
0.0151593677118425, 0.107181785151992, 0.283904109589041, 0.147467407565719, 
0.134734971868522, 0.0898917969111255, 0.0618528855676599, 0.0662997678218248, 
0.0738167252513693, 0.0347013151639994, 0.0312130527311422, 0.037131585054537, 
0.0339497041420116, 0.031614924522928, -0.0173658257700279, -0.0245450698264918, 
-0.0381980485779532, -0.0667777407530823, -0.0676646706586826, 
-0.0569191986201406, -0.0545381900512753, -0.0347940691927513, 
0.00606766364304969, 0.0203217612193057, -0.0143044462987245, 
-0.0521225752038237, -0.0582037129954843, -0.0722200348726027, 
-0.0124416796267495, 0.00444905828266354, 0.0185968284478614, 
0.0581023454157782, 0.0859616078227067, 0.0884866201933887, 0.0576736845880708, 
0.0796302755493547, 0.0565319077848313, 0.0299577518883625, 0.0326411400327374, 
0.028655798957423, 0.0381608808943432, 0.00355536402079344, 0.0430261742560058, 
0.0248427363868685, 0.0266070766950722, 0.018901831723899, 0.0283183632734531, 
0.0397852478064026, 0.0115105952009972, 0.0123013839056894, -0.0166981297316234, 
-0.0125974102068319, -0.0128530805687204, -0.0185826197850245, 
-0.0225792765039015, -0.03121185066414, -0.0300230122910608, 
-0.0461065573770492, -0.0386157959687372, -0.0340152944681697, 
-0.033826503798315, -0.0216441997341942, -0.0237017683012177, 
-0.0275448561897033, -0.0100426705745442, -0.0336605311342704, 
-0.0107469761359921, 0.00348577620533451, 0.00171105490254435, 
0.0162436424695204, 0.0185027345692166, 0.0213644198494057, 0.0167287496634054, 
0.0165515443763847, 0.00350273850464917, 0.00634393406434709, 
-0.0040230944045206, -0.0123736152967919, -0.0231806329892099, 
-0.0174477304278322, -0.0215181740623322, -0.0244854070660522, 
-0.0303436364719194, -0.0384739167324966, -0.0371457711774743, 
-0.0349906520769472, -0.0487476381958239, -0.0539916269669409, 
-0.0658138881079562, -0.0694658582495436, -0.0839509733237203, 
-0.0852069663218804, -0.0837962228217743, -0.0980865224625624, 
-0.10566966559158, -0.110524991379069, -0.106707260474873, -0.115982463132722, 
-0.123361481290374, -0.12687969924812, -0.127246409312851, -0.164004933102569, 
-0.161077721989872, -0.164883045405901, -0.16270337922403, -0.154604833442195, 
-0.144013000933578, -0.0599783861671469, -0.0863492834588294, 
-0.0151835372636263, -0.00176985240098836, 0.00426073600269326, 
0.0201668347236227, 0.028576308993901, 0.0536000544064356, 0.0717518144300556, 
0.0487716561751434, 0.0563304432118046, 0.0458769397329484, 0.0370438338926174, 
0.0351398466281378, 0.0179318889595821, 0.0106906541133094, 0.0255109578921448, 
-0.00232056344909007, -0.00808761179463392, -0.012027073087598, 
-0.0192993463637013, -0.0357491697597187, -0.0214234374879243, 
-0.0201492363478247, -0.00626233748553538, -0.00240710753205834, 
0.0173477490684748, 0.0905341856180283, 0.0665962539607147, 0.108993669152826, 
0.158571671204393, 0.17856558169993, 0.163123139170929, 0.156423672422446, 
0.157226357551429, 0.145182065890513, 0.128071631970578, 0.121861751362717, 
0.111454066535931, 0.119038038573778, 0.108032243053784, 0.101666078135533, 
0.0802002079188154, 0.0743475480596299, 0.0782006180637888, 0.068678103502412, 
0.0402626800171505, 0.0168170422875758, 0.0372995846874356, 0.0165686505389005, 
0.0598052244001091, 0.0748894944125711, 0.0769422286796759, 0.0636566699598973, 
0.0316136195145269, 0.0236950438017773, 0.00954154177493471, 
0.0197264719561723, 0.0300493762229292, 0.0196067332763246, 0.0301090422637191, 
0.00358990988432506, -0.0290751217211298, -0.0203230913427053, 
-0.00711870961690853, 0.0263159395334487, 0.070960134851874, 
0.0884495435456323, 0.0636297735590334, 0.0444413478491788, 0.0480764076837161, 
0.0202269772755432, 0.0246677659880827, 0.00853926054567111, 
-0.00671434535973425, 0.0154997362468077, 0.0295360794716331, 
0.0617903710567305, 0.0728684920236962, 0.0651732290004876, 0.0581056225836036, 
0.0419136277789374, 0.0351285218077813, 0.0373635943032884, 0.0472393292352447, 
0.0504884064796105, 0.060786300690209, 0.0596782529527751, 0.0538268520738328, 
0.0502329271117077, 0.0532314046912319, 0.0549675177494358, 0.0615907790755301, 
0.0813563861820921, 0.0813783128584689, 0.0718988596259749, 0.0588875688139812, 
0.0441272611178043, 0.0288522147809669, 0.025645430828753, 0.0271394322019241, 
0.0266166654290068, 0.0375973043867059, 0.0534578823111964, 0.0520339558767358, 
0.048474183099696, 0.0437873525492503, 0.0302618772245022, 0.0293098942212726, 
0.0205035408884857, 0.00329833148244418, 0.00184672259316443, 
0.0044452476472987, -0.00152804630848635, 0.0266643336134287, 
0.0305955598967422, 0.0295759452456288, 0.0428224136032416, 0.0341814565098648, 
0.0513930446520483, 0.052747338793246, 0.0663072996170762, 0.0728635093873589, 
0.0612324054871429, 0.0466176887705014, 0.0394316317043497, 0.00676085001745186, 
-0.00187624218090043, -0.00615352339297459, -0.0194468030871544, 
-0.0232703274896426, -0.0182270827139135, 0.00790737539285757, 
0.0252879411901894, 0.0597928951797009, 0.0596491217953563, 0.0483210134553875, 
0.0424223440289033, 0.0316552526387106, 0.04355276178417, 0.0560134105983359, 
0.0486364755381423, 0.040551575838748, 0.0592607929297948, 0.0514486598768666, 
0.0646766342940026, 0.063169439585586, 0.0262386462351465, 0.0236784209475776, 
0.0129371513914922, 0.0141846349919561, -0.0075116846107548, 
-0.0161930500216272, -0.000415221726676407, 0.0168385359288674, 
0.030002481482402, 0.042932285676482, 0.012822745861909, -0.0245155557640864, 
-0.0117733751605069, -0.026785482350153, -0.0140694464997466, 
0.0158125440972903, 0.0329523337358566, 0.0559380988747122, 0.0753843372046497, 
0.0820356547514205, 0.076883422348379, 0.0672907434164216, 0.0548149017111825, 
0.0450312560659221, 0.036737694839605, 0.0423869703287014, 0.041916041586914, 
0.0412551291663146, 0.036715350143977, 0.0313003730957178, 0.0289949458722241, 
0.0267331546193681, 0.0333144078066514, 0.0323135123167315, 0.043525308743293, 
0.0421629337084628, 0.0441338814314989, 0.0408671025982379, 0.0376532328662158, 
0.0420793428987345, 0.0367847416224212, 0.0384587321197571, 0.0274112150410204, 
0.0282708345406988, 0.0242971643309868, 0.0171092108614559, 0.00644233430576513, 
-0.00915083830286534, -0.00528017926834323, -0.000734917521887368, 
0.0121627493853573, 0.0286200782323895, 0.031845580373691, 0.0367335797130277, 
0.0423557983433813, 0.0324715406950276, 0.0274402896550043, 0.022623645973491, 
0.0259196042246863, 0.0338124145232577, 0.0414593373915793, 0.0424804444870563, 
0.0405008158955571, 0.034154899691563, 0.0240669500874642, 0.0267132543111241, 
0.0224956249426427, 0.0256233556846333, 0.0394501922519339, 0.0401290187890044, 
0.0435743019547807, 0.0446185412989077, 0.0422865321374086, 0.0457258241450855, 
0.0429417118590649, 0.0451976249670967, 0.039871086440753, 0.0402263479023617, 
0.0487803941949849, 0.0468905308941832, 0.0454477937354323, 0.0449562273196715, 
0.0458783866401458, 0.0408250287263776, 0.0513246418585958, 0.0400202268224366, 
0.0284789630569957, 0.0227347967492992, 0.00931128974697693, 
0.00493714854553851, 0.00204848680632885, 0.0140584119835854, 
0.0142718400440547, 0.0222986773649776, 0.0201570560350657, 0.0161606394839904, 
0.0198969132625439, 0.0316493170353258, 0.0426370695081406, 0.0432011376797128, 
0.0412668435153467, 0.0337051079055826, 0.0306948269039715, 0.0355633458187086, 
0.033469293746462, 0.0327879569529266, 0.0298710944493852, 0.031211950891235, 
0.028991367167432, 0.0215136488307817, 0.0236172171550084, 0.0122917224956094, 
0.0169296867033832, 0.0227421780063448, 0.0185068916630353, 0.0110416276019727, 
0.00836858662720097, -0.00314447746702484, -0.0280584408669675, 
-0.0351656798650826, -0.0414671094683481, -0.0333954929662408, 
-0.00241080652085479, 0.015859655122096, 0.0268249680616748, 
0.0302949863983173, 0.0269411054891595, 0.018755149374682, 0.0163915492577704, 
0.0117590903174207, 0.0166818231878949, 0.027159028845821, 0.0245663382115993, 
0.0236640989892756, 0.0126904426282977, 0.0108104941818912, 0.00892996155399572, 
0.015073587075646, 0.0242227486892297, 0.00984266330192352, 0.0130032389352084, 
0.0187768546712954, 0.0257364780694229, 0.0309740908010894, 0.03278773910113, 
0.0381963568345745, 0.0325582542935536, 0.0360059890444027, 0.0370617298524802, 
0.0306425579652205, 0.0271131088951999, 0.0243892605480025, 0.0202147547119695, 
0.0202709643736192, 0.0243554037855889, 0.0162652950233779, 0.0148827965283438, 
0.0125362418430162, 0.0117856744611142, 0.0131923454673384, 0.0143779362837457, 
0.0142678752241308, 0.0134153247390221, 0.0114874816609558, 0.011287316278271, 
0.0102862271424105, 0.0104801978914892, 0.0134896923527972, 0.0126737269653785, 
0.0121383901164793, 0.0108175815973515, 0.0100408050573968, 0.0100800006995136, 
0.00922946616055764, 0.0153789610656272, 0.0141635279428658, 
0.014904717001635, 0.0177180247311868, 0.0141722638069206, 0.0160142390420299, 
0.0180691959652783, 0.017997145055817, 0.0201994598560873, 0.0216287996632349, 
0.0253566770551701, 0.0310726047074588, 0.0327675791746209, 0.0304665855866078, 
0.0273269221241095, 0.0271680908062844, 0.0296370432053137, 0.036539244969422, 
0.0419830109364163, 0.0422698853134809, 0.0453981427376, 0.044674593293256, 
0.0468746507191113, 0.0510276356126069, 0.0497897120762563, 0.0534543172648561, 
0.0546059325879162, 0.0488120175550688, 0.049111585848316, 0.0502740994632465, 
0.0495159160151424, 0.0514506246678357, 0.0466062857466665, 0.0468135267247676, 
0.039831820655464, 0.0390801928446716, 0.0434272934320181, 0.0396276390056256, 
0.0486462316447511, 0.0581980981710801, 0.0652749643963784, 0.0725535460450648, 
0.0809281179419301, 0.0906114278757921, 0.0999427564179016, 0.103506812528386, 
0.0948659628260002, 0.083933285271752, 0.0714428304890133, 0.059376286661994, 
0.0546313531701235, 0.0497959066215583, 0.0508342450783723, 0.0564550182587689, 
0.060274879590823, 0.0597000422836738, 0.0636139477622901, 0.0624462701674298, 
0.0666423024465384, 0.0709944583178253, 0.0703129011851704, 0.0732365362419198, 
0.0790135629506841, 0.0835611781846031, 0.0825048894077667, 0.0853688585023207, 
0.0831830977721459, 0.0847983141571422, 0.0923046674400481, 0.0963934852423134, 
0.0932532712971477, 0.0883309546932787, 0.0796383479349041, 0.0688713848863505, 
0.0622663341374525, 0.0587360062354025, 0.0512100628790617, 0.0453551271278081, 
0.0401260322461603, 0.0362472292691445, 0.0325420928854667, 0.0350815433373115, 
0.0367155741419145, 0.0343690244059229, 0.0337300103766931, 0.0345802030099565, 
0.0323711632107839, 0.030078917968126, 0.0291541247040144, 0.0225903770941587, 
0.0204122342044748, 0.0186556798411663, 0.01844738330119, 0.0208092107063402, 
0.0234977602001596, 0.0267060415414981, 0.0293872713926877, 0.0299815444684821, 
0.0329212545610247, 0.0373974592784672, 0.0371439325788847, 0.0402484637673828, 
0.0409147976385063, 0.0364203330806729, 0.0353683108782965, 0.035415746953368, 
0.0353904153047022, 0.0370643248085329, 0.0376709401371809, 0.0366084551191745, 
0.0331776978545202, 0.0316048096366712, 0.0294488187719777, 0.0238151274577447, 
0.0233424419102679, 0.0207733625777156, 0.0221246706005847, 0.0235125421726012, 
0.0232126072990217, 0.0244708365635891, 0.0229368490380919, 0.0220985154829005, 
0.0210155249602009, 0.0204044117064877, 0.0206895968523444, 0.0215806063067889, 
0.0209956402024361, 0.0203408637619331, 0.0197694091980072, 0.0194479073344294, 
0.0188543035543027, 0.0169311905071279, 0.0170821449750518, 0.0178670154856855, 
0.0167729406383854, 0.017519959081997, 0.0157752864857974, 0.0112186615565282, 
0.0106041467911115, 0.0107692173463576, 0.0105696218826044, 0.0139239794390784, 
0.0151852480918029, 0.0150667900027388, 0.0165110932865344, 0.0191439233523845, 
0.0214478793725421, 0.0242970826816329, 0.0250840661915435, 0.0237296174720836, 
0.0251159449934377, 0.0219241287066554, 0.019590603756261, 0.0165269350060733, 
0.0132100122275478, 0.0143887374520997, 0.016765365195849, 0.0197104977257361, 
0.0191870051364491, 0.0202651540118906, 0.0195963426187022, 0.0221368062218712, 
0.0276068407666523, 0.0282175268500646, 0.0304767238746981, 0.031009630269474, 
0.0295779191235264, 0.0327494191615481, 0.0333202176644152, 0.0319329842278187, 
0.0327112386489929, 0.0303573613695542, 0.0262894088669912, 0.0296316420246798, 
0.0271889352701313, 0.0236967587389616, 0.0245548051072069, 0.0190813802909959, 
0.0183603626426061, 0.0217245516674023, 0.0188000743673973, 0.015571022332618, 
0.00905029054325013, 0.00200455100047492, 0.00354028692037467, 
0.00458661514796344, 0.0106840006044173, 0.0154596674685878, 
0.0176139286975978, 0.0185003379172626, 0.0213321302886422, 0.0227985917151381, 
0.019119815342779, 0.0199847126797934, 0.0172815803694082, 0.0166291413867334, 
0.0192331948908855, 0.017996112457034, 0.0158819026944617, 0.0152376017681597, 
0.0154927135422671, 0.0134, 0.015, 0.0194, 0.0236, 0.0248, 0.0269, 
0.0281, 0.0293, 0.0293, 0.03, 0.0323, 0.0325, 0.0186, 0.0094, 
0.0132, 0.0216, 0.0257, 0.0308, 0.0358, 0.0399, 0.0393, 0.037, 
0.0294, 0.023, 0.02, 0.0173, 0.0168, 0.024, 0.0246, 0.0261, 0.0285, 
0.0292, 0.0297, 0.0296, 0.0333, 0.0345, 0.0346, 0.0349, 0.0346, 
0.0358, 0.0397, 0.0408, 0.0407, 0.0417, 0.0456, 0.0491, 0.0541, 
0.0556, 0.0482, 0.0399, 0.0389, 0.0417, 0.0479, 0.0598, 0.0594, 
0.0592, 0.0657, 0.0833, 0.0898, 0.0894, 0.0857, 0.0788, 0.067, 
0.0557, 0.0386, 0.0456, 0.0547, 0.0475, 0.0354, 0.043, 0.0474, 
0.0514, 0.0654, 0.0782, 0.1056, 0.1, 0.0932, 0.1125, 0.1209, 
0.0935, 0.063, 0.0542, 0.0616, 0.0541, 0.0483, 0.052, 0.0528, 
0.0487, 0.0466, 0.0516, 0.0582, 0.0651, 0.0676, 0.0728, 0.081, 
0.0958, 0.1007, 0.1018, 0.1095, 0.1358, 0.1505, 0.1269, 0.0984, 
0.1585, 0.1657, 0.1778, 0.1758, 0.1359, 0.1423, 0.1451, 0.1101, 
0.0929, 0.0865, 0.088, 0.0946, 0.0943, 0.0969, 0.1056, 0.1139, 
0.0927, 0.0848, 0.0792, 0.079, 0.081, 0.0783, 0.0692, 0.0621, 
0.0627, 0.0622, 0.0665, 0.0684, 0.0692, 0.0666, 0.0716, 0.0798, 
0.0847, 0.0944, 0.0973, 0.0908, 0.0861, 0.0825, 0.0824, 0.0816, 
0.0774, 0.0643, 0.0586, 0.0564, 0.0482, 0.0402, 0.0377, 0.0326, 
0.0304, 0.0304, 0.03, 0.0306, 0.0299, 0.0321, 0.0394, 0.0449, 
0.0517, 0.0581, 0.0602, 0.058, 0.0572, 0.0536, 0.0524, 0.0531, 
0.0528, 0.0528, 0.0552, 0.0553, 0.0551, 0.0552, 0.055, 0.0553, 
0.0486, 0.0473, 0.0475, 0.0509, 0.0531, 0.0568, 0.0627, 0.0652, 
0.0647, 0.0559, 0.0433, 0.035, 0.0213, 0.0173, 0.0175, 0.0174, 
0.0144, 0.0125, 0.0125, 0.0102, 0.01, 0.01, 0.0101, 0.0143, 0.0195, 
0.0247, 0.0294, 0.0346, 0.0398, 0.0446, 0.0491, 0.0525, 0.0525, 
0.0526, 0.0525, 0.0507, 0.045, 0.0318, 0.0209, 0.0194, 0.0051, 
0.0018, 0.0018, 0.0016, 0.0012, 0.0013, 0.0019, 0.0019, 0.0019, 
0.0016, 0.0009, 0.0008, 0.0007, 0.001, 0.0015, 0.0014, 0.0016, 
0.0014, 0.0012, 0.0008, 0.0009), .Dim = c(236L, 4L), .Dimnames = list(
    NULL, c("deficit_debt", "gdp_growth", "inflation", "interest_rate"
    )), .Tsp = c(1955.25, 2014, 4), class = c("mts", "ts", "matrix"
))
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.