/* * Extended Smets–Wouters model with long-term public debt, partial fiscal backing * and Brazilian macro–fiscal data * ------------------------------------------------------------------------------- * * This Dynare file started from the replication code for * * Smets, Frank and Wouters, Rafael (2007), * “Shocks and Frictions in US Business Cycles: A Bayesian DSGE Approach”, * American Economic Review, 97(3), 586–606, * * as adapted by Johannes Pfeifer for Dynare 4.5+. * * The core sticky-price / sticky-wage block of SW-2007 is kept and ported to the * framework used in * * Smets, Frank and Wouters, Rafael (2024), * “Fiscal Backing, Inflation and US Business Cycles” (preliminary manuscript), * * by introducing long-term public debt, fiscal rules and a “shadow” (fiscal-led) * economy with partial fiscal backing. The calibration block is initialized * close to the Baseline column of Table 1 in SW-2024, while steady-state ratios * and several priors are re-centered on Brazilian sample moments. * * The model is estimated with quarterly Brazilian data (IPCA inflation, Selic, * real activity and fiscal variables) using Dynare’s Bayesian estimation * command. The data are read from the Excel file * * dados_dsge_model.xlsx * * which must be in the same folder as this .mod file. The 12 observables used * in the likelihood are, in order: * * robs, pinfobs, dy, dc, dinve, dw, labobs, r1yobs, bvalobs, pbobs, trobs, gobs * * where: * • dy, dc, dinve, dw are quarter-on-quarter growth rates (100 * Δlog); * • pinfobs is IPCA inflation in percent per quarter; * • robs and r1yobs are the Selic and a 1-year yield in percent per quarter; * • labobs is log employment / hours; * • bvalobs, pbobs, trobs and gobs are, respectively, market-value public debt, * primary balance, transfers and primary government spending, all as * fractions of GDP (level between 0 and 1) around their empirical means. * * Small measurement-error shocks are allowed on each observable, with tight * inverse-gamma priors, so that the structural model can focus on capturing the * medium-to-low frequency comovements in the Brazilian data. * * Notes inherited from the SW-2007 replication: * - In the consumption Euler equation (2), the risk-premium shock ε_t^b is * premultiplied by c_3. In the code, this prefactor is absorbed into the * definition of b, that is, b := c_3 * ε_t^b. Consequently, in the * arbitrage equation for the value of capital (4), the coefficient in front * of b is 1/c_3 so that the term is again equal to ε_t^b. The reported * standard deviation in Table 1B therefore corresponds to b, not to ε_t^b in * the paper’s original notation. * - As pointed out in Del Negro and Schorfheide (2012), in the implementation * of equation (8) the factor (1 + β γ^(1−σ)) is missing in front of q_t in * both the flexible-price and sticky-price/wage economies. Equation (8) in * the paper reads * (1 − (1−δ)/γ) (1 + β γ^(1−σ)) γ² φ * whereas the code implements * (1 − (1−δ)/γ) γ² φ, * that is, the term (1 + β γ^(1−σ)) is omitted. * - Chib and Ramamurthy (2010) show that the “mode” reported in the original * paper is not the true posterior mode; in particular, the posterior mode of * \bar π (constepinf) is lower and that of \bar l (constelab) is higher. * - At the prior mean, the pairs [cmap, crhopinf] and [cmaw, crhow] are * locally collinear, so identification at the prior mean produces a * warning. This is a purely local issue; the parameters are distinguishable * away from the prior mean. * - In Table 1A of the paper: * • the habit parameter λ is erroneously labeled h; * • the fixed-cost parameter φ_p is labeled Φ; * and ρ_ga actually follows a normal prior N(0.5, 0.25²), not a beta as * stated in the text. * * This Dynare implementation keeps these conventions so as to remain comparable * with the published SW-2007 and SW-2024 results, while extending the model to * long-term government bonds, fiscal rules, a shadow economy and Brazilian data. * * Original Dynare file written by Frank Smets and Rafael Wouters and updated by * Johannes Pfeifer. The present version further extends that file to include * long-term public debt, fiscal backing, a shadow economy and an empirical * application to Brazil. * * Please note that the following copyright notice only applies to this Dynare * implementation of the model. */ /* * Copyright (C) 2007–2013 Frank Smets and Raf Wouters * Copyright (C) 2013–2015 Johannes Pfeifer * Additional extensions for long-term debt, fiscal backing, shadow economy * and Brazilian data © 2025 * * This is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This file is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You can obtain a copy of the GNU General Public License at * . */ // Main structural changes relative to Smets_Wouters_2007_45.mod // ------------------------------------------------------------ // [A] Core SW-2007 block // 1) The flexible-price block and the *f variables are removed. // 2) The original sticky-price / sticky-wage block and the 7 standard observables // (dy, dc, dinve, dw, labobs, pinfobs, robs) are retained. // // [B] Long-term public debt (Eqs. 14–16 in SW-2024 notation) // 3) New variables: bond (B_t), R_b (gross return on the long-term bond), // P_bond (price of the long-term bond), together with tau (T_t), tra (TR_t) // and g (G_t) entering the primary surplus. // 4) Budget and pricing equations: // (14) r_t = R_{b,t+1} // (15) R_{b,t} = (ρ_M / r̄) P^b_t − P^b_{t−1} // (16) b_t = β^{−1} b_{t−1} + b̄ β^{−1}(R_{b,t−1} − y_t + y_{t−1} − π_t) // − (τ_t − TR_t − G_t) // with parameters cbond_ss = b̄ and crho_M_bond = ρ_M. // // [C] Monetary policy with fiscal component (Eqs. 17 and 26) // 5) Main policy rule (partial backing): // r_t = ρ_R r_{t−1} // + (1−ρ_R)[ ψ_π(π_t − π^F_t) + ψ^F_π π^F_t // + ψ_y[(y_t − y*_t) − (y^F_t − y^{F*}_t)] ] // + ψ_{Δy}[Δ(y_t − y*_t) − Δ(y^F_t − y^{F*}_t)] + ε^m_t. // 6) Shadow rule (fiscal-led): // r^F_t = ρ^F_R r^F_{t−1} + (1−ρ^F_R) ψ_{π,F} π^F_t + ε^{m,F}_t, // with ψ_{π,F} < 1 so that the shadow regime is passive. // // [D] Fiscal policy (Eqs. 18, 22–24) — main economy // 7) Revenues, transfers and purchases follow AR-type rules that react to // funded debt (b_t − b^F_t), to the level of activity y_t and to Δy_t, // with shocks e_tau, e_tra and eg. The primary surplus entering (16) is // (τ_t − TR_t − G_t). // // [E] Shadow economy (mirror sticky block) // 8) A full mirror of the SW-2007 sticky block is introduced with suffix F: // y^F, c^F, inve^F, π^F, w^F, r^F, l^F, mc^F, z^F, r^{k,F}, k^{s,F}, k^F, // q^F and the corresponding shocks. Structural shocks in the shadow // economy load the (1−λ) share of the common innovations. Shadow fiscal // rules share the same persistence but do not react to debt; the shadow // monetary rule is passive. // // [F] Observables and measurement equations (extended SW-2024 set) // 9) In addition to the 7 SW-2007 observables, the file defines r1yobs, // bvalobs, pbobs, trobs and gobs, along with measurement equations that // map model variables into Brazilian data in growth-rate, percent and // ratio-to-GDP units, using constants equal to their sample means. // Small measurement-error shocks are attached to each observable. // // Canonical Dynare order is kept: var → varexo → parameters → model → varobs // → estimated_params → shocks. The risk-premium shock is still denoted by b, // while bond is reserved for public debt to avoid naming conflicts. var // --------- Observables (macro + fiscal) ---------- labobs ${lHOURS}$ (long_name='log hours worked (observed)') robs ${FEDFUNDS}$ (long_name='short-term policy rate, % per quarter (observed)') pinfobs ${dlP}$ (long_name='inflation, 100*Δlog(P), qoq (observed)') dy ${dlGDP}$ (long_name='real GDP growth, 100*Δlog, qoq (observed)') dc ${dlCONS}$ (long_name='real consumption growth, 100*Δlog, qoq (observed)') dinve ${dlINV}$ (long_name='real investment growth, 100*Δlog, qoq (observed)') dw ${dlWAG}$ (long_name='real wage growth, 100*Δlog, qoq (observed)') // extra observables à la SW-2024 r1yobs ${R^{1Y}}$ (long_name='1-year nominal yield, % per quarter (observed)') bvalobs ${B^{mkt}}$ (long_name='public debt, market value / GDP, fraction of GDP (observed)') pbobs ${PB}$ (long_name='primary balance / GDP, fraction of GDP (observed)') trobs ${TR^{obs}}$ (long_name='transfers / GDP, fraction of GDP (observed)') gobs ${G^{obs}}$ (long_name='gov. spending / GDP, fraction of GDP (observed)') // --------- Core state & control variables (main economy) ---------- ewma ${\eta^{w,aux}}$ (long_name='Auxiliary wage markup moving average variable') epinfma ${\eta^{p,aux}}$ (long_name='Auxiliary price markup moving average variable') mc ${\mu_p}$ (long_name='gross price markup') zcap ${z}$ (long_name='Capital utilization rate') rk ${r^{k}}$ (long_name='rental rate of capital') k ${k^{s}}$ (long_name='Capital services') pk ${q}$ (long_name='real value of existing capital stock') c ${c}$ (long_name='Consumption') inve ${i}$ (long_name='Investment') y ${y}$ (long_name='Output') lab ${l}$ (long_name='hours worked') pinf ${\pi}$ (long_name='Inflation') w ${w}$ (long_name='real wage') r ${r}$ (long_name='nominal interest rate') a ${\varepsilon_a}$ (long_name='productivity process') b ${c_2*\varepsilon_t^b}$ (long_name='Scaled risk premium shock') g ${\varepsilon^g}$ (long_name='Government purchases (policy rule with shock)') qs ${\varepsilon^i}$ (long_name='Investment-specific technology') ms ${\varepsilon^r}$ (long_name='Monetary policy shock process') spinf ${\varepsilon^p}$ (long_name='Price markup shock process') sw ${\varepsilon^w}$ (long_name='Wage markup shock process') kp ${k}$ (long_name='Capital stock') // --- Long-term public debt (main economy) --- bond ${B}$ (long_name='public debt (log, ratio to ss-GDP)') tra ${TR}$ (long_name='government transfers (ratio to ss-GDP)') tau ${T}$ (long_name='government revenues (ratio to ss-GDP)') R_b ${R^b}$ (long_name='ex-post return on long-term bond') P_bond ${P^b}$ (long_name='price of long-term government bond') // --- Targets used in policy rules --- ystar ${y^{\star}}$ (long_name='output target y* (main)') ystarF ${y_F^{\star}}$ (long_name='output target y*F (shadow)') // ===================== Shadow economy (full mirror, sticky block) ===================== // Core real/nominal variables yF ${y^F}$ (long_name='shadow output') cF ${c^F}$ (long_name='shadow consumption') inveF ${i^F}$ (long_name='shadow investment') pinfF ${\pi^F}$ (long_name='shadow inflation') wF ${w^F}$ (long_name='shadow real wage') rF ${R^F}$ (long_name='shadow nominal interest rate') labF ${l^F}$ (long_name='shadow hours worked') mcF ${\mu_p^F}$ (long_name='shadow gross price markup') // Capital/utilization block zcapF ${z^F}$ (long_name='shadow capital utilization rate') rkF ${r^{k,F}}$ (long_name='shadow rental rate of capital') kF ${k^{s,F}}$ (long_name='shadow capital services') pkF ${q^F}$ (long_name='shadow real value of existing capital stock') kpF ${k^F}$ (long_name='shadow capital stock') // Shock/state processes (mirror of main shocks, scaled by (1-λ)) aF ${\varepsilon_a^F}$ (long_name='shadow productivity process') bF ${\varepsilon_t^{b,F}}$ (long_name='shadow scaled risk premium shock') gF ${\varepsilon^{g,F}}$ (long_name='shadow gov. spending process') qsF ${\varepsilon^{i,F}}$ (long_name='shadow investment-specific technology') msF ${\varepsilon^{r,F}}$ (long_name='shadow monetary policy shock') spinfF ${\varepsilon^{p,F}}$ (long_name='shadow price markup shock') swF ${\varepsilon^{w,F}}$ (long_name='shadow wage markup shock') // Auxiliary MA variables used in NKPC/NKWPC ewmaF ${\eta^{w,aux,F}}$ (long_name='shadow aux wage markup MA') epinfmaF ${\eta^{p,aux,F}}$ (long_name='shadow aux price markup MA') // Shadow fiscal block (separate from main debt) R_bF ${R^bF}$ (long_name='shadow ex-post return on long-term bond') P_bondF ${P^bF}$ (long_name='shadow price of long-term government bond') bondF ${B^F}$ (long_name='shadow public debt (log, ratio to ss-GDP)') tauF ${T^F}$ (long_name='shadow government revenues (ratio to ss-GDP)') traF ${TR^F}$ (long_name='shadow government transfers (ratio to ss-GDP)') ; varexo ea ${\eta^a}$ (long_name='productivity shock') eb ${\eta^b}$ (long_name='risk premium shock') eg ${\eta^g}$ (long_name='spending shock') eqs ${\eta^i}$ (long_name='investment-specific technology shock') em ${\eta^m}$ (long_name='monetary policy shock') epinf ${\eta^{p}}$ (long_name='price markup shock') ew ${\eta^{w}}$ (long_name='wage markup shock') e_tra ${\eta^{tra}}$ (long_name='fiscal transfers shock') e_tau ${\eta^{\tau}}$ (long_name='fiscal revenues shock') // measurement errors e_me_dw ${\eta^{me,dw}}$ e_me_lab ${\eta^{me,lab}}$ e_me_dy ${\eta^{me,dy}}$ e_me_r1 ${\eta^{me,r1}}$ ; parameters curvw ${\varepsilon_w}$ (long_name='curvature Kimball aggregator wages') curvp ${\varepsilon_p}$ (long_name='curvature Kimball aggregator prices') // Levels / trends (macro block) constelab ${\bar l}$ (long_name='steady-state hours (level)') constepinf ${\bar \pi}$ (long_name='steady-state quarterly inflation (net, % per quarter)') constebeta ${100(\beta^{-1}-1)}$ (long_name='time preference rate, quarterly, in percent') ctrend ${\bar \gamma}$ (long_name='steady-state net growth rate, % per quarter') cg ${\frac{\bar g}{\bar y}}$ (long_name='steady-state exogenous gov. purchases share, fraction of GDP') // --- Fiscal observable means (consistent with data: fractions of GDP) --- constebval ${\overline{B^{mkt}/Y}}$ (long_name='steady-state / sample-mean market value of debt / GDP, fraction of GDP') constepb ${\overline{PB/Y}}$ (long_name='steady-state / sample-mean primary balance / GDP, fraction of GDP') constetra ${\overline{TR/Y}}$ (long_name='steady-state / sample-mean transfers / GDP, fraction of GDP') consteg ${\overline{G/Y}}$ (long_name='steady-state / sample-mean gov. spending / GDP, fraction of GDP') // Shocks and real-side structure cmaw ${\mu_w}$ (long_name='coefficient on MA term in wage markup') cmap ${\mu_p}$ (long_name='coefficient on MA term in price markup') calfa ${\alpha}$ (long_name='capital share') czcap ${\psi}$ (long_name='capacity utilization cost parameter') csadjcost ${\varphi}$ (long_name='investment adjustment cost') ctou ${\delta}$ (long_name='depreciation rate') csigma ${\sigma_c}$ (long_name='risk aversion') chabb ${\lambda}$ (long_name='external habit degree') cfc ${\phi_p}$ (long_name='fixed cost share') cindw ${\iota_w}$ (long_name='indexation to past wages') cprobw ${\xi_w}$ (long_name='Calvo parameter wages') cindp ${\iota_p}$ (long_name='indexation to past prices') cprobp ${\xi_p}$ (long_name='Calvo parameter prices') csigl ${\sigma_l}$ (long_name='Frisch elasticity') clandaw ${\phi_w}$ (long_name='gross wage markup') crpi ${r_{\pi}}$ (long_name='Taylor rule inflation feedback') crdy ${r_{\Delta y}}$ (long_name='Taylor rule output growth feedback') cry ${r_{y}}$ (long_name='Taylor rule output level feedback') crr ${\rho}$ (long_name='interest rate persistence') crhoa ${\rho_a}$ (long_name='persistence productivity shock') crhob ${\rho_b}$ (long_name='persistence risk premium shock') crhog ${\rho_g}$ (long_name='persistence in government purchases rule') crhoqs ${\rho_i}$ (long_name='persistence investment-specific technology shock') crhoms ${\rho_r}$ (long_name='persistence monetary policy shock') crhopinf ${\rho_p}$ (long_name='persistence price markup shock') crhow ${\rho_w}$ (long_name='persistence wage markup shock') // --- Long-term public debt & fiscal backing (new) --- cbond_ss ${\bar b}$ (long_name='steady-state debt-to-GDP ratio (model state, fraction of GDP)') crho_M_bond ${\rho_M}$ (long_name='maturity parameter of long-term bond') clambda ${\lambda_{FB}}$ (long_name='fiscal backing share (fraction of shocks in main economy)') // --- Monetary policy with fiscal component (new) --- crpiF ${\psi_{\pi}^{F}}$ (long_name='weight on fiscal inflation in main rule') // --- Fiscal rules (main economy, new) --- crho_tau ${\rho_{\tau}}$ (long_name='revenue rule persistence') cdelta_btau ${\delta_{b,\tau}}$ (long_name='revenue response to funded debt (b − b^F)') cdelta_y ${\delta_{y,\tau}}$ (long_name='revenue response to output level y_t') cdelta_dy ${\delta_{\Delta y,\tau}}$ (long_name='revenue response to output change Δy_t') crho_tra ${\rho_{TR}}$ (long_name='transfers rule persistence') cdelta_btra ${\delta_{b,TR}}$ (long_name='transfers response to funded debt (b − b^F)') cdelta_dh ${\delta_{\Delta h,TR}}$ (long_name='transfers response to −Δhours (proxy for Δu)') cdelta_bG ${\delta_{b,G}}$ (long_name='purchases response to funded debt (b − b^F)') ; // ------------------------------------------------------------------------- // Baseline calibration — SW (2024) "Baseline model" (λ ≈ 0.83) // NOTE: Many structural parameters are still taken from the US baseline. // Fiscal steady-state ratios (B/Y, PB/Y, TR/Y, G/Y) are calibrated // to Brazilian sample means from dados_dsge_model.xlsx. // ------------------------------------------------------------------------- // ---------- Fixed technology / preferences (kept as in SW) ---------- ctou = 0.025; // depreciation rate (quarterly) clandaw = 1.5; // gross wage markup cg = 0.18; // exogenous government purchases share, G/Y curvp = 10; // Kimball curvature (prices) curvw = 10; // Kimball curvature (wages) // ---------- Core structural parameters ---------- calfa = 0.30; // α: capital share csigma = 1.10; // σ_c: risk aversion chabb = 0.60; // h: external habit in consumption csigl = 1.852; // σ_l: inverse Frisch elasticity csadjcost = 12.00; // φ: investment adjustment cost czcap = 0.50; // ψ: utilization cost curvature cfc = 1.25; // φ_p: fixed cost / price markup // ---------- Calvo and indexation ---------- cprobw = 0.60; // ξ_w: Calvo parameter for wages cprobp = 0.60; // ξ_p: Calvo parameter for prices cindw = 0.60; // ι_w: indexation to past wage inflation cindp = 0.60; // ι_p: indexation to past price inflation // ---------- Monetary policy (still SW-like baseline) ---------- crpi = 1.50; // r_π: feedback on inflation in main rule crr = 0.50; // ρ_R: interest rate smoothing (main rule) cry = 0.125; // r_y: feedback on output level crdy = 0.125; // r_Δy: feedback on output growth crpiF = 0.50; // weight on fiscal inflation π^F in main rule // ---------- Steady-state / trend parameters (still US-style) ---------- constepinf = 1.5; // steady-state net inflation, % per quarter (≈ 2% per year) — US baseline, not yet matched to Brazilian mean constebeta = 0.25; // 100 · (β^{-1} − 1), quarterly time preference in percent ctrend = 0.60; // steady-state net growth rate of technology, % per quarter constelab = 3.00; // steady-state hours (model level, from SW), not yet re-calibrated to Brazilian labobs // ---------- Fiscal steady-state levels (ratios to GDP, BRAZIL) ---------- // Data construction (R script): // - bvalobs, pbobs, trobs, gobs are stored as FRACTIONS of GDP (0–1). // - Sample means (from summary_table): // mean(bvalobs) ≈ 0.685 → gross public debt ≈ 68.5% of GDP // mean(pbobs) ≈ 0.0091 → primary surplus ≈ 0.91% of GDP // mean(gobs) ≈ 0.0482 → primary gov. spending ≈ 4.82% of GDP // mean(trobs) ≈ 0.170 → transfers ≈ 17.0% of GDP constebval = 0.685; // steady-state / sample-mean B^{mkt}/Y, fraction of GDP (Brazil) constepb = 0.0091; // steady-state / sample-mean PB/Y, fraction of GDP (Brazil) consteg = 0.0482; // steady-state / sample-mean G/Y, fraction of GDP (Brazil) constetra = 0.170; // steady-state / sample-mean TR/Y, fraction of GDP (Brazil) // ---------- Long-term public debt and fiscal backing ---------- // IMPORTANT: cbond_ss is still taken from SW (US) and implies debt ≈ 240% of GDP, // while the Brazilian observable bvalobs has mean ≈ 68.5% (constebval). // For a fully consistent Brazilian calibration, cbond_ss should later be // re-aligned with constebval (e.g., cbond_ss ≈ 0.7). It is kept at 2.4 // here to preserve the original SW steady state until the whole block // (including steady_state_model and measurement equation for bvalobs) // is jointly revised. cbond_ss = 0.68; // model steady-state long-term debt-to-GDP ratio (state "bond"), currently US baseline crho_M_bond = 0.90; // ρ_M: maturity parameter of long-term bond clambda = 0.50; // λ_FB: fiscal-backing share (fraction of shocks in main economy) // ---------- Fiscal policy (main economy) ---------- crho_tau = 0.30; // persistence in revenue rule cdelta_btau = 0.25; // revenue response to funded debt (b − b^F) cdelta_btauF = 0.30; // revenue response to shadow debt b^F cdelta_y = 0.49; // revenue response to output level y_t cdelta_dy = 0.35; // revenue response to output change Δy_t crho_tra = 0.30; // persistence in transfers rule cdelta_btra = 0.05; // transfers response to funded debt (b − b^F) cdelta_dh = 0.35; // transfers response to −Δhours (proxy for Δu_t) crhog = 0.30; // persistence in government purchases rule cdelta_bG = 0.01; // G response to funded debt (b − b^F) // ---------- AR(1) persistence of structural shocks (baseline modes) ---------- crhoa = 0.30; // ρ_a: productivity shock persistence crhob = 0.30; // ρ_b: risk-premium shock persistence crhoqs = 0.30; // ρ_i: investment-specific technology shock persistence crhoms = 0.30; // ρ_r: monetary policy shock persistence crhopinf = 0.30; // ρ_p: price-markup shock persistence crhow = 0.30; // ρ_w: wage-markup shock persistence // ---------- Moving-average shock terms (kept inactive) ---------- cmap = 0.30; // MA term in price-markup process (set to zero) cmaw = 0.30; // MA term in wage-markup process (set to zero) model(linear); // --- Local auxiliaries (consistent with SW-2007/2024) --- #cpie = 1 + constepinf/100; // gross inflation #cgamma = 1 + ctrend/100; // gross growth #cbeta = 1/(1 + constebeta/100); // discount factor (from constebeta) #beta_inv= 1/cbeta; // handy alias #clandap = cfc; // fixed cost / gross price markup #cbetabar= cbeta*cgamma^(-csigma); #cr = cpie/(cbeta*cgamma^(-csigma)); // ss gross real rate #crk = (cbeta^(-1))*(cgamma^csigma) - (1-ctou); // ss rental rate of capital #cw = (calfa^calfa*(1-calfa)^(1-calfa)/(clandap*crk^calfa))^(1/(1-calfa)); #cikbar = 1 - (1-ctou)/cgamma; #cik = (1 - (1-ctou)/cgamma)*cgamma; #clk = ((1-calfa)/calfa)*(crk/cw); #cky = cfc*(clk)^(calfa-1); #ciy = cik*cky; #ccy = 1 - cg - cik*cky; #crkky = crk*cky; #cwhlc = (1/clandaw)*(1-calfa)/calfa*crk*cky/ccy; #cwly = 1 - crk*cky; // Aliases for the debt block #bbar = cbond_ss; // steady-state debt-to-GDP #rhoM = crho_M_bond; // maturity parameter // Steady-state short-term nominal rate (net, percent per quarter; matches robs data) #conster = (cr - 1)*100; // ========================== STICKY PRICE–WAGE (MAIN) ========================== [name='FOC labor with mpl expressed as function of rk and w, SW Eq. (9)'] mc = calfa*rk + (1-calfa)*w - 1*a - 0*(1-calfa)*a ; [name='FOC capacity utilization, SW Eq. (7)'] zcap = (1/(czcap/(1-czcap)))* rk ; [name='Firm FOC capital, SW Eq. (11)'] rk = w + lab - k ; [name='Definition capital services, SW Eq. (6)'] k = kp(-1) + zcap ; [name='Investment Euler Equation, SW Eq. (3)'] inve = (1/(1+cbetabar*cgamma)) * ( inve(-1) + cbetabar*cgamma*inve(1) + (1/(cgamma^2*csadjcost))*pk ) + qs ; [name='Arbitrage equation value of capital, SW Eq. (4)'] pk = -r + pinf(1) - 0*b + (1/((1-chabb/cgamma)/(csigma*(1+chabb/cgamma))))*b + (crk/(crk+(1-ctou)))*rk(1) + ((1-ctou)/(crk+(1-ctou)))*pk(1) ; [name='Consumption Euler Equation, SW Eq. (2)'] c = (chabb/cgamma)/(1+chabb/cgamma)*c(-1) + (1/(1+chabb/cgamma))*c(+1) + ((csigma-1)*cwhlc/(csigma*(1+chabb/cgamma)))*(lab - lab(+1)) - (1-chabb/cgamma)/(csigma*(1+chabb/cgamma))*( r - pinf(+1) + 0*b ) + b ; [name='Aggregate Resource Constraint, SW Eq. (1)'] y = ccy*c + ciy*inve + g + 1*crkky*zcap ; [name='Aggregate Production Function, SW Eq. (5)'] y = cfc*( calfa*k + (1-calfa)*lab + a ); [name='New Keynesian Phillips Curve, SW Eq. (10)'] pinf = (1/(1 + cbetabar*cgamma*cindp)) * ( cbetabar*cgamma*pinf(1) + cindp*pinf(-1) + ((1-cprobp)*(1-cbetabar*cgamma*cprobp)/cprobp)/((cfc-1)*curvp+1)*mc ) + spinf ; [name='Wage Phillips Curve, SW Eq. (13), with (12) plugged for mu_w'] w = (1/(1+cbetabar*cgamma))*w(-1) + (cbetabar*cgamma/(1+cbetabar*cgamma))*w(1) + (cindw/(1+cbetabar*cgamma))*pinf(-1) - (1+cbetabar*cgamma*cindw)/(1+cbetabar*cgamma)*pinf + (cbetabar*cgamma)/(1+cbetabar*cgamma)*pinf(1) + (1-cprobw)*(1-cbetabar*cgamma*cprobw)/((1+cbetabar*cgamma)*cprobw)*(1/((clandaw-1)*curvw+1))* ( csigl*lab + (1/(1-chabb/cgamma))*c - ((chabb/cgamma)/(1-chabb/cgamma))*c(-1) - w ) + 1*sw ; // --- Shock processes (MAIN) --- [name='Law of motion for productivity (main)'] a = crhoa*a(-1) + ea; [name='Law of motion for risk premium (main)'] b = crhob*b(-1) + eb; [name='Law of motion for investment-specific tech (main)'] qs = crhoqs*qs(-1) + eqs; [name='Law of motion for monetary policy shock (main)'] ms = 0*crhoms*ms(-1) + em; [name='Law of motion for price markup shock (main)'] spinf = crhopinf*spinf(-1) + epinfma - cmap*epinfma(-1); epinfma = epinf; [name='Law of motion for wage markup shock (main)'] sw = crhow*sw(-1) + ewma - cmaw*ewma(-1); ewma = ew; [name='Law of motion for capital, SW Eq. (8)'] kp = (1-cikbar)*kp(-1) + cikbar*inve + cikbar*cgamma^2*csadjcost*qs ; // ========================== STICKY PRICE–WAGE (SHADOW, F) ========================== [name='FOC labor (shadow) — SW Eq. (9)'] mcF = calfa*rkF + (1-calfa)*wF - 1*aF - 0*(1-calfa)*aF ; [name='FOC capacity utilization (shadow) — SW Eq. (7)'] zcapF = (1/(czcap/(1-czcap))) * rkF ; [name='Firm FOC capital (shadow) — SW Eq. (11)'] rkF = wF + labF - kF ; [name='Definition capital services (shadow) — SW Eq. (6)'] kF = kpF(-1) + zcapF ; [name='Investment Euler (shadow) — SW Eq. (3)'] inveF = (1/(1+cbetabar*cgamma)) * ( inveF(-1) + cbetabar*cgamma*inveF(1) + (1/(cgamma^2*csadjcost))*pkF ) + qsF ; [name='Arbitrage value of capital (shadow) — SW Eq. (4)'] pkF = -rF + pinfF(1) - 0*bF + (1/((1-chabb/cgamma)/(csigma*(1+chabb/cgamma))))*bF + (crk/(crk+(1-ctou)))*rkF(1) + ((1-ctou)/(crk+(1-ctou)))*pkF(1) ; [name='Consumption Euler (shadow) — SW Eq. (2)'] cF = (chabb/cgamma)/(1+chabb/cgamma)*cF(-1) + (1/(1+chabb/cgamma))*cF(+1) + ((csigma-1)*cwhlc/(csigma*(1+chabb/cgamma)))*(labF - labF(+1)) - (1-chabb/cgamma)/(csigma*(1+chabb/cgamma))*( rF - pinfF(+1) + 0*bF ) + bF ; [name='Resource constraint (shadow) — SW Eq. (1)'] yF = ccy*cF + ciy*inveF + gF + 1*crkky*zcapF ; [name='Production function (shadow) — SW Eq. (5)'] yF = cfc*( calfa*kF + (1-calfa)*labF + aF ); [name='NK Phillips Curve (shadow) — SW Eq. (10)'] pinfF = (1/(1 + cbetabar*cgamma*cindp)) * ( cbetabar*cgamma*pinfF(1) + cindp*pinfF(-1) + ((1-cprobp)*(1-cbetabar*cgamma*cprobp)/cprobp)/((cfc-1)*curvp+1)*mcF ) + spinfF ; [name='Wage Phillips Curve (shadow) — SW Eq. (13)'] wF = (1/(1+cbetabar*cgamma))*wF(-1) + (cbetabar*cgamma/(1+cbetabar*cgamma))*wF(1) + (cindw/(1+cbetabar*cgamma))*pinfF(-1) - (1+cbetabar*cgamma*cindw)/(1+cbetabar*cgamma)*pinfF + (cbetabar*cgamma)/(1+cbetabar*cgamma)*pinfF(1) + (1-cprobw)*(1-cbetabar*cgamma*cprobw)/((1+cbetabar*cgamma)*cprobw)*(1/((clandaw-1)*curvw+1))* ( csigl*labF + (1/(1-chabb/cgamma))*cF - ((chabb/cgamma)/(1-chabb/cgamma))*cF(-1) - wF ) + 1*swF ; // --- Shock processes (SHADOW), scaled by (1−λ) --- [name='Law of motion for productivity (shadow)'] aF = crhoa*aF(-1) + (1-clambda)*ea; [name='Law of motion for risk premium (shadow)'] bF = crhob*bF(-1) + (1-clambda)*eb; [name='Law of motion for investment-specific tech (shadow)'] qsF = crhoqs*qsF(-1) + (1-clambda)*eqs; [name='Law of motion for monetary policy shock (shadow)'] msF = 0*crhoms*msF(-1) + (1-clambda)*em; [name='Law of motion for price markup shock (shadow)'] spinfF = crhopinf*spinfF(-1) + epinfmaF - cmap*epinfmaF(-1); epinfmaF = (1-clambda)*epinf; [name='Law of motion for wage markup shock (shadow)'] swF = crhow*swF(-1) + ewmaF - cmaw*ewmaF(-1); ewmaF = (1-clambda)*ew; [name='Law of motion for capital (shadow), SW Eq. (8)'] kpF = (1-cikbar)*kpF(-1) + cikbar*inveF + cikbar*cgamma^2*csadjcost*qsF ; // ================= LONG-TERM DEBT & POLICY BLOCK (SW, 2024) ================= // (14) No-arbitrage: short rate equals expected long-bond return r = R_b(+1); // Eq. (14) // (15) Return on long-term bond (ex-post, t−1 to t) R_b = (crho_M_bond / cr) * P_bond - P_bond(-1); // Eq. (15) // (16)/(21) Government budget constraint (linearized; primary surplus = tau − tra − g) bond = (1/cbeta)*bond(-1) + cbond_ss*(1/cbeta)*( R_b - y + y(-1) - pinf ) - ( tau - tra - g ); // Eq. (21) // (18),(22) Revenues rule (main, responds to funded debt and activity) tau = crho_tau*tau(-1) + (1-crho_tau)*( cdelta_btau*( bond(-1) - bondF(-1) ) + cdelta_y*y(-1) ) + cdelta_dy*( y - y(-1) ) + e_tau; // Eq. (22) // (23) Transfers rule (main) tra = crho_tra*tra(-1) + (1-crho_tra)*( cdelta_btra*( bond(-1) - bondF(-1) ) ) - cdelta_dh*( lab - lab(-1) ) + e_tra; // Eq. (23) // (24) Government purchases rule (main) g = crhog*g(-1) + (1-crhog)*( cdelta_bG*( bond(-1) - bondF(-1) ) ) + eg; // Eq. (24) // (25) Monetary policy rule with fiscal component (main, SW-2024) r = crr*r(-1) + (1-crr)*( crpi*(pinf - pinfF) // ψ_π (π_t − π_t^F) + crpiF*pinfF // ψ_π^F π_t^F + cry*((y - ystar) - (yF - ystarF)) // ψ_y [(y−y*) − (y^F−y^{F*})] ) + crdy*( // ψ_{Δy}[Δ(y−y*) − Δ(y^F−y^{F*})] (y - ystar) - (y(-1) - ystar(-1)) - ( (yF - ystarF) - (yF(-1) - ystarF(-1)) ) ) + ms; // Eq. (25) // ================= LONG-TERM DEBT & POLICY BLOCK — SHADOW ECONOMY (SW, 2024) ================= // (14) No-arbitrage: short rate equals expected long-bond return rF = R_bF(+1); // Eq. (14) // (15) Return on long-term bond (ex-post, t−1 to t) R_bF = (crho_M_bond / cr) * P_bondF - P_bondF(-1); // Eq. (15) // (21) Government budget constraint in the shadow economy bondF = (1/cbeta)*bondF(-1) + cbond_ss*(1/cbeta)*( R_bF - yF + yF(-1) - pinfF ) - ( tauF - traF - gF ); // Eq. (21) // (22) Revenues rule — shadow (same persistence, no debt feedback; activity terms only) tauF = crho_tau*tauF(-1) + (1-crho_tau)*( cdelta_y*yF ) + cdelta_dy*( yF - yF(-1) ) + (1-clambda)*e_tau; // (23) Transfers rule — shadow (no debt feedback; proxy Δu^F_t with −Δlab^F_t) traF = crho_tra*traF(-1) - cdelta_dh*( labF - labF(-1) ) + (1-clambda)*e_tra; // Eq. (23) // (24) Government purchases rule — shadow (no debt feedback) gF = crhog*gF(-1) + (1-clambda)*eg; // Eq. (24) // (26) Monetary policy rule — shadow (passive; no output-gap terms) rF = crr*rF(-1) + (1-crr)*( crpiF * pinfF ) + msF; // (13) Output targets (paper) ystar = a; ystarF = aF; // ======================= MEASUREMENT EQUATIONS ======================= // Real GDP growth (qoq, Δlog, seasonally adjusted in R) // ctrend is set to the sample mean of dy (df_final$dy) [name='Observation equation output'] dy = 100*(y - y(-1)) + ctrend + e_me_dy; // Real consumption growth (qoq, Δlog, seasonally adjusted in R) [name='Observation equation consumption'] dc = 100*(c - c(-1)) + ctrend; // Real investment growth (qoq, Δlog, seasonally adjusted in R) [name='Observation equation investment'] dinve = 100*(inve - inve(-1)) + ctrend; // Real wage growth (qoq, Δlog, seasonally adjusted in R) [name='Observation equation real wage'] dw = 100*(w - w(-1)) + ctrend + e_me_dw; // Consumer price inflation (qoq, 100*Δlog IPCA, seasonally adjusted via X-13 in R) // constepinf is the average quarterly inflation used as steady-state target [name='Observation equation inflation'] pinfobs = pinf + constepinf; // Short-term policy rate (Selic, net %, per quarter, seasonally adjusted via X-13 in R) // conster is the steady-state short rate in the same units [name='Observation equation interest rate'] robs = r + conster; // Hours worked / employment: log level, seasonally adjusted via X-13 in R // constelab is the sample mean of labobs (df_final$labobs) [name='Observation equation hours worked'] labobs = lab + constelab + e_me_lab; // 1Y zero-coupon yield approximated by long-term bond return R_b // r1yobs is in net % per quarter, same scale as robs [name='Observation equation 1Y yield'] r1yobs = R_b + conster + e_me_r1; // Market value of public debt (B^{mkt}/Y), fraction of GDP (0–1) // bvalobs is in level; constebval is the sample mean of bvalobs (df_final$bvalobs) [name='Observation equation public debt (market value ratio)'] bvalobs = bond + P_bond + constebval; // Primary balance: revenues - (transfers + government spending), PB/Y // pbobs is a fraction of GDP (0–1); constepb is its sample mean [name='Observation equation primary surplus ratio'] pbobs = tau - tra - g + constepb; // Government transfers TR/Y, fraction of GDP (0–1); constetra is sample mean [name='Observation equation government transfers'] trobs = tra + constetra; // Government primary spending G/Y, fraction of GDP (0–1); consteg is sample mean [name='Observation equation government spending'] gobs = g + consteg; end; varobs // IMPORTANT: order aligned with columns in dados_dsge_model.xlsx // (date, robs, pinfobs, dy, dc, dinve, dw, labobs, r1yobs, bvalobs, pbobs, trobs, gobs) robs // short-term policy rate (Selic, % per quarter, X-13 adjusted) pinfobs // consumer price inflation (IPCA, % per quarter, X-13 adjusted) dy // real GDP growth (qoq, Δlog, source-adjusted) dc // real consumption growth (qoq, Δlog, source-adjusted) dinve // real investment growth (qoq, Δlog, source-adjusted) dw // real wage growth (qoq, Δlog, X-13 adjusted) labobs // hours worked / employment (log level, X-13 adjusted) r1yobs // 1-year nominal yield (% per quarter, X-13 adjusted) bvalobs // gross public debt-to-GDP ratio (fraction of GDP, raw) pbobs // primary balance-to-GDP ratio (fraction of GDP, X-13 adjusted) trobs // government transfers-to-GDP ratio (fraction of GDP, X-13 adjusted) gobs; // primary government spending-to-GDP ratio (fraction of GDP, X-13 adjusted) steady_state_model; // -------- States & shocks (MAIN) -------- a = 0; b = 0; qs = 0; ms = 0; spinf = 0; sw = 0; epinfma = 0; ewma = 0; // -------- Macro block (MAIN) -------- y = 0; c = 0; inve = 0; lab = 0; w = 0; pinf = 0; r = 0; mc = 0; // -------- Capital / utilization (MAIN) -------- k = 0; kp = 0; pk = 0; rk = 0; zcap = 0; // -------- Fiscal & debt (MAIN) -------- g = 0; tau = 0; tra = 0; bond = 0; R_b = 0; P_bond = 0; // -------- Shadow economy: states & shocks -------- aF = 0; bF = 0; qsF = 0; msF = 0; spinfF = 0; swF = 0; epinfmaF = 0; ewmaF = 0; // -------- Shadow macro -------- yF = 0; cF = 0; inveF = 0; labF = 0; wF = 0; pinfF = 0; rF = 0; mcF = 0; // -------- Shadow capital / utilization -------- kF = 0; kpF = 0; pkF = 0; rkF = 0; zcapF = 0; // -------- Shadow fiscal & debt -------- gF = 0; tauF = 0; traF = 0; bondF = 0; R_bF = 0; P_bondF = 0; // -------- Targets (used in policy rules) -------- ystar = 0; ystarF = 0; // -------- Observables: real activity & prices -------- // Growth rates are in 100*Δlog, so the steady state equals ctrend. dy = ctrend; dc = ctrend; dinve = ctrend; dw = ctrend; // Inflation observable in levels: mean equal to constepinf (in % per quarter) pinfobs = constepinf; // Short rate observable in levels (Selic, % per quarter). // This matches the transformation applied in the R pre-processing. robs = ( (1 + constepinf/100) / ( (1/(1 + constebeta/100)) * (1 + ctrend/100)^(-csigma) ) - 1 ) * 100; // Hours observable: level around the average constelab labobs = constelab; // -------- Extra observables (extended SW-2024 block) -------- // 1-year yield: in deterministic steady state R_b = 0, so the same level as robs r1yobs = robs; // Fiscal ratios are fed in levels (fractions of GDP, NOT demeaned). // The constants constebval, constepb, constetra and consteg are calibrated // to the sample means of the Brazilian series in the R script, so that the // model’s steady state matches the observed average levels. // Market value of public debt / GDP bvalobs = bond + P_bond + constebval; // = constebval at steady state // Primary balance / GDP = τ − TR − G pbobs = (tau - tra - g) + constepb; // = constepb at steady state // Transfers / GDP trobs = tra + constetra; // = constetra at steady state // Government spending / GDP gobs = g + consteg; // = consteg at steady state end; // NOTE: // - This 'shocks' block is used for stochastic simulations (stoch_simul). // - When running estimation(), the standard deviations of these shocks // are taken from the 'estimated_params' block (stderr ...). // Here they serve mainly as an initial calibration / sanity check. // --------------------------------------------------------------- // SHOCKS BLOCK — used only for pre-estimation stoch_simul runs. // During Bayesian estimation, these variances are IG priors set // in `estimated_params` and this block is ignored by Dynare. // --------------------------------------------------------------- shocks; // Core structural shocks (template centers; units as in the model) var ea; stderr 0.10; // TFP shock (≈10 bps in log units) var eb; stderr 0.10; // Risk-premium/Euler shock var eg; stderr 0.10; // Government spending shock var eqs; stderr 0.10; // Investment-specific technology shock var em; stderr 0.10; // Monetary policy shock (≈10 bps) var epinf; stderr 0.10; // Price mark-up shock var ew; stderr 0.10; // Wage mark-up shock // Fiscal-rule shocks (ratio units, scale-only recentering) var e_tau; stderr 0.10; // Tax-rule shock (PB/Y units) var e_tra; stderr 0.10; // Transfers-rule shock (TR/Y units) // Measurement-error std. deviations var e_me_dw; stderr 0.50; // ME: real wage growth (Δw_obs) (SAMBA 2023) var e_me_lab; stderr 0.50; // ME: hours/labor (ℓ_obs) (SAMBA 2023) var e_me_dy; stderr 0.50; // ME: real output growth (Δy_obs) (SAMBA 2023) var e_me_r1; stderr 0.50; // ME: 1-year nominal yield (SAMBA 2023) end; steady; check; //stoch_simul(order=1, irf=40, irf_shocks=(ea, em)) y c inve pinf r w lab; estimated_params; // NAME, init, LB, UB, PRIOR, P1, P2 (P3,P4 optional) // -------------------- Shock standard deviations (Inv-Gamma) -------------------- // Exogenous structural shocks prior prior ~ IG(mean from SW24, s.d. from Samba23) stderr ea, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // TFP shock std. dev. (SW24 + SAMBA 2023) stderr eb, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // Risk-premium shock std. dev. (SW24 + SAMBA 2023) stderr eg, 0.05, , , INV_GAMMA_PDF, 0.05, inf; // Government spending shock std. dev. (SW24 + SAMBA 2023) stderr eqs, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // IST shock std. dev. (SW24 + SAMBA 2023) stderr em, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // Monetary policy shock std. dev. (SW24 + SAMBA 2023) stderr epinf, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // Price markup shock std. dev. (SW24 + SAMBA 2023) stderr ew, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // Wage markup shock std. dev. (SW24 + SAMBA 2023) // Fiscal rule shocks (ratios) prior ~ IG(mean from SW24, s.d. from Samba23) stderr e_tau, 0.10, , , INV_GAMMA_PDF, 0.10, inf; // Tax-rule shock std. dev. (SW24 + SAMBA 2023) stderr e_tra, 0.05, , , INV_GAMMA_PDF, 0.05, inf; // Transfers-rule shock std. dev. (SW24 + SAMBA 2023) // -------------------- Measurement-error std. deviations prior ~ IG(0.25 , Inf) SAMBA2011 -------------------- stderr e_me_dw, 0.25, , , INV_GAMMA_PDF, 0.25, inf; // ME: real wage growth (Δw_obs) (SAMBA 2011) stderr e_me_lab, 0.25, , , INV_GAMMA_PDF, 0.25, inf; // ME: hours/labor (ℓ_obs) (SAMBA 2011) stderr e_me_dy, 0.25, , , INV_GAMMA_PDF, 0.25, inf; // ME: real output growth (Δw_obs) (SAMBA 2011) stderr e_me_r1, 0.25, , , INV_GAMMA_PDF, 0.25, inf; // ME: 1-year nominal yield (SAMBA 2011) // -------------------- Monetary policy (main + shadow) -------------------- crpi, 1.50, , , GAMMA_PDF, 1.50, 0.75; // Taylor rule: inflation coeff. (SAMBA 2023) crr, 0.50, , , BETA_PDF, 0.50, 0.175; // MP smoothing (SW24) cry, 0.50, , , GAMMA_PDF, 0.50, 0.25; // Response to output level/gap (SAMBA 2023) crdy, 0.50, , , GAMMA_PDF, 0.50, 0.25; // Response to output growth (SAMBA 2023) crpiF, 0.50, , , BETA_PDF, 0.50, 0.15; // Weight on shadow inflation π^F in main rule // -------------------- AR(1) shock persistence prior ~ B(0.30 , 0.05) SAMBA2023 -------------------- crhoa, 0.30, , , BETA_PDF, 0.30, 0.05; // TFP persistence (SAMBA 2023) crhob, 0.30, , , BETA_PDF, 0.30, 0.05; // Risk-premium (Euler) persistence (SAMBA 2023) crhoqs, 0.30, , , BETA_PDF, 0.30, 0.05; // IST persistence (SAMBA 2023) crhoms, 0.30, , , BETA_PDF, 0.30, 0.05; // MP shock persistence (SAMBA 2023) crhopinf, 0.30, , , BETA_PDF, 0.30, 0.05; // Price markup shock persistence (SAMBA 2023) crhow, 0.30, , , BETA_PDF, 0.30, 0.05; // Wage markup shock persistence (SAMBA 2023) // -------------------- MA(1) terms in price/wage mark-up shocks -------------------- cmap, 0.30, , , BETA_PDF, 0.30, 0.05; // Price markup MA(1) θ_p (SAMBA 2023) cmaw, 0.30, , , BETA_PDF, 0.30, 0.05; // Wage markup MA(1) θ_w (SAMBA 2023) // -------------------- Fiscal rules (main) -------------------- // (1) Persistence crho_tau, 0.30, , , BETA_PDF, 0.30, 0.05; // Tax rule persistence (SAMBA 2023) crho_tra, 0.30, , , BETA_PDF, 0.30, 0.05; // Transfers rule persistence (SAMBA 2023) crhog, 0.30, , , BETA_PDF, 0.30, 0.05; // Spending rule persistence (SAMBA 2023) // (2) Debt feedbacks (kept as Normal; can switch to Gamma in a later refinement) cdelta_btau, 0.25, , , NORMAL_PDF, 0.25, 0.10; // τ reacts to debt (SW 24) cdelta_btra, 0.05, , , NORMAL_PDF, 0.05, 0.10; // Transfers vs debt (SW 24, with adjustment) cdelta_bG, 0.05, , , NORMAL_PDF, 0.05, 0.10; // Transfers vs debt (SW 24, with adjustment) // (3) Cyclical elasticities cdelta_y, 0.28, , , NORMAL_PDF, 0.28, 0.20; // τ vs output level/gap (SW 24) cdelta_dy, 0.28, , , NORMAL_PDF, 0.28, 0.20; // τ vs output growth (SW 24) cdelta_dh, 0.25, , , NORMAL_PDF, 0.25, 0.20; // Transfers vs hours/unemployment (SW 24) // -------------------- Core structural (Normal / Beta) -------------------- csadjcost, 12.00, , , GAMMA_PDF, 12.00, 1.00; // Investment adj. cost (SAMBA 2023) csigma, 1.50, , , NORMAL_PDF, 1.50, 0.375; // Inverse IES (SW 24) chabb, 0.70, , , BETA_PDF, 0.70, 0.10; // Habit persistence (SW 24) cprobw, 0.60, , , BETA_PDF, 0.60, 0.20; // Wage Calvo probability (SAMBA 2023) csigl, 1.852, , , NORMAL_PDF, 1.852, 0.90; // Inverse Frisch (η) (SAMBA 2023) cprobp, 0.60, , , BETA_PDF, 0.60, 0.20; // Price Calvo probability (SAMBA 2023) cindp, 0.60, , , BETA_PDF, 0.60, 0.20; // Price indexation (SAMBA 2023) cindw, 0.60, , , BETA_PDF, 0.60, 0.20; // Wage indexation (SAMBA 2023) czcap, 0.50, , , BETA_PDF, 0.50, 0.15; // Utilization adjustment parameter (SW 24) cfc, 1.25, , , NORMAL_PDF, 1.25, 0.12; // Fixed cost / markup level (SW 2007) calfa, 0.30, , , NORMAL_PDF, 0.30, 0.05; // Capital income share (SW 24) // -------------------- Long-term debt & fiscal backing -------------------- cbond_ss, 0.68, , , NORMAL_PDF, 0.68, 0.05; // Steady-state debt ratio D/Y crho_M_bond, 0.90, , , BETA_PDF, 0.90, 0.05; // Long-term bond maturity ρ_M clambda, 0.50, , , UNIFORM_PDF, , , 0.00, 1.00; // Fiscal-backing share λ: Uniform[0,1] (SW-2024-style) // -------------------- Trend / levels (SS block; Gamma/Normal) -------------------- constepinf, 1.50, , , GAMMA_PDF, 1.50, 0.40; // Trend quarterly inflation π* constebeta, 0.25, , , GAMMA_PDF, 0.25, 0.10; // Prior on 100*(β^{-1}−1) (SW 24) constelab, 3.00, , , NORMAL_PDF, 3.00, 1.00; // Log hours level ctrend, 0.60, , , NORMAL_PDF, 0.60, 0.20; // Real GDP growth trend [% q/q] end; model_diagnostics; // ================== Bayesian estimation with Excel data ================== // // - 'dados_dsge_model.xlsx' must be in the same folder as this .mod file // - Sheet 1, range A1:M81: // * col A: date (ignored by Dynare) // * cols B–M: robs, pinfobs, dy, dc, dinve, dw, // labobs, r1yobs, bvalobs, pbobs, trobs, gobs // - There are 80 quarterly observations (after the header row). // ------- Shock groups for SW-2024-style decompositions ------- shock_groups(name=sw_groups); // Supply shocks: TFP, price/wage markups, investment-specific technology supply = ea, epinf, ew, eqs; // Demand shocks: risk-premium / preference demand = eb; // Monetary policy shocks monpol = em; // Fiscal / fiscal-backing shocks (G, T, TR) fbpol = eg, e_tau, e_tra; end; // ===================================================================== // Final (overnight) Bayesian estimation + historical decomposition // ===================================================================== //set_dynare_seed(123456); % ====================================================================== % Phase 1: posterior mode only (no MCMC) % ====================================================================== //estimation( //% --- Data --- //datafile = dados_dsge_model, //xls_sheet = Sheet1, //xls_range = B1:M81, //first_obs = 1, //nobs = 80, //% --- Kalman filter initialisation --- //presample = 12, //% --- Posterior mode --- //mode_compute = 6, //mode_file = 'est_code_v08/Output/est_code_v08_mode.mat', // comment this for 1st time run //mode_check, //mcmc_jumping_covariance = hessian, //% --- MCMC block (disabled here) --- //mh_replic = 0, % no MCMC in this step //mh_nblocks = 2, //mh_jscale = 0.25, //mh_drop = 0.50, //mh_conf_sig = 0.90 //) pinf y c inve w r lab bond tau tra g; // ====================================================================== // Phase 2: full MCMC using stored mode // ====================================================================== estimation( // --- Data --- datafile = dados_dsge_model, xls_sheet = Sheet1, xls_range = B1:M81, first_obs = 1, nobs = 80, // --- Kalman filter initialisation --- presample = 12, // --- Reuse mode from Phase 1 --- mode_compute = 0, // do not recompute the mode mode_file = 'est_code_v08/Output/est_code_v08_mode.mat', mcmc_jumping_covariance = hessian, // --- MCMC (Random-Walk Metropolis-Hastings) --- mh_replic = 350000, mh_nblocks = 2, mh_jscale = 0.25, mh_drop = 0.50, mh_conf_sig = 0.90, // --- Outputs --- bayesian_irf, irf = 40, irf_shocks = (ea, eb, eg, eqs, em, epinf, ew, e_tau, e_tra), moments_varendo ) pinf y c inve w r lab bond tau tra g; // ===================================================================== // Historical shock decomposition à la SW-2024 // ===================================================================== // Decomposition of output, inflation, policy rate and primary balance // into SW-style groups: supply / demand / monpol / fbpol shock_decomposition(use_shock_groups=sw_groups) y pinf r pbobs; plot_shock_decomposition(use_shock_groups=sw_groups) y pinf r pbobs; // Command: dynare est_code_v06 noclearall; est_code_v03_half_life; est_code_v03_fig14; est_code_v03_shockdecomp_xticks