Dears,
Greetings. I need a code for plotting transitional probabilities generated from Markov switching model. I am running a model on active-passive fiscal-monetary policy regimes.
the transition probability of monetary policy stays in active and passive regimes is (0.97, 0.03 \ 0.01, 0.99) and the transitional probability for fiscal policy is (0.94, 0.06 \ 0.05, 0.95).
I use the following stata code to compute the joint transition matrix for monetary and fiscal policies (matrix multiplication).
***Stata code:
matrix P_M = (0.97, 0.03 \ 0.01, 0.99)
matrix P_F = (0.94, 0.06 \ 0.05, 0.95)
matrix P_joint = P_M * P_F
matrix list P_joint
The, I want to put in a time-series graph showing the evolution of the monetary and fiscal policy regimes over time (quarters). Given that the computed aggregated transition matrix for monetary policy and the estimated transition matrix for fiscal policy, I run the following code. (we can have four distinct or less monetary/fiscal regimes in the graph: AM/AF, AM/PM, PM/AF, and PM/PM)
*** this is example. in my dataset (2000q1- 2023q4 with all other variables I tsset already)
set obs 96
gen quarter = tq(2000q1) + _n - 1
format quarter %tq
tsset quarter
gen monetary_regime = .
gen fiscal_regime = .
replace monetary_regime = 1 in 1
replace fiscal_regime = 1 in 1
local P_M_tight_tight = 0.97
local P_M_tight_loose = 0.03
local P_M_loose_tight = 0.01
local P_M_loose_loose = 0.99
local P_F_tight_tight = 0.94
local P_F_tight_loose = 0.06
local P_F_loose_tight = 0.05
local P_F_loose_loose = 0.95
forvalues t = 2/96 {
if monetary_regime[`t' - 1] == 1 {
replace monetary_regime = 1 in `t' if runiform() < `P_M_tight_tight'
replace monetary_regime = 2 in `t' if runiform() >= `P_M_tight_tight'
}
else if monetary_regime[`t' - 1] == 2 {
replace monetary_regime = 1 in `t' if runiform() < `P_M_loose_tight'
replace monetary_regime = 2 in `t' if runiform() >= `P_M_loose_tight'
}
if fiscal_regime[`t' - 1] == 1 {
replace fiscal_regime = 1 in `t' if runiform() < `P_F_tight_tight'
replace fiscal_regime = 2 in `t' if runiform() >= `P_F_tight_tight'
}
else if fiscal_regime[`t' - 1] == 2 {
replace fiscal_regime = 1 in `t' if runiform() < `P_F_loose_tight'
replace fiscal_regime = 2 in `t' if runiform() >= `P_F_loose_tight'
}
}
label define regime 1 "Tight" 2 "Loose"
label values monetary_regime regime
label values fiscal_regime regime
*** However, using the above code, I can't generate values for all the datapoints. Could you please suggest me, how to translate the joint transition probability matrix into time series graph.
***graph
twoway (line monetary_regime quarter, sort lcolor(blue) lpattern(solid) ///
ytitle("Regime") ylab(1 "Tight" 2 "Loose") ///
title("Monetary and Fiscal Policy Regimes Over Time")) ///
(line fiscal_regime quarter, sort lcolor(red) lpattern(dash)), ///
legend(order(1 "Monetary Policy" 2 "Fiscal Policy") ring(0) position(11))
attached are two praphs from the paper (Davig, T. and Leeper, E.M., 2011. Monetary–fiscal policy interactions and fiscal stimulus. European Economic Review, 55(2), pp.211-227.) and (Estimating a Markov Switching DSGE Model with Macroeconomic Policy Interaction)
Greetings. I need a code for plotting transitional probabilities generated from Markov switching model. I am running a model on active-passive fiscal-monetary policy regimes.
the transition probability of monetary policy stays in active and passive regimes is (0.97, 0.03 \ 0.01, 0.99) and the transitional probability for fiscal policy is (0.94, 0.06 \ 0.05, 0.95).
I use the following stata code to compute the joint transition matrix for monetary and fiscal policies (matrix multiplication).
***Stata code:
matrix P_M = (0.97, 0.03 \ 0.01, 0.99)
matrix P_F = (0.94, 0.06 \ 0.05, 0.95)
matrix P_joint = P_M * P_F
matrix list P_joint
The, I want to put in a time-series graph showing the evolution of the monetary and fiscal policy regimes over time (quarters). Given that the computed aggregated transition matrix for monetary policy and the estimated transition matrix for fiscal policy, I run the following code. (we can have four distinct or less monetary/fiscal regimes in the graph: AM/AF, AM/PM, PM/AF, and PM/PM)
*** this is example. in my dataset (2000q1- 2023q4 with all other variables I tsset already)
set obs 96
gen quarter = tq(2000q1) + _n - 1
format quarter %tq
tsset quarter
gen monetary_regime = .
gen fiscal_regime = .
replace monetary_regime = 1 in 1
replace fiscal_regime = 1 in 1
local P_M_tight_tight = 0.97
local P_M_tight_loose = 0.03
local P_M_loose_tight = 0.01
local P_M_loose_loose = 0.99
local P_F_tight_tight = 0.94
local P_F_tight_loose = 0.06
local P_F_loose_tight = 0.05
local P_F_loose_loose = 0.95
forvalues t = 2/96 {
if monetary_regime[`t' - 1] == 1 {
replace monetary_regime = 1 in `t' if runiform() < `P_M_tight_tight'
replace monetary_regime = 2 in `t' if runiform() >= `P_M_tight_tight'
}
else if monetary_regime[`t' - 1] == 2 {
replace monetary_regime = 1 in `t' if runiform() < `P_M_loose_tight'
replace monetary_regime = 2 in `t' if runiform() >= `P_M_loose_tight'
}
if fiscal_regime[`t' - 1] == 1 {
replace fiscal_regime = 1 in `t' if runiform() < `P_F_tight_tight'
replace fiscal_regime = 2 in `t' if runiform() >= `P_F_tight_tight'
}
else if fiscal_regime[`t' - 1] == 2 {
replace fiscal_regime = 1 in `t' if runiform() < `P_F_loose_tight'
replace fiscal_regime = 2 in `t' if runiform() >= `P_F_loose_tight'
}
}
label define regime 1 "Tight" 2 "Loose"
label values monetary_regime regime
label values fiscal_regime regime
*** However, using the above code, I can't generate values for all the datapoints. Could you please suggest me, how to translate the joint transition probability matrix into time series graph.
***graph
twoway (line monetary_regime quarter, sort lcolor(blue) lpattern(solid) ///
ytitle("Regime") ylab(1 "Tight" 2 "Loose") ///
title("Monetary and Fiscal Policy Regimes Over Time")) ///
(line fiscal_regime quarter, sort lcolor(red) lpattern(dash)), ///
legend(order(1 "Monetary Policy" 2 "Fiscal Policy") ring(0) position(11))
attached are two praphs from the paper (Davig, T. and Leeper, E.M., 2011. Monetary–fiscal policy interactions and fiscal stimulus. European Economic Review, 55(2), pp.211-227.) and (Estimating a Markov Switching DSGE Model with Macroeconomic Policy Interaction)