Skip to content

Commit

Permalink
test write_to_dynare
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Sep 30, 2023
1 parent 5b17d5b commit 1371120
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/src/unfinished_docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## High priority

- [ ] implement occasionally binding constraints with shocks
- [ ] check if higher order effects might distort results for autocorr (problem with order deffinition)
- [ ] recheck function examples and docs (include output description)
- [ ] riccati with analytical derivatives (much faster if sparse) instead of implicit diff
- [ ] autocorr and covariance with derivatives. return 3d array
Expand Down Expand Up @@ -65,6 +64,7 @@
- [ ] Find any SS by optimising over both SS guesses and parameter inputs
- [ ] weed out SS solver and saved objects

- [x] check if higher order effects might distort results for autocorr (problem with order deffinition) - doesnt seem to be the case; full_covar yields same result
- [x] write parameter equations to dynare (take ordering on board)
- [x] pruning of 3rd order takes pruned 2nd order input
- [x] implement moment matching for pruned models
Expand Down
9 changes: 0 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ if test_higher_order
GC.gc()
end


@testset verbose = true "Test dynare read/write" begin
include("models/FS2000.jl")
write_to_dynare_file(m)
translate_mod_file("m.mod")
end
m = nothing
GC.gc()

# @testset verbose = true "Code formatting (JuliaFormatter.jl)" begin
# @test format(MacroModelling; verbose=true, overwrite=true)
# end
Expand Down
14 changes: 14 additions & 0 deletions test/test_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var_dec = get_var_decomp(Backus_Kehoe_Kydland_1992)
@test isapprox(var_dec(["K{F}","Y{H}","Z{F}"],"E{F}") * 100, [51.34, 42.44, 52.59],rtol = 1e-3)
@test isapprox(var_dec(["K{F}","Y{H}","Z{F}"],"E{H}") * 100, [48.66, 57.56, 47.41],rtol = 1e-3)

write_to_dynare_file(Backus_Kehoe_Kydland_1992)
Backus_Kehoe_Kydland_1992 = nothing


Expand All @@ -24,6 +25,7 @@ var_dec = get_var_decomp(NAWM_EAUS_2008)
@test isapprox(var_dec(:EA_Y,[:EA_EPSR,:EA_EPSZ,:US_EPSZ]) * 100, [50.02, 13.54, 4.35],rtol = 1e-3)
@test isapprox(var_dec(:US_K,[:EA_EPSRP,:US_EPSR,:US_EPSZ]) * 100, [17.48, 26.83, 27.76],rtol = 1e-3)

write_to_dynare_file(NAWM_EAUS_2008)
NAWM_EAUS_2008 = nothing


Expand All @@ -45,6 +47,7 @@ if test_higher_order
@test isapprox(autocorr_3rd(:c,5),0.4784,rtol = 1e-3)
end

write_to_dynare_file(SGU_2003_debt_premium)
SGU_2003_debt_premium = nothing


Expand All @@ -58,6 +61,7 @@ corrr = get_correlation(Baxter_and_King_1993)
@test isapprox(corrr(:k,:l),0.8553,rtol = 1e-3)
@test isapprox(corrr(:r,:w),-0.9898,rtol = 1e-3)

write_to_dynare_file(Baxter_and_King_1993)
Baxter_and_King_1993 = nothing


Expand All @@ -82,6 +86,7 @@ if test_higher_order
@test isapprox(autocorr_3rd(:r,5),0.2927,rtol = 1e-3)
end

write_to_dynare_file(JQ_2012_RBC)
JQ_2012_RBC = nothing


Expand All @@ -95,6 +100,7 @@ var_dec = get_variance_decomposition(Ireland_2004)

@test isapprox(var_dec(:π̂,:) * 100, [4.51, 0.91, 87.44, 7.14],rtol = 1e-4)

write_to_dynare_file(Ireland_2004)
Ireland_2004 = nothing


Expand All @@ -109,6 +115,7 @@ var_dec = get_var_decomp(GNSS_2010)

@test isapprox(var_dec(:B,:) * 100, [42.97, 19.31, 11.70, 0.36, 4.45, 1.41, 0.70, 0.00, 0.61, 12.54, 2.85, 2.72, 0.38],rtol = 1e-3)

write_to_dynare_file(GNSS_2010)
GNSS_2010 = nothing


Expand All @@ -135,6 +142,7 @@ if test_higher_order
@test isapprox(autocorr_3rd(:C,5),0.9178,rtol = 1e-3)
end

write_to_dynare_file(Ghironi_Melitz_2005)
Ghironi_Melitz_2005 = nothing


Expand All @@ -149,6 +157,7 @@ var_dec = get_var_decomp(Gali_Monacelli_2005_CITR)
@test isapprox(var_dec(:pih,:) * 100, [62.06, 37.94],rtol = 1e-3)
@test isapprox(var_dec(:x,:) * 100, [56.22, 43.78],rtol = 1e-3)

write_to_dynare_file(Gali_Monacelli_2005_CITR)
Gali_Monacelli_2005_CITR = nothing


Expand All @@ -172,6 +181,7 @@ if test_higher_order
@test isapprox(mean_2nd(:C),0.9156,rtol = 1e-3)
end

write_to_dynare_file(Gali_2015_chapter_3_nonlinear)
Gali_2015_chapter_3_nonlinear = nothing


Expand All @@ -189,6 +199,8 @@ if test_higher_order

@test isapprox(autocorr_3rd(:c,5),0.9424,rtol = 1e-3)
end

write_to_dynare_file(Caldara_et_al_2012)
Caldara_et_al_2012 = nothing


Expand All @@ -204,6 +216,7 @@ var_dec = get_var_decomp(Ascari_Sbordone_2014)
@test isapprox(var_dec(:w,:) * 100, [2.02, 95.18, 2.80],rtol = 1e-3)
@test isapprox(var_dec(:y,:) * 100, [0.47, 99.41, 0.12],rtol = 1e-3)

write_to_dynare_file(Ascari_Sbordone_2014)
Ascari_Sbordone_2014 = nothing


Expand All @@ -226,4 +239,5 @@ if test_higher_order
@test isapprox(autocorr_3rd(:c,5),0.9299,rtol = 1e-3)
end

write_to_dynare_file(Aguiar_Gopinath_2007)
Aguiar_Gopinath_2007 = nothing

0 comments on commit 1371120

Please sign in to comment.