Skip to content

Commit

Permalink
Documentation update (#16)
Browse files Browse the repository at this point in the history
* Update documentation for solve function and add one for steady_state_K

* Bind steady_state_K documentation

* Change public function call

* Use LaTeX

---------

Co-authored-by: Michał Dobranowski <mdbrnowski@gmail.com>
  • Loading branch information
joannakonieczny and mdbrnowski authored Jun 5, 2024
1 parent be4cdcc commit 73b3e0a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "RamseyGrowthModel"
uuid = "d3b58844-8b75-44dd-9e60-01c7b9b67cff"
authors = ["Michał Dobranowski <mdbrnowski@gmail.com>"]
authors = ["Michał Dobranowski <mdbrnowski@gmail.com>", "Joanna Konieczny <joanna.konieczny.contact@gmail.com>"]
version = "0.1.0"

[deps]
Expand Down
4 changes: 4 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ print(allocation)
GrowthModel
```

```@docs
RamseyGrowthModel.steady_state_K
```

```@docs
solve
```
Expand Down
4 changes: 2 additions & 2 deletions example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ With the increase of time ``T``, a special property of the capital function can
"""

# ╔═╡ 69167b33-034d-480b-9a06-193c11c61c49
kss = RamseyGrowthModel.steady_state_K(my_model)
kss = steady_state_K(my_model)

# ╔═╡ 77398e1c-55a3-4ae7-868a-cdb7cdf2a8f2
kss_best_allocation = solve(my_model, 100, kss)
Expand Down Expand Up @@ -168,7 +168,7 @@ md"""
custom_allocation = solve(custom_model, t, k_0/10)

# ╔═╡ 8214f1e7-f8ad-44ef-9be7-ec5b930e399d
custom_kss = RamseyGrowthModel.steady_state_K(custom_model)
custom_kss = steady_state_K(custom_model)

# ╔═╡ f4e715da-809f-42e5-a948-f8d4de5e297e
plot_capital(custom_allocation, custom_kss)
Expand Down
19 changes: 17 additions & 2 deletions src/RamseyGrowthModel.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module RamseyGrowthModel

export GrowthModel, solve
export GrowthModel, solve, steady_state_K

using DataFrames
using ForwardDiff
Expand Down Expand Up @@ -83,6 +83,19 @@ function shooting(model::GrowthModel, T::Integer, K₀::Real, C₀::Real)::DataF
allocation
end

@doc raw"""
Returns steady state capital ``K``, to which capital ``K_t`` converges for large values of ``T``.
```julia
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.
"""
function steady_state_K(model::GrowthModel)::Real
f′(k::Real) = ForwardDiff.derivative(model.f, k)
find_zero(x -> f′(x) - 1 / model.β + 1 - model.δ, (0, Inf64))
Expand All @@ -92,7 +105,7 @@ end
Returns the best possible capital and consumption allocation (as a DataFrame).
```julia
solve(model::GrowthModel, T::Integer, K₀::Real; kwargs...)
solve(model::GrowthModel, T::Union{Integer,typeof(Inf)}, K₀::Real; kwargs...)
```
# Arguments
Expand All @@ -101,6 +114,8 @@ solve(model::GrowthModel, T::Integer, K₀::Real; kwargs...)
* `T` - considered time horizon
* `K₀` - 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`).
Expand Down

0 comments on commit 73b3e0a

Please sign in to comment.