Skip to content

Commit

Permalink
ready to retrain nets for DSGE
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Creel committed Jun 3, 2024
1 parent e80e786 commit 5fa1e98
Show file tree
Hide file tree
Showing 1,093 changed files with 162,178 additions and 162,128 deletions.
75 changes: 75 additions & 0 deletions Examples/DSGE/Bayesian/CK.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Dynare version: 0.9.12
2024-06-01T09:59:22.812: Starting @dynare CK.mod
["CK.mod", "language=julia", "json=compute"]
Dynare preprocessor version: 6.4.0+0
2024-06-01T09:59:22.820: End of preprocessing
2024-06-01T09:59:22.827: Start parse_statements!
* Status: success

* Candidate solution
Final objective value: -9.217020e+02

* Found with
Algorithm: BFGS

* Convergence measures
|x - x'| = 3.08e-03 ≰ 0.0e+00
|x - x'|/|x'| = 1.15e-03 ≰ 0.0e+00
|f(x) - f(x')| = 4.02e-05 ≰ 0.0e+00
|f(x) - f(x')|/|f(x')| = 4.37e-08 ≤ 1.0e-05
|g(x)| = 8.58e-02 ≰ 1.0e-08

* Work counters
Seconds run: 1 (vs limit Inf)
Iterations: 13
f(x) calls: 39
∇f(x) calls: 39

Posterior mode

───────────┬──────────────────────────────────────────────────────────
Parameter │ Estimated value Standard error 80% confidence interval
──────────────────────────────────────────────────────────────────────
betta │ 0.992 0.0015 0.9901 .. 0.9939
gam │ 1.9146 0.1794 1.685 .. 2.1442
rho1 │ 0.9207 0.0078 0.9107 .. 0.9308
sigma1 │ 0.0216 0.0014 0.0198 .. 0.0233
rho2 │ 0.5794 0.0697 0.4902 .. 0.6686
sigma2 │ 0.009 0.0005 0.0083 .. 0.0097
nss │ 0.3294 0.0022 0.3265 .. 0.3323
───────────┴──────────────────────────────────────────────────────────

Chains MCMC chain (20000×8×1 Array{Float64, 3}):

Iterations = 1:1:20000
Number of chains = 1
Samples per chain = 20000
parameters = betta, gam, rho1, sigma1, rho2, sigma2, nss
internals = lp

Summary Statistics
parameters mean std mcse ess_bulk ess_tail rhat ess_per_sec
Symbol Float64 Float64 Float64 Float64 Float64 Float64 Missing

betta 0.9919 0.0001 0.0000 42.6577 69.6404 2.0742 missing
gam 1.9236 0.1384 0.0128 115.1382 421.7060 1.0545 missing
rho1 0.9188 0.0098 0.0014 51.0250 62.7307 1.0319 missing
sigma1 0.0207 0.0007 0.0001 44.3294 62.7245 1.0469 missing
rho2 0.5994 0.0592 0.0031 350.2670 647.3667 1.0032 missing
sigma2 0.0090 0.0002 0.0000 43.2730 65.2541 1.3036 missing
nss 0.3296 0.0007 0.0001 51.7295 85.7004 1.4124 missing

Quantiles
parameters 2.5% 25.0% 50.0% 75.0% 97.5%
Symbol Float64 Float64 Float64 Float64 Float64

betta 0.9917 0.9918 0.9919 0.9919 0.9920
gam 1.6781 1.8249 1.9155 2.0115 2.2162
rho1 0.9010 0.9113 0.9185 0.9258 0.9380
sigma1 0.0195 0.0201 0.0206 0.0212 0.0221
rho2 0.4818 0.5594 0.6016 0.6419 0.7075
sigma2 0.0087 0.0088 0.0089 0.0091 0.0094
nss 0.3283 0.3291 0.3296 0.3300 0.3310

2024-06-01T09:59:39.931: End parse_statements!
2024-06-01T09:59:39.931: End parser
2 changes: 1 addition & 1 deletion Examples/DSGE/Bayesian/CK.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ end;
// you may need to change mh_jscale to get good acceptance rate

varobs c n; // experiment choosing one or two from y c n r w
estimation(order=1, datafile='dsgedata.csv', mh_replic=20000, mh_nblocks=4, mh_jscale=2.) ;
estimation(order=1, datafile='dsgedata.csv', mh_replic=20000, mh_nblocks=4, mh_jscale=5.) ;

//varobs y n; // experiment choosing one or two from y c n r w
//estimation(order=1, datafile='dsgedata.csv', mh_replic=20000, mh_nblocks=4, mh_jscale=5.) ;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Examples/DSGE/Bayesian/CK/graphs/Priors_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Examples/DSGE/Bayesian/CK/model/bytecode/dynamic.bin
Binary file not shown.
Binary file not shown.
Binary file added Examples/DSGE/Bayesian/CK/model/bytecode/static.bin
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/DynamicParamsDerivs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NB: this file was automatically generated by Dynare
# from CK.mod
#
function dynamic_params_derivs(y, x, params, steady_state, it_,ss_param_deriv, ss_param_2nd_deriv)
@inbounds begin
T = zeros(0)
rp = zeros(11, 15);
gp = zeros(11, 19, 15);
end
return (rp, gp)
end
45 changes: 45 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseDynamicG1!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function SparseDynamicG1!(T::Vector{<: Real}, g1_v::Vector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, steady_state::Vector{<: Real})
@assert length(T) >= 6
@assert length(g1_v) == 34
@assert length(y) == 33
@assert length(x) == 2
@assert length(params) == 15
@inbounds begin
g1_v[1]=(-(1-params[3]));
g1_v[2]=(-1);
g1_v[3]=(-params[6]);
g1_v[4]=(-params[8]);
g1_v[5]=1;
g1_v[6]=(-1);
g1_v[7]=(-(get_power_deriv(y[13],(-params[4]),1)));
g1_v[8]=1;
g1_v[9]=(-(T[2]*params[1]*exp(y[17])*get_power_deriv(y[14],params[1]-1,1)));
g1_v[10]=(-(T[4]*exp(y[17])*(1-params[1])*T[5]));
g1_v[11]=(-(T[2]*exp(y[17])*T[5]));
g1_v[12]=1;
g1_v[13]=(-(T[1]*T[6]));
g1_v[14]=(-(exp(y[17])*(1-params[1])*T[3]*get_power_deriv(y[15],(-params[1]),1)));
g1_v[15]=(-(exp(y[17])*T[3]*T[6]));
g1_v[16]=1;
g1_v[17]=(-(T[1]*T[2]));
g1_v[18]=(-(exp(y[17])*(1-params[1])*T[3]*T[4]));
g1_v[19]=1;
g1_v[20]=(-(T[2]*exp(y[17])*T[3]));
g1_v[21]=(-(params[10]*exp(y[18])));
g1_v[22]=1;
g1_v[23]=1;
g1_v[24]=1;
g1_v[25]=(-y[20])/(y[19]*y[19]);
g1_v[26]=1;
g1_v[27]=1/y[19];
g1_v[28]=1;
g1_v[29]=1;
g1_v[30]=(-1);
g1_v[31]=(-(params[2]*(1+y[32]-params[3])));
g1_v[32]=(-(params[2]*y[30]));
g1_v[33]=(-params[7]);
g1_v[34]=(-params[9]);
end
return nothing
end

9 changes: 9 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseDynamicG1TT!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function SparseDynamicG1TT!(T::Vector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, steady_state::Vector{<: Real})
SparseDynamicResidTT!(T, y, x, params, steady_state)
@inbounds begin
T[5] = get_power_deriv(y[14],params[1],1)
T[6] = get_power_deriv(y[15],1-params[1],1)
end
return nothing
end

22 changes: 22 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseDynamicResid!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function SparseDynamicResid!(T::Vector{<: Real}, residual::AbstractVector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, steady_state::Vector{<: Real})
@assert length(T) >= 4
@assert length(residual) == 11
@assert length(y) == 33
@assert length(x) == 2
@assert length(params) == 15
@inbounds begin
residual[1] = (y[19]) - (y[13]^(-params[4]));
residual[2] = (y[20]) - (params[10]*exp(y[18]));
residual[3] = (y[21]) - (T[1]*T[2]);
residual[4] = (y[22]) - (exp(y[17])*(1-params[1])*T[3]*T[4]);
residual[5] = (y[19]) - (params[2]*y[30]*(1+y[32]-params[3]));
residual[6] = (y[20]/y[19]) - (y[22]);
residual[7] = (y[17]) - (params[6]*y[6]+params[7]*x[1]);
residual[8] = (y[18]) - (params[8]*y[7]+params[9]*x[2]);
residual[9] = (y[12]) - (T[2]*exp(y[17])*T[3]);
residual[10] = (y[16]) - (y[12]-y[13]);
residual[11] = (y[14]) - (y[5]+(1-params[3])*y[3]);
end
return nothing
end

10 changes: 10 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseDynamicResidTT!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function SparseDynamicResidTT!(T::Vector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real}, steady_state::Vector{<: Real})
@inbounds begin
T[1] = params[1]*exp(y[17])*y[14]^(params[1]-1)
T[2] = y[15]^(1-params[1])
T[3] = y[14]^params[1]
T[4] = y[15]^(-params[1])
end
return nothing
end

42 changes: 42 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseStaticG1!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function SparseStaticG1!(T::Vector{<: Real}, g1_v::Vector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real})
@assert length(T) >= 6
@assert length(g1_v) == 28
@assert length(y) == 11
@assert length(x) == 2
@assert length(params) == 15
@inbounds begin
g1_v[1]=1;
g1_v[2]=(-1);
g1_v[3]=(-(get_power_deriv(y[2],(-params[4]),1)));
g1_v[4]=1;
g1_v[5]=(-(T[2]*params[1]*exp(y[6])*get_power_deriv(y[3],params[1]-1,1)));
g1_v[6]=(-(T[4]*exp(y[6])*(1-params[1])*T[5]));
g1_v[7]=(-(T[2]*exp(y[6])*T[5]));
g1_v[8]=1-(1-params[3]);
g1_v[9]=(-(T[1]*T[6]));
g1_v[10]=(-(exp(y[6])*(1-params[1])*T[3]*get_power_deriv(y[4],(-params[1]),1)));
g1_v[11]=(-(exp(y[6])*T[3]*T[6]));
g1_v[12]=1;
g1_v[13]=(-1);
g1_v[14]=(-(T[1]*T[2]));
g1_v[15]=(-(exp(y[6])*(1-params[1])*T[3]*T[4]));
g1_v[16]=1-params[6];
g1_v[17]=(-(T[2]*exp(y[6])*T[3]));
g1_v[18]=(-(params[10]*exp(y[7])));
g1_v[19]=1-params[8];
g1_v[20]=1;
g1_v[21]=1-params[2]*(1+y[10]-params[3]);
g1_v[22]=(-y[9])/(y[8]*y[8]);
g1_v[23]=1;
g1_v[24]=1/y[8];
g1_v[25]=1;
g1_v[26]=(-(y[8]*params[2]));
g1_v[27]=1;
g1_v[28]=(-1);
end
if ~isreal(g1_v)
g1_v = real(g1_v)+2*imag(g1_v);
end
return nothing
end

9 changes: 9 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseStaticG1TT!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function SparseStaticG1TT!(T::Vector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real})
SparseStaticResidTT!(T, y, x, params)
@inbounds begin
T[5] = get_power_deriv(y[3],params[1],1)
T[6] = get_power_deriv(y[4],1-params[1],1)
end
return nothing
end

25 changes: 25 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseStaticResid!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function SparseStaticResid!(T::Vector{<: Real}, residual::AbstractVector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real})
@assert length(T) >= 4
@assert length(residual) == 11
@assert length(y) == 11
@assert length(x) == 2
@assert length(params) == 15
@inbounds begin
residual[1] = (y[8]) - (y[2]^(-params[4]));
residual[2] = (y[9]) - (params[10]*exp(y[7]));
residual[3] = (y[10]) - (T[1]*T[2]);
residual[4] = (y[11]) - (exp(y[6])*(1-params[1])*T[3]*T[4]);
residual[5] = (y[8]) - (y[8]*params[2]*(1+y[10]-params[3]));
residual[6] = (y[9]/y[8]) - (y[11]);
residual[7] = (y[6]) - (y[6]*params[6]+params[7]*x[1]);
residual[8] = (y[7]) - (y[7]*params[8]+params[9]*x[2]);
residual[9] = (y[1]) - (T[2]*exp(y[6])*T[3]);
residual[10] = (y[5]) - (y[1]-y[2]);
residual[11] = (y[3]) - (y[5]+y[3]*(1-params[3]));
end
if ~isreal(residual)
residual = real(residual)+imag(residual).^2;
end
return nothing
end

10 changes: 10 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SparseStaticResidTT!.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function SparseStaticResidTT!(T::Vector{<: Real}, y::Vector{<: Real}, x::Vector{<: Real}, params::Vector{<: Real})
@inbounds begin
T[1] = params[1]*exp(y[6])*y[3]^(params[1]-1)
T[2] = y[4]^(1-params[1])
T[3] = y[3]^params[1]
T[4] = y[4]^(-params[1])
end
return nothing
end

11 changes: 11 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/StaticParamsDerivs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NB: this file was automatically generated by Dynare
# from CK.mod
#
function static_params_derivs(y, x, params)
@inbounds begin
T = zeros(0)
rp = zeros(11, 15);
gp = zeros(11, 11, 15);
end
return (rp, gp)
end
25 changes: 25 additions & 0 deletions Examples/DSGE/Bayesian/CK/model/julia/SteadyState2.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# NB: this file was automatically generated by Dynare
# from CK.mod
#
function steady_state!(ys_::Vector{<: Real}, exo_::Vector{<: Real}, params::Vector{<: Real})
@inbounds begin
params[11]=((1/params[2]+params[3]-1)/params[1])^(1/(1-params[1]));
params[14]=params[5]/params[11];
params[12]=params[3]*params[14];
params[13]=params[14]^params[1]*params[5]^(1-params[1]);
params[15]=params[13]-params[12];
params[10]=params[14]^params[1]*(1-params[1])*params[15]^(-params[4])*params[5]^(-params[1]);
ys_[3]=params[14];
ys_[4]=params[5];
ys_[2]=params[15];
ys_[1]=params[13];
ys_[5]=params[12];
ys_[8]=ys_[2]^(-params[4]);
ys_[10]=params[1]*ys_[3]^(params[1]-1)*ys_[4]^(1-params[1]);
ys_[11]=(1-params[1])*ys_[3]^params[1]*ys_[4]^(-params[1]);
ys_[9]=ys_[8]*ys_[11];
ys_[6]=0;
ys_[7]=0;
# Auxiliary equations
end
end
Binary file added Examples/DSGE/Bayesian/CK/output/CK.jls
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Examples/DSGE/Bayesian/CK/output/mcmc_chain_1.jls
Binary file not shown.
4 changes: 2 additions & 2 deletions Examples/DSGE/Bayesian/Estimate.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Dynare, Serialization, Statistics

context = @dynare "CK.mod"
cd(@__DIR__)
context = @dynare "CK.mod" ;

chain = deserialize("CK/output/mcmc_chain_1.jls")
mean(chain.value[:,1:end-1],dims=1)
Binary file modified Examples/DSGE/Bayesian/MCMC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Examples/DSGE/Bayesian/MCMC2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Examples/DSGE/Bayesian/MonteCarlo/MonteCarlo.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Dynare version: 0.9.12
2024-06-01T10:13:41.212: Starting @dynare MonteCarlo.mod
["MonteCarlo.mod", "language=julia", "json=compute"]
Dynare preprocessor version: 6.4.0+0
2024-06-01T10:13:41.267: End of preprocessing
2024-06-01T10:13:41.327: Start parse_statements!
* Status: success

* Candidate solution
Final objective value: -1.227896e+03

* Found with
Algorithm: BFGS

* Convergence measures
|x - x'| = 1.03e-02 ≰ 0.0e+00
|x - x'|/|x'| = 2.99e-03 ≰ 0.0e+00
|f(x) - f(x')| = 4.02e-04 ≰ 0.0e+00
|f(x) - f(x')|/|f(x')| = 3.27e-07 ≤ 1.0e-05
|g(x)| = 5.71e-02 ≰ 1.0e-08

* Work counters
Seconds run: 0 (vs limit Inf)
Iterations: 14
f(x) calls: 41
∇f(x) calls: 41

Posterior mode

───────────┬──────────────────────────────────────────────────────────
Parameter │ Estimated value Standard error 80% confidence interval
──────────────────────────────────────────────────────────────────────
betta │ 0.9935 0.0014 0.9917 .. 0.9953
gam │ 1.9923 0.1345 1.8201 .. 2.1645
rho1 │ 0.9094 0.0064 0.9012 .. 0.9175
sigma1 │ 0.0228 0.0016 0.0208 .. 0.0249
rho2 │ 0.7264 0.0498 0.6626 .. 0.7902
sigma2 │ 0.0084 0.0008 0.0074 .. 0.0094
nss │ 0.3314 0.0015 0.3294 .. 0.3333
───────────┴──────────────────────────────────────────────────────────

Loading

0 comments on commit 5fa1e98

Please sign in to comment.