21. Dynamics in One Dimension#
21.1. Overview#
In this lecture we give a quick introduction to discrete time dynamics in one dimension.
In one-dimensional models, the state of the system is described by a single variable.
Although most interesting dynamic models have two or more state variables, the one-dimensional setting is a good place to learn the foundations of dynamics and build intuition.
We’ll use the following packages:
using LaTeXStrings, LinearAlgebra, Plots
21.2. Some Definitions#
This section sets out the objects of interest and the kinds of properties we study.
21.2.1. Difference Equations#
A time homogeneous first order difference equation is an equation of the form
where
Here
In the definition,
time homogeneity means that
is the same at each timefirst order means dependence on only one lag (i.e., earlier states such as
do not enter into (21.1)).
If
This sequence is called the trajectory of
If we define
21.2.2. Example: A Linear Model#
One simple example is the linear difference equation
where
In this case, given
Continuing in this way, and using our knowledge of geometric series, we find that, for any
This is about all we need to know about the linear model.
We have an exact expression for
Notice in particular that
regardless of
This is an example of what is called global stability, a topic we return to below.
21.2.3. Example: A Nonlinear Model#
In the linear example above, we obtained an exact analytical expression for
This made analysis of dynamics very easy.
When models are nonlinear, however, the situation can be quite different.
For example, consider the law of motion for the Solow growth model, a simplified version of which is
Here
If you try to iterate like we did in (21.3), you will find that the algebra gets messy quickly.
Analyzing the dynamics of this model requires a different method (see below).
21.2.4. Stability#
A steady state of the difference equation
In other words,
For example, for the linear model
is a steady state whenever .if
and , then every is a steady state.if
and , then the linear model has no steady state in .
A steady state
For example, in the linear model
is globally stable if
andfails to be globally stable otherwise.
This follows directly from (21.4).
A steady state
Obviously every globally stable steady state is also locally stable.
We will see examples below where the converse is not true.
21.3. Graphical Analysis#
As we saw above, analyzing the dynamics for nonlinear models is nontrivial.
There is no single way to tackle all nonlinear models.
However, there is one technique for one-dimensional models that provides a great deal of intuition.
This is a graphical approach based on 45 degree diagrams.
Let’s look at an example: the Solow model with dynamics given in (21.6).
We begin with some plotting code that you can ignore at first reading.
The function of the code is to produce 45 degree diagrams and time series plots.
# Iterates a function from an initial condition
function iterate_map(f, x0, T)
x = zeros(T + 1)
x[1] = x0
for t in 2:(T + 1)
x[t] = f(x[t - 1])
end
return x
end
function plot45(f, xmin, xmax, x0, T; num_points = 100, label = L"g(k)",
xlabel = "k")
# Plot the function and the 45 degree line
x_grid = range(xmin, xmax, num_points)
plt = plot(x_grid, f.(x_grid); xlim = (xmin, xmax), ylim = (xmin, xmax),
linecolor = :black, lw = 2, label)
plot!(x_grid, x_grid; linecolor = :blue, lw = 2, label = nothing)
# Iterate map and add ticks
x = iterate_map(f, x0, T)
xticks!(x, [L"%$(xlabel)_{%$i}" for i in 0:T])
yticks!(x, [L"%$(xlabel)_{%$i}" for i in 0:T])
# Plot arrows and dashes
for i in 1:T
plot!([x[i], x[i]], [x[i], x[i + 1]], arrow = :closed, linecolor = :black,
alpha = 0.5, label = nothing)
plot!([x[i], x[i + 1]], [x[i + 1], x[i + 1]], arrow = :closed,
linecolor = :black, alpha = 0.5, label = nothing)
plot!([x[i + 1], x[i + 1]], [0, x[i + 1]], linestyle = :dash,
linecolor = :black, alpha = 0.5, label = nothing)
end
plot!([x[1], x[1]], [0, x[1]], linestyle = :dash, linecolor = :black,
alpha = 0.5, label = nothing)
end
function ts_plot(f, x0, T; xlabel = L"t", label = L"k_t")
x = iterate_map(f, x0, T)
plot(0:T, x; xlabel, label)
plot!(0:T, x; seriestype = :scatter, mc = :blue, alpha = 0.7, label = nothing)
end
ts_plot (generic function with 1 method)
Let’s create a 45 degree diagram for the Solow model with a fixed set of parameters
p = (A = 2, s = 0.3, alpha = 0.3, delta = 0.4, xmin = 0, xmax = 4)
(A = 2, s = 0.3, alpha = 0.3, delta = 0.4, xmin = 0, xmax = 4)
Here’s the update function corresponding to the model.
g(k; p) = p.A * p.s * k^p.alpha + (1 - p.delta) * k
g (generic function with 1 method)
Here is the 45 degree plot.
plot45(k -> g(k; p), p.xmin, p.xmax, 0, 6)
The plot shows the function
Think of
To calculate
Clearly,
If
lies above the 45 degree line at this point, then we have .If
lies below the 45 degree line at this point, then we have .If
hits the 45 degree line at this point, then we have , so is a steady state.
For the Solow model, there are two steady states when
the origin
the unique positive number such that
.
By using some algebra, we can show that in the second case, the steady state is
21.3.1. Trajectories#
By the preceding discussion, in regions where
The next figure traces out a trajectory in such a region so we can see this more clearly.
The initial condition is
k0 = 0.25
plot45(k -> g(k; p), p.xmin, p.xmax, k0, 5)
We can plot the time series of capital corresponding to the figure above as follows:
ts_plot(k -> g(k; p), k0, 5)
Here’s a somewhat longer view:
ts_plot(k -> g(k; p), k0, 20)
When capital stock is higher than the unique positive steady state, we see that it declines:
k0 = 2.95
plot45(k -> g(k; p), p.xmin, p.xmax, k0, 5)
Here is the time series:
ts_plot(k -> g(k; p), k0, 8)
21.3.2. Complex Dynamics#
The Solow model is nonlinear but still generates very regular dynamics.
One model that generates irregular dynamics is the quadratic map
Let’s have a look at the 45 degree diagram.
xmin, xmax = 0, 1
g(k) = 4 * k * (1 - k)
x0 = 0.3
plot45(g, xmin, xmax, 0.1, 0)
Now let’s look at a typical trajectory.
plot45(g, xmin, xmax, 0.1, 6)
Notice how irregular it is.
Here is the corresponding time series plot.
ts_plot(g, x0, 6)
The irregularity is even clearer over a longer time horizon:
ts_plot(g, x0, 20)
21.4. Exercises#
21.4.1. Exercise 1#
Consider again the linear model
The unique steady state is
The steady state is globally stable if
Try to illustrate this graphically by looking at a range of initial conditions.
What differences do you notice in the cases
Use
Set
21.5. Solutions#
21.5.1. Exercise 1#
We will start with the case
Let’s set up the model and plotting region:
q = (a = 0.5, b = 1, xmin = -1, xmax = 3)
g(k; q) = q.a * k + q.b
g (generic function with 1 method)
Now let’s plot a trajectory:
x0 = -0.5
plot45(k -> g(k; q), q.xmin, q.xmax, x0, 5)
Here is the corresponding time series, which converges towards the steady state.
ts_plot(k -> g(k; q), x0, 10)
Now let’s try
Let’s set up the model and plotting region:
r = (a = -0.5, b = 1, xmin = -1, xmax = 3)
g(k; r) = r.a * k + r.b
g (generic function with 1 method)
Now let’s plot a trajectory:
x0 = -0.5
plot45(k -> g(k; r), r.xmin, r.xmax, x0, 5)
Here is the corresponding time series, which converges towards the steady state.
ts_plot(k -> g(k; r), x0, 10)
Once again, we have convergence to the steady state but the nature of convergence differs.
In particular, the time series jumps from above the steady state to below it and back again.
In the current context, the series is said to exhibit damped oscillations.