Skip to content

Commit

Permalink
lint: JuliaFormetter
Browse files Browse the repository at this point in the history
  • Loading branch information
AldoGl committed Jun 28, 2024
1 parent b6b1c73 commit aadc7c5
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ makedocs(
],
)

deploydocs(;repo = "github.com/bancaditalia/ABCredit.jl.git")
deploydocs(; repo = "github.com/bancaditalia/ABCredit.jl.git")
25 changes: 15 additions & 10 deletions examples/compare_histograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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))
plot(p1, p2, p3, p4, p5, layout = (2, 3))
1 change: 0 additions & 1 deletion main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

3 changes: 2 additions & 1 deletion src/markets/credit_market.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/model_init/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
4 changes: 2 additions & 2 deletions src/params/standard_params.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
const REAL_DATA_EXAMPLE = real_data
4 changes: 2 additions & 2 deletions test/consumption_goods_market.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,4 +67,4 @@ using ABCredit, Test
@test endQ == [2.0 / 5.0, 0.0]
@test endYd == [2 / 5, 0]

end
end
3 changes: 1 addition & 2 deletions test/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion test/stock_flow_consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ using ABCredit, Test
@test isapprox(init_money, money, atol = 1e-5)
end

end
end
2 changes: 1 addition & 1 deletion test/stock_flow_consistency_detailed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ using ABCredit, Test

end

end
end

0 comments on commit aadc7c5

Please sign in to comment.