| 1 |
/* |
| 2 |
* This file provides replication files for |
| 3 |
* Smets, Frank and Wouters, Rafael (2007): "Shocks and Frictions in US Business Cycles: A Bayesian |
| 4 |
* DSGE Approach", American Economic Review, 97(3), 586-606, that are compatible with Dynare 4.5 onwards |
| 5 |
* |
| 6 |
* To replicate the full results, you have to get back to the original replication files available at |
| 7 |
* https://www.aeaweb.org/articles.php?doi=10.1257/aer.97.3.586 and include the respective estimation commands and mode-files. |
| 8 |
* |
| 9 |
* Notes: |
| 10 |
* - The consumption Euler equation in the paper, equation (2), premultiplies the risk premium process \varepsilon_t^b, |
| 11 |
* denoted by b in this code, by the coefficient c_3. In the code this prefactor is omitted by setting the |
| 12 |
* coefficient to 1. As a consequence, b in this code actually is b:=c_3*\varepsilon_t^b. As a consequence, in |
| 13 |
* the arbitrage equation for the value of capital in the paper, equation (4), the term 1*\varepsilon_t^b |
| 14 |
* is replaced by 1/c_3*b, which is equal to \varepsilon_t^b given the above redefinition. This rescaling also explains why the |
| 15 |
* standard deviation of the risk premium shock in the AR(1)-process for b has a different standard deviation than reported |
| 16 |
* in the paper. However, the results are unaffected by this scaling factor (except for the fact that the posterior distribution |
| 17 |
* reported in the paper cannot be directly translated to the present mod-file due to parameter correlation in the posterior. |
| 18 |
* - As pointed out in Del Negro/Schorfheide (2012): "Notes on New-Keynesian Models" |
| 19 |
* in the code implementation of equation (8) for both the flex price and the sticky price/wage economy, |
| 20 |
* there is a (1+cbetabar*cgamma) missing in the i_2 in front of q_t (denoted qs in the code). |
| 21 |
* Equation (8) in the paper reads: |
| 22 |
* (1-(1-delta)/gamma)*(1+beta*gamma^(1-sigma))*gamma^2*varphi |
| 23 |
* which translates to the code snippet: |
| 24 |
* (1-(1-ctou)/cgamma)*(1+cbetabar*cgamma)*cgamma^2*csadjcost |
| 25 |
* But the code implements |
| 26 |
* (1-(1-ctou)/cgamma)*cgamma^2*csadjcost |
| 27 |
* which corresponds to an equation reading |
| 28 |
* (1-(1-delta)/gamma)*gamma^2*varphi |
| 29 |
* - Chib/Ramamurthy (2010): "Tailored randomized block MCMC methods with application to DSGE models", Journal of Econometrics, 155, pp. 19-38 |
| 30 |
* have pointed out that the mode reported in the original Smets/Wouters (2007) paper is not actually the mode. \bar \pi (constepinf) is estimated lower |
| 31 |
* while \bar \l (constelab) is higher. |
| 32 |
* - Note that at the prior mean, [cmap,crhopinf] and [cmaw,crhow] are pairwise collinear. Thus, running identification at the prior |
| 33 |
* mean will return a warning. But this is only a local issue. These parameters are only indistinguishable at the prior mean, but not |
| 34 |
* at different points. |
| 35 |
* - In the prior Table 1A in the paper, the |
| 36 |
* - habit parameter $\lambda$ is erroneously labeled h |
| 37 |
* - the fixed cost parameter $\phi_p$ is labeled $\Phi$ |
| 38 |
* - Table 1B claims that $\rho_{ga}$ follows a beta prior with B(0.5,0.2^2), but the code shows that it actually |
| 39 |
* follows a normal distribution with N(0.5,0.25^2) |
| 40 |
* |
| 41 |
* This file was originally written by Frank Smets and Rafeal Wouters and has been updated by |
| 42 |
* Johannes Pfeifer. |
| 43 |
* |
| 44 |
* Please note that the following copyright notice only applies to this Dynare |
| 45 |
* implementation of the model |
| 46 |
*/ |
| 47 |
|
| 48 |
/* |
| 49 |
* Copyright © 2007-2013 Frank Smets and Raf Wouters |
| 50 |
* Copyright © 2013-2025 Johannes Pfeifer |
| 51 |
* Copyright © 2025-2026 Dynare Team |
| 52 |
* |
| 53 |
* This is free software: you can redistribute it and/or modify |
| 54 |
* it under the terms of the GNU General Public License as published by |
| 55 |
* the Free Software Foundation, either version 3 of the License, or |
| 56 |
* (at your option) any later version. |
| 57 |
* |
| 58 |
* This file is distributed in the hope that it will be useful, |
| 59 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 60 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 61 |
* GNU General Public License for more details. |
| 62 |
* |
| 63 |
* You can receive a copy of the GNU General Public License |
| 64 |
* at <http://www.gnu.org/licenses/>. |
| 65 |
*/ |
| 66 |
|
| 67 |
// -----------------Dynare ----------------------------------------------// |
| 68 |
var labobs ${lHOURS}$ (long_name='log hours worked') |
| 69 |
robs ${FEDFUNDS}$ (long_name='Federal funds rate') |
| 70 |
pinfobs ${\pi}$ (long_name='Inflation') |
| 71 |
dy ${\Delta GDP}$ (long_name='Output growth rate') |
| 72 |
dc ${\Delta C}$ (long_name='Consumption growth rate') |
| 73 |
dinve ${\Delta I}$ (long_name='Investment growth rate') |
| 74 |
dw ${\Delta W}$ (long_name='Wage growth rate') |
| 75 |
ewma ${\eta^{w,aux}}$ (long_name='Auxiliary wage markup moving average variable') |
| 76 |
epinfma ${\eta^{p,aux}}$ (long_name='Auxiliary price markup moving average variable') |
| 77 |
ygap ${ygap}$ (long_name='ygap') |
| 78 |
mc ${\mu_p}$ (long_name='gross price markup') |
| 79 |
zcap ${z}$ (long_name='Capital utilization rate') |
| 80 |
rk ${r^{k}}$ (long_name='rental rate of capital') |
| 81 |
k ${k^{s}}$ (long_name='Capital services') |
| 82 |
pk ${q}$ (long_name='real value of existing capital stock') |
| 83 |
c ${c}$ (long_name='Consumption') |
| 84 |
inve ${i}$ (long_name='Investment') |
| 85 |
y ${y}$ (long_name='Output') |
| 86 |
lab ${l}$ (long_name='hours worked') |
| 87 |
pinf ${\pi}$ (long_name='Inflation') |
| 88 |
w ${w}$ (long_name='real wage') |
| 89 |
r ${r}$ (long_name='nominal interest rate') |
| 90 |
rnot ${rnot}$ (long_name='notional interest rate') |
| 91 |
rlag ${rlag}$ (long_name='Inertia interest rate') |
| 92 |
a ${\varepsilon_a}$ (long_name='productivity process') |
| 93 |
b ${c_2*\varepsilon_t^b}$ (long_name='Scaled risk premium shock') |
| 94 |
g ${\varepsilon^g}$ (long_name='Exogenous spending') |
| 95 |
qs ${\varepsilon^i}$ (long_name='Investment-specific technology') |
| 96 |
ms ${\varepsilon^r}$ (long_name='Monetary policy shock process') |
| 97 |
spinf ${\varepsilon^p}$ (long_name='Price markup shock process') |
| 98 |
sw ${\varepsilon^w}$ (long_name='Wage markup shock process') |
| 99 |
kp ${k}$ (long_name='Capital stock') |
| 100 |
; |
| 101 |
|
| 102 |
varexo ea ${\eta^a}$ (long_name='productivity shock') |
| 103 |
eb ${\eta^b}$ (long_name='risk premium shock') |
| 104 |
eg ${\eta^g}$ (long_name='Spending shock') |
| 105 |
eqs ${\eta^i}$ (long_name='Investment-specific technology shock') |
| 106 |
em ${\eta^m}$ (long_name='Monetary policy shock') |
| 107 |
epinf ${\eta^{p}}$ (long_name='Price markup shock') |
| 108 |
ew ${\eta^{w}}$ (long_name='Wage markup shock') |
| 109 |
; |
| 110 |
|
| 111 |
parameters curvw ${\varepsilon_w}$ (long_name='Curvature Kimball aggregator wages') |
| 112 |
cgy ${\rho_{ga}}$ (long_name='Feedback technology on exogenous spending') |
| 113 |
curvp ${\varepsilon_p}$ (long_name='Curvature Kimball aggregator prices') |
| 114 |
constelab ${\bar l}$ (long_name='steady state hours') |
| 115 |
constepinf ${\bar \pi}$ (long_name='steady state inflation rate') |
| 116 |
constebeta ${100(\beta^{-1}-1)}$ (long_name='time preference rate in percent') |
| 117 |
calfa ${\alpha}$ (long_name='capital share') |
| 118 |
czcap ${\psi}$ (long_name='capacity utilization cost') |
| 119 |
csadjcost ${\varphi}$ (long_name='investment adjustment cost') |
| 120 |
ctou ${\delta}$ (long_name='depreciation rate') |
| 121 |
csigma ${\sigma_c}$ (long_name='risk aversion') |
| 122 |
chabb ${\lambda}$ (long_name='external habit degree') |
| 123 |
cfc ${\phi_p}$ (long_name='fixed cost share') |
| 124 |
cindw ${\iota_w}$ (long_name='Indexation to past wages') |
| 125 |
cprobw ${\xi_w}$ (long_name='Calvo parameter wages') |
| 126 |
cindp ${\iota_p}$ (long_name='Indexation to past prices') |
| 127 |
cprobp ${\xi_p}$ (long_name='Calvo parameter prices') |
| 128 |
csigl ${\sigma_l}$ (long_name='Frisch elasticity') |
| 129 |
clandaw ${\phi_w}$ (long_name='Gross markup wages') |
| 130 |
crpi ${r_{\pi}}$ (long_name='Taylor rule inflation feedback') |
| 131 |
crdy ${r_{\Delta y}}$ (long_name='Taylor rule output growth feedback') |
| 132 |
cry ${r_{y}}$ (long_name='Taylor rule output level feedback') |
| 133 |
crr ${\rho}$ (long_name='interest rate persistence') |
| 134 |
crhoa ${\rho_a}$ (long_name='persistence productivity shock') |
| 135 |
crhob ${\rho_b}$ (long_name='persistence risk premium shock') |
| 136 |
crhog ${\rho_g}$ (long_name='persistence spending shock') |
| 137 |
crhoqs ${\rho_i}$ (long_name='persistence risk premium shock') |
| 138 |
ctrend ${\bar \gamma}$ (long_name='net growth rate in percent') |
| 139 |
cg ${\frac{\bar g}{\bar y}}$ (long_name='steady state exogenous spending share') |
| 140 |
rlb ${rlb}$ (long_name='effective lower bound') |
| 141 |
inomobszlb ${iobszlb}$ (long_name='switch if inom is observed at the zlb') |
| 142 |
|
| 143 |
cpie //gross inflation rate |
| 144 |
cgamma // gross growth rate |
| 145 |
cbeta //discount factor |
| 146 |
clandap // fixed cost share/gross price markup |
| 147 |
cbetabar // growth-adjusted discount factor in Euler equation |
| 148 |
cr // steady state gross real interest rate |
| 149 |
crk // R^k_{*}: steady state rental rate |
| 150 |
cw // steady state real wage |
| 151 |
cikbar // (1-k_1) in equation LOM capital, equation (8) |
| 152 |
cik // i_k: investment-capital ratio |
| 153 |
clk // labor to capital ratio |
| 154 |
cky // k_y: steady state output ratio |
| 155 |
ciy // investment-output ratio |
| 156 |
ccy // consumption-output ratio |
| 157 |
crkky // z_y=R_{*}^k*k_y |
| 158 |
cwhlc // W^{h}_{*}*L_{*}/C_{*} used in c_2 in equation (2) |
| 159 |
cwly // unused parameter |
| 160 |
conster // steady state federal funds rate ($\bar r$) |
| 161 |
; |
| 162 |
// fixed parameters |
| 163 |
ctou=.025; |
| 164 |
clandaw=1.5; |
| 165 |
cg=0.18; |
| 166 |
curvp=10; |
| 167 |
curvw=10; |
| 168 |
zlb = 0; |
| 169 |
inomobszlb=1; |
| 170 |
rlb = 0.05;//1.05; |
| 171 |
// estimated parameters initialisation |
| 172 |
calfa=.24; |
| 173 |
cbeta=.9995; |
| 174 |
csigma=1.5; |
| 175 |
cfc=1.5; |
| 176 |
cgy=0.51; |
| 177 |
csadjcost= 6.0144; |
| 178 |
chabb= 0.6361; |
| 179 |
cprobw= 0.8087; |
| 180 |
csigl= 1.9423; |
| 181 |
cprobp= 0.6; |
| 182 |
cindw= 0.3243; |
| 183 |
cindp= 0.47; |
| 184 |
czcap= 0.2696; |
| 185 |
crpi= 1.488; |
| 186 |
crr= 0.8762; |
| 187 |
cry= 0.0593; |
| 188 |
crdy= 0.2347; |
| 189 |
crhoa= 0.9977; |
| 190 |
crhob= 0.5799; |
| 191 |
crhog= 0.9957; |
| 192 |
crhols= 0.9928; |
| 193 |
crhoqs= 0.7165; |
| 194 |
crhoas=1; |
| 195 |
crhoms=0; |
| 196 |
crhopinf=0; |
| 197 |
crhow=0; |
| 198 |
cmap = 0; |
| 199 |
cmaw = 0; |
| 200 |
constelab=0; |
| 201 |
|
| 202 |
// Trends from data |
| 203 |
load('usdata_pkf') |
| 204 |
constepinf=0.7; |
| 205 |
constebeta=0.7420; |
| 206 |
//ctrend=0.3982; |
| 207 |
set_param_value('ctrend',mean(dy(74:end))) |
| 208 |
|
| 209 |
ybar = 19; |
| 210 |
shocks; |
| 211 |
var ea; |
| 212 |
stderr 0.4618; |
| 213 |
var eb; |
| 214 |
stderr 1.8513; |
| 215 |
var eg; |
| 216 |
stderr 0.6090; |
| 217 |
var eqs; |
| 218 |
stderr 0.6017; |
| 219 |
var em; |
| 220 |
stderr 0.2397; |
| 221 |
var epinf; |
| 222 |
stderr 0.1455; |
| 223 |
var ew; |
| 224 |
stderr 0.2089; |
| 225 |
end; |
| 226 |
|
| 227 |
|
| 228 |
model(linear); |
| 229 |
|
| 230 |
[name='FOC labor with mpl expressed as function of rk and w, SW Equation (9)'] |
| 231 |
mc = calfa*rk+(1-calfa)*(w) - 1*a - 0*(1-calfa)*a ; |
| 232 |
[name='FOC capacity utilization, SW Equation (7)'] |
| 233 |
zcap = (1/(czcap/(1-czcap)))* rk ; |
| 234 |
[name='Firm FOC capital, SW Equation (11)'] |
| 235 |
rk = w+lab-k ; |
| 236 |
[name='Definition capital services, SW Equation (6)'] |
| 237 |
k = kp(-1)+zcap ; |
| 238 |
[name='Investment Euler Equation, SW Equation (3)'] |
| 239 |
inve = (1/(1+cbetabar*cgamma))* (inve(-1) + cbetabar*cgamma*inve(1)+(1/(cgamma^2*csadjcost))*pk ) +qs ; |
| 240 |
[name='Arbitrage equation value of capital, SW Equation (4)'] |
| 241 |
pk = -r+pinf(1)-0*b |
| 242 |
+ (1/((1-chabb/cgamma)/(csigma*(1+chabb/cgamma))))*b |
| 243 |
+ (crk/(crk+(1-ctou)))*rk(1) |
| 244 |
+ ((1-ctou)/(crk+(1-ctou)))*pk(1) ; |
| 245 |
[name='Consumption Euler Equation, SW Equation (2)'] |
| 246 |
c = (chabb/cgamma)/(1+chabb/cgamma)*c(-1) |
| 247 |
+ (1/(1+chabb/cgamma))*c(+1) |
| 248 |
+((csigma-1)*cwhlc/(csigma*(1+chabb/cgamma)))*(lab-lab(+1)) |
| 249 |
- (1-chabb/cgamma)/(csigma*(1+chabb/cgamma))*(r-pinf(+1) + 0*b) +b ; |
| 250 |
[name='Aggregate Resource Constraint, SW Equation (1)'] |
| 251 |
y = ccy*c+ciy*inve+g + 1*crkky*zcap ; |
| 252 |
[name='Aggregate Production Function, SW Equation (5)'] |
| 253 |
y = cfc*( calfa*k+(1-calfa)*lab +a ); |
| 254 |
[name='New Keynesian Phillips Curve, SW Equation (10)'] |
| 255 |
pinf = (1/(1+cbetabar*cgamma*cindp)) * ( cbetabar*cgamma*pinf(1) +cindp*pinf(-1) |
| 256 |
+((1-cprobp)*(1-cbetabar*cgamma*cprobp)/cprobp)/((cfc-1)*curvp+1)*(mc) ) + spinf ; |
| 257 |
[name='Wage Phillips Curve, SW Equation (13), with (12) plugged for mu_w'] |
| 258 |
w = (1/(1+cbetabar*cgamma))*w(-1) |
| 259 |
+(cbetabar*cgamma/(1+cbetabar*cgamma))*w(1) |
| 260 |
+(cindw/(1+cbetabar*cgamma))*pinf(-1) |
| 261 |
-(1+cbetabar*cgamma*cindw)/(1+cbetabar*cgamma)*pinf |
| 262 |
+(cbetabar*cgamma)/(1+cbetabar*cgamma)*pinf(1) |
| 263 |
+(1-cprobw)*(1-cbetabar*cgamma*cprobw)/((1+cbetabar*cgamma)*cprobw)*(1/((clandaw-1)*curvw+1))* |
| 264 |
(csigl*lab + (1/(1-chabb/cgamma))*c - ((chabb/cgamma)/(1-chabb/cgamma))*c(-1) -w) |
| 265 |
+ 1*sw ; |
| 266 |
[name='Taylor rule, SW Equation (14)'] |
| 267 |
rnot = crpi*(1-crr)*pinf |
| 268 |
//Note: y = cfc*(calfa*(zcap)+(1-calfa)*lab-stst(lab)); |
| 269 |
// +cry*(1-crr)*(cfc*(calfa*(zcap)+(1-calfa)*lab)) |
| 270 |
// +crdy*((cfc*(calfa*(zcap)+(1-calfa)*lab))-(cfc*(calfa*(zcap(-1))+(1-calfa)*lab(-1)))) |
| 271 |
+cry*(1-crr)*ygap |
| 272 |
+crdy*(ygap-ygap(-1)) |
| 273 |
+ |
| 274 |
crr*rlag(-1) ; |
| 275 |
[name = 'Observed interest rate',relax='zlb'] |
| 276 |
r = rnot + ms; |
| 277 |
[name = 'Observed interest rate',bind='zlb'] |
| 278 |
r = rlb-conster + inomobszlb*ms; //-> and remove inom from obs |
| 279 |
|
| 280 |
[name = 'Auxiliary notional interest rate',bind='zlb'] |
| 281 |
rlag = rnot; |
| 282 |
[name = 'Auxiliary notional interest rate',relax='zlb'] |
| 283 |
rlag = r; |
| 284 |
[name='Output gap check'] |
| 285 |
ygap = cfc*(calfa*(zcap)+(1-calfa)*lab); |
| 286 |
[name='Law of motion for productivity'] |
| 287 |
//a = crhoa*a(-1) + ea*exp(lea); // for log normal prior |
| 288 |
a = crhoa*a(-1) + ea; |
| 289 |
[name='Law of motion for risk premium'] |
| 290 |
b = crhob*b(-1) + eb; |
| 291 |
[name='Law of motion for spending process'] |
| 292 |
g = crhog*(g(-1)) + eg + cgy*ea; |
| 293 |
[name='Law of motion for investment specific technology shock process'] |
| 294 |
qs = crhoqs*qs(-1) + eqs; |
| 295 |
[name='Law of motion for monetary policy shock process'] |
| 296 |
ms = em; |
| 297 |
[name='Law of motion for price markup shock process'] |
| 298 |
spinf = epinf; |
| 299 |
epinfma=epinf; |
| 300 |
[name='Law of motion for wage markup shock process'] |
| 301 |
sw = ew; |
| 302 |
ewma=ew; |
| 303 |
[name='Law of motion for capital, SW Equation (8) (see header notes)'] |
| 304 |
kp = (1-cikbar)*kp(-1)+cikbar*inve + cikbar*cgamma^2*csadjcost*qs ; |
| 305 |
// measurement equations |
| 306 |
[name='Observation equation output'] |
| 307 |
dy=y-y(-1)+ctrend; |
| 308 |
[name='Observation equation consumption'] |
| 309 |
dc=c-c(-1)+ctrend; |
| 310 |
[name='Observation equation investment'] |
| 311 |
dinve=inve-inve(-1)+ctrend; |
| 312 |
[name='Observation equation real wage'] |
| 313 |
dw=w-w(-1)+ctrend; |
| 314 |
[name='Observation equation inflation'] |
| 315 |
pinfobs = 1*(pinf) + constepinf; |
| 316 |
[name='Observation equation interest rate'] |
| 317 |
robs = 1*(r) + conster; |
| 318 |
[name='Observation equation hours worked'] |
| 319 |
labobs = lab + constelab; |
| 320 |
end; |
| 321 |
|
| 322 |
occbin_constraints; |
| 323 |
name 'zlb'; bind rnot+conster<=rlb; //relax rnot+conster> rlb; |
| 324 |
end; |
| 325 |
|
| 326 |
steady_state_model; |
| 327 |
dy=ctrend; |
| 328 |
dc=ctrend; |
| 329 |
dinve=ctrend; |
| 330 |
dw=ctrend; |
| 331 |
pinfobs = constepinf; |
| 332 |
robs = (((1+constepinf/100)/((1/(1+constebeta/100))*(1+ctrend/100)^(-csigma)))-1)*100; |
| 333 |
labobs = constelab; |
| 334 |
cpie=1+constepinf/100; %gross inflation rate |
| 335 |
cgamma=1+ctrend/100 ; %gross growth rate |
| 336 |
cbeta=1/(1+constebeta/100); %discount factor |
| 337 |
clandap=cfc; %fixed cost share/gross price markup |
| 338 |
cbetabar=cbeta*cgamma^(-csigma); %growth-adjusted discount factor in Euler equation |
| 339 |
cr=cpie/(cbeta*cgamma^(-csigma)); %steady state gross real interest rate |
| 340 |
crk=(cbeta^(-1))*(cgamma^csigma) - (1-ctou); %R^k_{*}: steady state rental rate |
| 341 |
cw = (calfa^calfa*(1-calfa)^(1-calfa)/(clandap*crk^calfa))^(1/(1-calfa)); %steady state real wage |
| 342 |
// //cw = (calfa^calfa*(1-calfa)^(1-calfa)/(clandap*((cbeta^(-1))*(cgamma^csigma) - (1-ctou))^calfa))^(1/(1-calfa)); |
| 343 |
cikbar=(1-(1-ctou)/cgamma); %(1-k_1) in equation LOM capital, equation (8) |
| 344 |
cik=(1-(1-ctou)/cgamma)*cgamma; %i_k: investment-capital ratio |
| 345 |
clk=((1-calfa)/calfa)*(crk/cw); %labor to capital ratio |
| 346 |
cky=cfc*(clk)^(calfa-1); %k_y: steady state output ratio |
| 347 |
ciy=cik*cky; %investment-output ratio |
| 348 |
ccy=1-cg-cik*cky; %consumption-output ratio |
| 349 |
crkky=crk*cky; %z_y=R_{*}^k*k_y |
| 350 |
cwhlc=(1/clandaw)*(1-calfa)/calfa*crk*cky/ccy; %W^{h}_{*}*L_{*}/C_{*} used in c_2 in equation (2) |
| 351 |
cwly=1-crk*cky; %unused parameter |
| 352 |
conster=(cr-1)*100; %steady state federal funds rate ($\bar r$) |
| 353 |
end; |
| 354 |
|
| 355 |
varobs dy dc dinve labobs pinfobs dw robs; |
| 356 |
|
| 357 |
options_.occbin.smoother.max_number_of_iterations=20; |
| 358 |
options_.occbin.smoother.first_period_occbin_update=1; |
| 359 |
options_.occbin.likelihood.first_period_occbin_update=1; |
| 360 |
options_.occbin.likelihood.check_ahead_periods=60; |
| 361 |
options_.occbin.likelihood.max_check_ahead_periods=60; |
| 362 |
options_.occbin.simul.check_ahead_periods=60; |
| 363 |
options_.occbin.simul.max_check_ahead_periods=60; |
| 364 |
options_.occbin.smoother.check_ahead_periods=60; |
| 365 |
options_.occbin.smoother.max_check_ahead_periods=60; |
| 366 |
|
| 367 |
estimated_params; |
| 368 |
stderr ea,,0.01,3,INV_GAMMA_PDF,0.1,2; |
| 369 |
stderr eb,,0.025,5,INV_GAMMA_PDF,0.1,2; |
| 370 |
stderr eg,,0.01,3,INV_GAMMA_PDF,0.1,2; |
| 371 |
stderr eqs,,0.01,3,INV_GAMMA_PDF,0.1,2; |
| 372 |
stderr em,,0.01,3,INV_GAMMA_PDF,0.1,2; |
| 373 |
stderr epinf,,0.01,3,INV_GAMMA_PDF,0.1,2; |
| 374 |
stderr ew,,0.01,3,INV_GAMMA_PDF,0.1,2; |
| 375 |
crhoa,,.01,.9999,BETA_PDF,0.5,0.20; |
| 376 |
crhob,,.01,.9999,BETA_PDF,0.5,0.20; |
| 377 |
crhog,,.01,.9999,BETA_PDF,0.5,0.20; |
| 378 |
crhoqs,,.01,.9999,BETA_PDF,0.5,0.20; |
| 379 |
csadjcost,,2,15,NORMAL_PDF,4,1.5; |
| 380 |
csigma,,0.25,3,NORMAL_PDF,1.50,0.375; |
| 381 |
chabb,,0.001,0.99,BETA_PDF,0.7,0.1; |
| 382 |
cprobw,,0.3,0.95,BETA_PDF,0.5,0.1; |
| 383 |
csigl,,0.25,10,NORMAL_PDF,2,0.75; |
| 384 |
cprobp,,0.5,0.95,BETA_PDF,0.5,0.10; |
| 385 |
cindw,,0.01,0.99,BETA_PDF,0.5,0.15; |
| 386 |
cindp,,0.01,0.99,BETA_PDF,0.5,0.15; |
| 387 |
czcap,,0.01,1,BETA_PDF,0.5,0.15; |
| 388 |
cfc,,1.0,3,NORMAL_PDF,1.25,0.125; |
| 389 |
crpi,,1.0,3,NORMAL_PDF,1.5,0.25; |
| 390 |
crr,,0.5,0.975,BETA_PDF,0.75,0.10; |
| 391 |
cry,,0.001,0.5,NORMAL_PDF,0.125,0.05; |
| 392 |
crdy,,0.001,0.5,NORMAL_PDF,0.125,0.05; |
| 393 |
constepinf,,0.1,2.0,GAMMA_PDF,0.625,0.1;//20; |
| 394 |
constebeta,,0.01,2.0,GAMMA_PDF,0.25,0.1;//0.20; |
| 395 |
constelab,,-10.0,10.0,NORMAL_PDF,0.0,2.0; |
| 396 |
ctrend,,0.1,0.8,NORMAL_PDF,0.4,0.10; |
| 397 |
cgy,,0.01,2.0,NORMAL_PDF,0.5,0.25; |
| 398 |
calfa,,0.01,1.0,NORMAL_PDF,0.3,0.05; |
| 399 |
end; |
| 400 |
options_.TeX=true; |
| 401 |
options_.debug = 0; |
| 402 |
options_.occbin.likelihood.periodic_solution = true; |
| 403 |
options_.occbin.simul.periodic_solution = true; |
| 404 |
options_.occbin.smoother.periodic_solution = true; |
| 405 |
options_.occbin.filter.particle.number_of_particles =64; |
| 406 |
options_.noprint = false; |
| 407 |
options_.nograph = false; |
| 408 |
options_.plot_priors = true; |
| 409 |
|
| 410 |
|
| 411 |
estimation(datafile='usdata_pkf', |
| 412 |
nobs=210, |
| 413 |
first_obs=74, |
| 414 |
use_univariate_filters_if_singularity_is_detected=0, |
| 415 |
mh_replic=0, |
| 416 |
mode_compute=0, |
| 417 |
mode_file = 'swpkfest_mh_mode', |
| 418 |
posterior_sampling_method='slice', |
| 419 |
mh_nblocks=4, |
| 420 |
mh_drop=0.5, |
| 421 |
presample = 20, |
| 422 |
nodisplay, |
| 423 |
graph_format=(eps,fig), |
| 424 |
filter_covariance, smoothed_state_uncertainty, |
| 425 |
smoother, smoother_redux,consider_all_endogenous); |
| 426 |
|
| 427 |
load swpkfest_mh_mode.mat fval xparam1; |
| 428 |
|
| 429 |
if abs(cli.evaluate.posterior_kernel(xparam1)-fval)>1.e-10 |
| 430 |
error('Computed PKF postrior kernel at the mode is not recovered!') |
| 431 |
else |
| 432 |
disp('Computed PKF posterior kernel at the mode is recovered!') |
| 433 |
cli.evaluate.posterior_kernel(xparam1) |
| 434 |
end |
| 435 |
|
| 436 |
//triggers PPF |
| 437 |
disp('PPF posterior kernel at the mode') |
| 438 |
options_.occbin.filter.particle.status=true; |
| 439 |
cli.evaluate.posterior_kernel(xparam1) |
| 440 |
|
| 441 |
//triggers diagnostic plots with PPF |
| 442 |
disp('PPF diagnostic plots') |
| 443 |
options_.occbin.filter.particle.diagnostics.graph_periods=[172]; |
| 444 |
options_.occbin.filter.particle.diagnostics.nograph=false; |
| 445 |
options_.occbin.filter.particle.diagnostics.status=true; |
| 446 |
cli.evaluate.posterior_kernel(xparam1) |
| 447 |
options_.occbin.filter.particle.diagnostics.nograph=true; |
| 448 |
options_.occbin.filter.particle.diagnostics.status=false; |
| 449 |
|
| 450 |
// posterior importance sampling using ppf starting from pkf draws |
| 451 |
options_.occbin.posterior_importance_sampling.status = true; |
| 452 |
options_.occbin.posterior_importance_sampling.sub_draws = 6; // set to 600 to use all draws |
| 453 |
options_.occbin.posterior_importance_sampling.filter = 'ppf'; % can be pkf or ppf |
| 454 |
options_.occbin.posterior_importance_sampling.orig_dname = 'swpkfest'; |
| 455 |
options_.occbin.posterior_importance_sampling.orig_fname = 'swpkfest'; |
| 456 |
options_.occbin.posterior_importance_sampling.orig_filter = 'pkf'; % can be linear or pkf |
| 457 |
oo_ = occbin.posterior_importance_sampling(M_, estim_params_, oo_, options_, bayestopt_); |
| 458 |
|
| 459 |
collect_latex_files; |
| 460 |
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']); |
| 461 |
if status |
| 462 |
cmdout |
| 463 |
error('TeX-File did not compile.') |
| 464 |
end |