Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
  • chskcau/dynare-doc-fixes
27 results
Select Git revision
Loading items
Show changes
......@@ -83,7 +83,7 @@ method_of_moments(mom_method = irf_matching
%, mode_check_neighbourhood_size
%, mode_check_number_of_points
, mode_check_symmetric_plots = 0
, mode_compute = 1
, mode_compute = 4
, mode_file = cet_original_mode
%, nobs
%, no_posterior_kernel_density
......
......@@ -192,7 +192,7 @@ method_of_moments(mom_method = irf_matching
, mh_replic=10
, plot_priors = 0
, nograph
, mode_compute = 1
, mode_compute = 5
, posterior_sampling_method = 'slice'
, posterior_sampler_options = ('rotated',1
% ,'mode_files'
......
......@@ -156,14 +156,14 @@ method_of_moments(mom_method = irf_matching
method_of_moments(mom_method = irf_matching
, additional_optimizer_steps = [1]
, additional_optimizer_steps = [4]
, cova_compute=1
, dirname=cet_tarb_results
, irf_matching_file = cet_irf_matching_file
, mh_conf_sig = 0.90
, mh_replic=0
%, mode_check
, mode_compute = 4
, mode_compute = 5
, mode_file = 'cet_tarb_results/method_of_moments/cet_tarb_mh_mode'
, plot_priors = 0
, nograph
......
......@@ -77,12 +77,12 @@ send_endogenous_variables_to_workspace;
options_.nomoments=0;
oo_unfiltered_all_shocks=oo_;
[junk, y_filtered]=sample_hp_filter(y',1600);
[junk, c_filtered]=sample_hp_filter(c',1600);
[junk, k_filtered]=sample_hp_filter(k',1600);
[junk, a_filtered]=sample_hp_filter(a',1600);
[junk, h_filtered]=sample_hp_filter(h',1600);
[junk, b_filtered]=sample_hp_filter(b',1600);
[junk, y_filtered]=sample_hp_filter(y,1600);
[junk, c_filtered]=sample_hp_filter(c,1600);
[junk, k_filtered]=sample_hp_filter(k,1600);
[junk, a_filtered]=sample_hp_filter(a,1600);
[junk, h_filtered]=sample_hp_filter(h,1600);
[junk, b_filtered]=sample_hp_filter(b,1600);
verbatim;
total_std_all_shocks_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered]);
......@@ -112,12 +112,12 @@ stoch_simul(order=1,nofunctions,hp_filter=0,periods=2500000,nomoments);
send_endogenous_variables_to_workspace;
oo_unfiltered_one_shock=oo_;
[junk, y_filtered]=sample_hp_filter(y',1600);
[junk, c_filtered]=sample_hp_filter(c',1600);
[junk, k_filtered]=sample_hp_filter(k',1600);
[junk, a_filtered]=sample_hp_filter(a',1600);
[junk, h_filtered]=sample_hp_filter(h',1600);
[junk, b_filtered]=sample_hp_filter(b',1600);
[junk, y_filtered]=sample_hp_filter(y,1600);
[junk, c_filtered]=sample_hp_filter(c,1600);
[junk, k_filtered]=sample_hp_filter(k,1600);
[junk, a_filtered]=sample_hp_filter(a,1600);
[junk, h_filtered]=sample_hp_filter(h,1600);
[junk, b_filtered]=sample_hp_filter(b,1600);
verbatim;
total_std_one_shock_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered]);
......
......@@ -13,66 +13,66 @@
// ----------------- Defintions -----------------------------------------//
var
c //1 Consumption
n //2 Labor
y //5 Output
yf //6 Final goods
yg //11 Output growth gap
w //12 Real wage rate
wf //13 Flexible real wage
pigap //15 Inflation rate -> pi(t)/pibar = pigap
inom ${i^{nom}}$ //16 Nominal interest rate
inomnot //17 Notional interest rate
mc //19 Real marginal cost
lam ${\lambda}$ //20 Inverse marginal utility of wealth
g //21 Growth shock
s //22 Risk premium shock
mp //23 Monetary policy shock
pi ${\pi}$ //24 Observed inflation
c $c$ (long_name='Consumption')
n (long_name='Labor')
y $y$ (long_name='Output')
yf (long_name='Final goods')
yg (long_name='Output growth gap')
w (long_name='Real wage rate')
wf (long_name='Flexible real wage')
pigap (long_name='Inflation rate -> pi(t)/pibar = pigap')
inom ${i^{nom}}$ (long_name='Nominal interest rate')
inomnot (long_name='Notional interest rate')
mc (long_name='Real marginal cost')
lam ${\lambda}$ (long_name='Inverse marginal utility of wealth')
g (long_name='Growth shock')
s (long_name='Risk premium shock')
mp (long_name='Monetary policy shock')
pi ${\pi}$ (long_name='Observed inflation')
@#if !(small_model)
x //3 Investment
k //4 Capital
u //7 Utilization cost
ups //8 Utilization choice
wg //9 Real wage growth gap
xg //10 Investment growth
rk //14 Real rental rate
q //18 Tobins q
x (long_name='Investment')
k (long_name='Capital')
u (long_name='Utilization cost')
ups (long_name='Utilization choice')
wg (long_name='Real wage growth gap')
xg (long_name='Investment growth')
rk (long_name='Real rental rate')
q (long_name='Tobins q')
@#endif
;
varexo
epsg ${\varepsilon_g}$ // Productivity growth shock
epsi // Notional interest rate shock
epss // Risk premium shock
epsg ${\varepsilon_g}$ (long_name='Productivity growth shock')
epsi (long_name='Notional interest rate shock')
epss (long_name='Risk premium shock')
;
parameters
// Calibrated Parameters
beta $\beta$ // Discount factor
chi // Labor disutility scale
thetap // Elasticity of subs. between intermediate goods
thetaw // Elasticity of subs. between labor types
nbar // Steady state labor
eta // Inverse frish elasticity of labor supply
delta // Depreciation
alpha // Capital share
gbar // Mean growth rate
pibar // Inflation target
inombar // Steady gross nom interest rate
inomlb // Effective lower bound on gross nominal interest rate
sbar // Average risk premium
beta $\beta$ (long_name='Discount factor')
chi (long_name='Labor disutility scale')
thetap (long_name='Elasticity of subs. between intermediate goods')
thetaw (long_name='Elasticity of subs. between labor types')
nbar (long_name='Steady state labor')
eta (long_name='Inverse frish elasticity of labor supply')
delta (long_name='Depreciation')
alpha (long_name='Capital share')
gbar (long_name='Mean growth rate')
pibar (long_name='Inflation target')
inombar (long_name='Steady gross nom interest rate')
inomlb (long_name='Effective lower bound on gross nominal interest rate')
sbar (long_name='Average risk premium')
// Parameters for DGP and Estimated parameters
varphip // Rotemberg price adjustment cost
varphiw // Rotemberg wage adjustment cost
h // Habit persistence
rhos // Persistence
rhoi // Persistence
sigz // Standard deviation technology
sigs // Standard deviation risk premia
sigi // Standard deviation mon pol
phipi // Inflation responsiveness
phiy // Output responsiveness
nu // Investment adjustment cost
sigups // Utilization
varphip (long_name='Rotemberg price adjustment cost')
varphiw (long_name='Rotemberg wage adjustment cost')
h (long_name='Habit persistence')
rhos (long_name='Persistence')
rhoi (long_name='Persistence')
sigz (long_name='Standard deviation technology')
sigs (long_name='Standard deviation risk premia')
sigi (long_name='Standard deviation mon pol')
phipi (long_name='Inflation responsiveness')
phiy (long_name='Output responsiveness')
nu (long_name='Investment adjustment cost')
sigups (long_name='Utilization')
;
......@@ -316,36 +316,34 @@ varobs yg inom pi;
// forecast starting from period 42, zero shocks (default)
smoother2histval(period=42);
[oo, error_flag] = occbin.forecast(options_,M_,oo_,8);
[forecast, error_flag] = occbin.forecast(options_,M_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,8);
// forecast with stochastic shocks
options_.occbin.forecast.qmc=true;
options_.occbin.forecast.replic=127;
[oo1, error_flag] = occbin.forecast(options_,M_,oo_,8);
[forecast1, error_flag] = occbin.forecast(options_,M_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,8);
figure('Name','OccBin: Forecasts')
subplot(2,1,1)
plot(1:8,forecast.piecewise.Mean.inom,'b-',1:8,forecast1.piecewise.Mean.inom,'r--')
subplot(2,1,2)
plot(1:8,forecast.piecewise.Mean.y,'b-',1:8,forecast1.piecewise.Mean.y,'r--')
// GIRF given states in 42 and shocks in 43
t0=42;
options_.occbin.irf.exo_names=M_.exo_names;
options_.occbin.irf.t0=t0;
oo_ = occbin.irf(M_,oo_,options_);
vars_irf = {
'c', 'consumption'
'n', 'labor'
'y', 'output'
'pigap', 'inflation rate'
'inom', 'interest rate'
'inomnot', 'shadow rate'
};
options_.occbin.plot_irf.exo_names = M_.exo_names;
options_.occbin.plot_irf.endo_names = vars_irf(:,1);
options_.occbin.plot_irf.endo_names_long = vars_irf(:,2);
oo_.occbin.irfs = occbin.irf(M_,oo_,options_);
var_list_ = {'c','n','y','pigap','inom','inomnot'};
// if you want to scale ...
// options_occbin_.plot_irf.endo_scaling_factor = vars_irf(:,3);
options_.occbin.plot_irf.simulname = ['t0_' int2str(t0)];
options_.occbin.plot_irf.tplot = min(40,options_.irf);
occbin.plot_irfs(M_,oo_,options_);
options_.irf=40;
occbin.plot_irfs(M_,oo_.occbin.irfs,options_,var_list_);
var_list_={};
options_.occbin.plot_irf.simulname = ['t0_' int2str(t0) '_full'];
occbin.plot_irfs(M_,oo_.occbin.irfs,options_,var_list_);
oo0=oo_;
// use smoother_redux
estimation(
......@@ -374,7 +372,7 @@ varobs yg inom pi;
consider_all_endogenous,heteroskedastic_filter,filter_step_ahead=[1],smoothed_state_uncertainty);
// show initial condition effect of IF
figure,
figure('Name','OccBin: Smoothed shocks')
subplot(221)
plot([oo0.SmoothedShocks.epsg oo_.SmoothedShocks.epsg]), title('epsg')
subplot(222)
......@@ -382,7 +380,7 @@ varobs yg inom pi;
subplot(223)
plot([oo0.SmoothedShocks.epss oo_.SmoothedShocks.epss]), title('epss')
legend('PKF','IF')
figure,
figure('Name','OccBin: Smoothed Variables')
subplot(221)
plot([oo0.SmoothedVariables.inom oo_.SmoothedVariables.inom]), title('inom')
subplot(222)
......
//MODEL:
//test on Dynare to find the lagrangean multipliers.
//We consider a standard NK model. We use the FOCS of the competitive economy and we aim at calculating the Ramsey optimal problem.
//------------------------------------------------------------------------------------------------------------------------
//1. Variable declaration
//------------------------------------------------------------------------------------------------------------------------
var pai, c, n, r, a;
//4 variables + 1 shock
varexo u;
//------------------------------------------------------------------------------------------------------------------------
// 2. Parameter declaration and calibration
//-------------------------------------------------------------------------------------------------------------------------
parameters beta, rho, epsilon, omega, phi, gamma;
beta=0.99;
gamma=3; //Frish elasticity
omega=17; //price stickyness
epsilon=8; //elasticity for each variety of consumption
phi=1; //coefficient associated to labor effort disutility
rho=0.95; //coefficient associated to productivity shock
//-----------------------------------------------------------------------------------------------------------------------
// 3. The model
//-----------------------------------------------------------------------------------------------------------------------
model(bytecode);
a=rho*(a(-1))+u;
1/c=beta*(1/(c(+1)))*(r/(pai(+1))); //euler
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
(exp(a))*n=c+(omega/2)*((pai-1)^2);
end;
//--------------------------------------------------------------------------------------------------------------------------
// 4. Steady state
//---------------------------------------------------------------------------------------------------------------------------
initval;
pai=1;
r=1/beta;
c=0.9671684882;
n=0.9671684882;
a=0;
end;
//---------------------------------------------------------------------------------------------------------------------------
// 5. shocks
//---------------------------------------------------------------------------------------------------------------------------
shocks;
var u;
periods 1;
values 0.008;
end;
//--------------------------------------------------------------------------------------------------------------------------
// 6. Ramsey problem
//--------------------------------------------------------------------------------------------------------------------------
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
write_latex_static_model;
ramsey_model(planner_discount=0.99);
steady;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=20);
rplot r;
source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']);
dynare_config;
testFailed = 0;
skipline()
disp('*** TESTING: riccatiupdate.m ***');
t0 = clock;
% Set the number of experiments for time measurement
N = 5000;
% Set the dimension of the problem to be solved.
r = 50;
n = 100;
tol = 1e-15;
% Set the input arguments
% P, Q: use the fact that for any real matrix A, A'*A is positive semidefinite
P = rand(n,r);
P = P'*P;
Q = rand(n,r);
Q = Q'*Q;
K = rand(r,n);
Z = rand(n,r);
T = rand(r,r);
% Computing an upperbound for the norm the updated variance-covariance matrix
ub = norm(T,1)^2*norm(P,1)*(1+norm(K*Z,1))+norm(Q,1);
% Weighting the P and Q matrices to keep the norm of the variance-covariance matrix below 1
P = 0.5*P/ub;
Q = 0.5*Q/ub;
% 1. Update the state vairance-covariance matrix with Matlab
tElapsed1 = 0.;
tic;
for i=1:N
Ptmp_matlab = T*(P-K*Z*P)*transpose(T)+Q;
end
tElapsed1 = toc;
disp(['Elapsed time for the Matlab Riccati update is: ' num2str(tElapsed1) ' (N=' int2str(N) ').'])
% 2. Update the state varance-covariance matrix with the mex routine
tElapsed2 = 0.;
Ptmp_fortran = P;
try
tic;
for i=1:N
Ptmp_fortran = riccati_update(P, T, K, Z, Q);
end
tElapsed2 = toc;
disp(['Elapsed time for the Fortran Riccati update is: ' num2str(tElapsed2) ' (N=' int2str(N) ').'])
R = norm(Ptmp_fortran-Ptmp_matlab,1);
if (R > tol)
testFailed = testFailed+1;
dprintf('The Fortran Riccati update is wrong')
end
catch
testFailed = testFailed+1;
dprintf('Fortran Riccati update failed')
end
% Compare the Fortran and Matlab execution time
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab Riccati update is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran Riccati update is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
% Compare results after multiple calls
N = 50;
disp(['After 1 update using the Riccati formula, the norm-1 discrepancy is ' num2str(norm(Ptmp_fortran-Ptmp_matlab,1)) '.']);
for i=2:N
Ptmp_matlab = T*(Ptmp_matlab-K*Z*Ptmp_matlab)*transpose(T)+Q;
Ptmp_fortran = riccati_update(Ptmp_fortran, T, K, Z, Q);
disp(['After ' int2str(i) ' updates using the Riccati formula, the norm-1 discrepancy is ' num2str(norm(Ptmp_fortran-Ptmp_matlab,1)) '.'])
end
t1 = clock;
fprintf('\n*** Elapsed time (in seconds): %.1f\n\n', etime(t1, t0));
quit(testFailed > 0)
......@@ -5,7 +5,7 @@
# The binaries are cross compiled for Windows (64-bit), Octave and MATLAB
# (all supported versions).
# Copyright © 2017-2023 Dynare Team
# Copyright © 2017-2024 Dynare Team
#
# This file is part of Dynare.
#
......@@ -127,8 +127,8 @@ mkdir "$ZIPDIR"/preprocessor
cp -p build-win-matlab/preprocessor/src/dynare-preprocessor.exe "$ZIPDIR"/preprocessor
cp -pr matlab "$ZIPDIR"
cp -p build-win-matlab/dynare_version.m "$ZIPDIR"/matlab
mkdir -p "$ZIPDIR"/matlab/modules/dseries/externals/x13/windows/64
cp -p windows/deps/lib64/x13as/x13as.exe "$ZIPDIR"/matlab/modules/dseries/externals/x13/windows/64
mkdir -p "$ZIPDIR"/matlab/dseries/externals/x13/windows/64
cp -p windows/deps/lib64/x13as/x13as.exe "$ZIPDIR"/matlab/dseries/externals/x13/windows/64
cp -pr examples "$ZIPDIR"
mkdir -p "$ZIPDIR"/scripts
cp -p scripts/dynare.el "$ZIPDIR"/scripts
......
......@@ -157,7 +157,8 @@ mingw64: tarballs/mingw-w64-x86_64-gcc-$(MINGW64_GCC_VERSION)-any.pkg.tar.zst ta
touch $@
tarballs/mingw-w64-x86_64-%-any.pkg.tar.zst:
wget $(WGET_OPTIONS) -O $@ http://repo.msys2.org/mingw/x86_64/$(notdir $@)
mkdir -p tarballs
wget $(WGET_OPTIONS) -O $@ https://www.dynare.org/windows-pkg-build/msys2/6.x/$(notdir $@)
clean-msys2:
rm -rf lib64-msys2
......
......@@ -52,7 +52,7 @@ Section "Dynare core (preprocessor and M-files)"
File README.txt ..\NEWS.md ..\license.txt
SetOutPath $INSTDIR\matlab
File /r ..\matlab\*.m ..\build-win-matlab\dynare_version.m
File /r ..\matlab\*.m ..\matlab\*.json ..\build-win-matlab\dynare_version.m
SetOutPath $INSTDIR\preprocessor
File ..\build-win-matlab\preprocessor\src\dynare-preprocessor.exe
......@@ -60,7 +60,7 @@ Section "Dynare core (preprocessor and M-files)"
SetOutPath $INSTDIR\matlab\preprocessor64
File ..\matlab\preprocessor64\dynare_m.exe
SetOutPath $INSTDIR\matlab\modules\dseries\externals\x13\windows\64
SetOutPath $INSTDIR\matlab\dseries\externals\x13\windows\64
File deps\lib64\x13as\x13as.exe
SetOutPath $INSTDIR\contrib
......