RamseyGrowthModel.jl
Simple example
using RamseyGrowthModel
my_model = GrowthModel(
0.95, # discount factor
0.02, # depreciation rate on capital
2.0, # coefficient of relative risk aversion
0.3, # return to capital per capita
1, # technology
)
allocation = solve(
my_model,
5, # time horizon
1.0 # initial capital
)
print(allocation)
[ Info: The best allocation has been found after 25 iterations.
6×3 DataFrame
Row │ t K C
│ Int64 Float64 Float64
─────┼───────────────────────────
1 │ 0 1.0 0.884107
2 │ 1 1.09589 0.967806
3 │ 2 1.13402 1.05663
4 │ 3 1.09316 1.15689
5 │ 4 0.941491 1.28216
6 │ 5 0.622579 1.4776
Defining and Solving a Growth Model
RamseyGrowthModel.GrowthModel
— TypeDefines a Ramsey Growth Model.
Fields
β
- discount factorδ
- depreciation rate on capitalu
- utility functionf
- production function
Constructors
If you want to use a CRRA utility function and a Cobb-Douglas production function, use constructor
GrowthModel(β::Real, δ::Real, γ::Real, α::Real, A::Real)
where γ
is a parameter for RamseyGrowthModel.sample_u
, and α
and A
are parameters for RamseyGrowthModel.sample_f
.
However, if you have some other utility and production functions you want to use, constructor
GrowthModel(β::Real, δ::Real, u::Function, f::Function)
is also avaible.
RamseyGrowthModel.steady_state_K
— FunctionReturns steady state capital $K$, to which capital $K_t$ converges for large values of $T$.
steady_state_K(model::GrowthModel)
Arguments
model
- previously defined growth model
This value is mostly useful for plotting purposes and as a starting point of a simulation.
RamseyGrowthModel.solve
— FunctionReturns the best possible capital and consumption allocation (as a DataFrame).
solve(model::GrowthModel, T::Union{Integer,typeof(Inf)}, K₀::Real; kwargs...)
Arguments
model
- previously defined growth modelT
- considered time horizonK₀
- initial capital
Argument T
should be of type Integer
or equal to Inf
. Passing a floating point value will raise an error.
Keyword Arguments
The algorithm uses a binary search; if you want, you can override the default maximum number of iterations (max_iter=1000
) or error tolerance (tol=K₀/1e6
).
Sample Functions Used in the Model
You probably should not be using these functions directly in your program. Instead, use a constructor of the GrowthModel
.
RamseyGrowthModel.sample_u
— FunctionReturns CRRA (constant relative risk aversion) utility function $u(c)$ with a given $γ$.
\[u(c) = \frac{c^{1 - γ} - 1}{1 - γ} + 1\]
What does it look like? See for yourself here.
RamseyGrowthModel.sample_f
— FunctionReturns per-capita Cobb-Douglas production function $f(k)$ with given $α$ and $A$.
\[f(k) = A \cdot k^α\]