diff --git a/docs/make.jl b/docs/make.jl index 4a63b54..32e4751 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -30,4 +30,4 @@ makedocs( ], ) -deploydocs(;repo = "github.com/bancaditalia/ABCredit.jl.git") +deploydocs(; repo = "github.com/bancaditalia/ABCredit.jl.git") diff --git a/examples/compare_histograms.jl b/examples/compare_histograms.jl index 3fda6c9..7198dc6 100644 --- a/examples/compare_histograms.jl +++ b/examples/compare_histograms.jl @@ -6,7 +6,7 @@ using ABCredit, Statistics, Plots, DelimitedFiles # install the HPFilter and KernelDensity packages using Pkg -Pkg.add(url="https://github.com/sdBrinkmann/HPFilter.jl") +Pkg.add(url = "https://github.com/sdBrinkmann/HPFilter.jl") Pkg.add("KernelDensity") using HPFilter, KernelDensity @@ -23,10 +23,10 @@ T = 1000 d = ABCredit.run_one_sim!(model, T; seed = 100, burn_in = 300) # select some variables -Y = d.Y_real; -P = d.gdp_deflator; -I = d.Investment; -C = d.consumption; +Y = d.Y_real; +P = d.gdp_deflator; +I = d.Investment; +C = d.consumption; U = d.Un; # load the data from FRED saved in the package as an example @@ -38,16 +38,21 @@ c_real = data[:, 4]; u_real = data[:, 5]; # apply HP filter to the simulated data -y = log.(Y) - HP(log.(Y),1600); -c = log.(C) - HP(log.(C),1600); -invest = log.(I) - HP(log.(I),1600); +y = log.(Y) - HP(log.(Y), 1600); +c = log.(C) - HP(log.(C), 1600); +invest = log.(I) - HP(log.(I), 1600); u = U; pi = diff(log.(P)) .- mean((diff(log.(P)))); # plot the histograms of real and simulated data pdf_sim = kde(u); pdf_real = kde(u_real); -p1 = plot([pdf_sim.density, pdf_real.density], title = "unemployment rate", titlefont = 10, labels=["simulated" "real"]) +p1 = plot( + [pdf_sim.density, pdf_real.density], + title = "unemployment rate", + titlefont = 10, + labels = ["simulated" "real"], +) pdf_sim = kde(y); pdf_real = kde(y_real); @@ -65,4 +70,4 @@ pdf_sim = kde(invest); pdf_real = kde(invest_real); p5 = plot([pdf_sim.density, pdf_real.density], title = "investment gap", titlefont = 10, legend = :none) -plot(p1, p2, p3, p4, p5, layout = (2, 3)) \ No newline at end of file +plot(p1, p2, p3, p4, p5, layout = (2, 3)) diff --git a/main.jl b/main.jl index 20b032f..355da7c 100644 --- a/main.jl +++ b/main.jl @@ -48,4 +48,3 @@ p21 = plot(d.reserves, title = "RESERVES", titlefont = 10) p21 = plot(d.deposits, title = "DEPOSITS", titlefont = 10) plot(p1, p2, p3, p4, p5, p6, p7, p8, p9, layout = (3, 3), legend = false) plot(p10, p11, p12, p13, p14, p15, p16, p17, p18, layout = (3, 3), legend = false) - diff --git a/src/markets/credit_market.jl b/src/markets/credit_market.jl index 1923c0f..fa8c0cf 100644 --- a/src/markets/credit_market.jl +++ b/src/markets/credit_market.jl @@ -28,7 +28,8 @@ function firm_gets_credit!(firm::AbstractConsumptionFirm, model::AbstractModel) pr = _compute_bankruptcy_probability(firm.lev, model.params[:b1], model.params[:b2]) #proposed rate depends on the estimated bankruptcy probability - proposed_rate = _compute_proposed_rate(pr, model.params[:mu], model.params[:theta], model.params[:interest_rate]) + proposed_rate = + _compute_proposed_rate(pr, model.params[:mu], model.params[:theta], model.params[:interest_rate]) #the bank gives a maximum credit depending on maximum expected loss maxL = _compute_max_loan(firm.deb, model.params[:phi], model.bank.E, model.bank.E_threshold, pr) diff --git a/src/model_init/init.jl b/src/model_init/init.jl index d522a0b..33ae75d 100644 --- a/src/model_init/init.jl +++ b/src/model_init/init.jl @@ -28,7 +28,7 @@ function initialise_model(W, F, N; params = ABCredit.PARAMS_ORIGINAL) params[:init_K] = 10.0 params[:maastricht] = false params[:E_threshold_scale] = 0.0 - + workers = ABCredit.initialise_workers(params) ### INITIALISE CAPITAL FIRMS AND CONSUMPTION FIRMS ### diff --git a/src/params/standard_params.jl b/src/params/standard_params.jl index 0b2027c..b6b73b2 100644 --- a/src/params/standard_params.jl +++ b/src/params/standard_params.jl @@ -105,6 +105,6 @@ end const PARAMS_RL = params -real_data = readdlm(joinpath(dir, "FRED_data.txt"), ' ', Float64, skipstart=1) +real_data = readdlm(joinpath(dir, "FRED_data.txt"), ' ', Float64, skipstart = 1) -const REAL_DATA_EXAMPLE = real_data \ No newline at end of file +const REAL_DATA_EXAMPLE = real_data diff --git a/test/consumption_goods_market.jl b/test/consumption_goods_market.jl index 2f378a8..3c5c1d9 100644 --- a/test/consumption_goods_market.jl +++ b/test/consumption_goods_market.jl @@ -29,7 +29,7 @@ using ABCredit, Test firm.Yd = 0 #record demand end - ABCredit.consumption_goods_market!(consumer,cons_firms, model) + ABCredit.consumption_goods_market!(consumer, cons_firms, model) @test consumer.PA == 2.0 - 0.25 * F @test consumer.cons_budget == 1.0 - 0.25 * F @@ -67,4 +67,4 @@ using ABCredit, Test @test endQ == [2.0 / 5.0, 0.0] @test endYd == [2 / 5, 0] -end \ No newline at end of file +end diff --git a/test/main.jl b/test/main.jl index 4ef4c17..7c5b694 100644 --- a/test/main.jl +++ b/test/main.jl @@ -21,9 +21,8 @@ d = ABCredit.run_one_sim!(model, T; seed = seed); # ABCredit.save_csv(d, dir*"/fixtures/data_fixed_seed_$seed.csv") -data_expected = ABCredit.load_csv( dir*"/fixtures/data_fixed_seed_$seed.csv") +data_expected = ABCredit.load_csv(dir * "/fixtures/data_fixed_seed_$seed.csv") for name in fieldnames(typeof(d)) @test isapprox(getfield(d, name), getfield(data_expected, name), rtol = 1e-2) end - diff --git a/test/stock_flow_consistency.jl b/test/stock_flow_consistency.jl index 8f4a34c..2f4a790 100644 --- a/test/stock_flow_consistency.jl +++ b/test/stock_flow_consistency.jl @@ -24,4 +24,4 @@ using ABCredit, Test @test isapprox(init_money, money, atol = 1e-5) end -end \ No newline at end of file +end diff --git a/test/stock_flow_consistency_detailed.jl b/test/stock_flow_consistency_detailed.jl index d9122a5..f807332 100644 --- a/test/stock_flow_consistency_detailed.jl +++ b/test/stock_flow_consistency_detailed.jl @@ -152,4 +152,4 @@ using ABCredit, Test end -end \ No newline at end of file +end