Nonlinear equation solver for neoclassical growth model

Hello!
I am trying to replicate a neoclassical growth model by computing the optimal paths of the main variables of the model. As such, I am starting from fixed initial values for capital, consumption, investment, and output (k_path(1), c_path(1), i_path(1), y_path(1)) and have to reach fixed final values for all these variables (k_path(T), c_path(T), i_path(T), y_path(T)). There are 4 equations describing the relationships between these variables:
  • Euler equation:
c_path(t) = beta * c_path(t - 1) * ((1 + g)^(-1) * (theta * k_path(t)^(theta - 1) * (gamma * l_path(t))^(1 - theta) + 1 - delta));
  • Law of motion for capital:
k_path(t) = (i_path(t - 1) + (1 - delta) * k_path(t - 1)) / ((1 + g) * (1 + n_path(t) / 100));
  • Resource constraint:
y_path(t) = c_path(t) + i_path(t);
  • Production function:
y_path(t) = k_path(t)^theta * (gamma * l_path(t))^(1-theta);
where l_path and n_path are labour and population growth rate respectively (both of them are exogenous variables), beta is the discount factor, g is the growth rate, theta is the weight for capital in the production function, gamma is a parameter related to labour efficiency, delta is the depreciation rate.
The algorithm for this task should be normally based on a nonlinear equation solver. Do you think that fsolve is the best function to perform this? Or is there a better alternative given the nature of the equations?

9 Comments

And which are the control parameters that you can influence to get the desired output at time T ? The initial conditions for k,c i and y ?
@Torsten there are no other parameters specified in the model. I calculated the initial and final values of the variables based on the Euler equation assuming steady state in both the initial and final periods and a slightly modified law of motion for capital. So the initial and final values are computed and known before the equation solver part.
And what are the unknowns ? If you know the initial values and recursions for k,c,i and y, why do you need a nonlinear solver ?
@Torsten The solver should return the values for k, c, i, and y in each period from 2 to T-1. Initially, I applied your method with recursions, but the variables did not converge to the final values. Afterwards, I realised that not all the equations describe contemporaneous relations between k_path(t), c_path(t), i_path(t), and y_path(t). The best example is the law of motion for capital, which relates current k to past k and i and not to any other current variables. For this reason, I guess it would be safer to use a nonlinear solver.
Initially, I applied your method with recursions, but the variables did not converge to the final values.
Then either your recursions are wrong or the final values.
Afterwards, I realised that not all the equations describe contemporaneous relations between k_path(t), c_path(t), i_path(t), and y_path(t). The best example is the law of motion for capital, which relates current k to past k and i and not to any other current variables.
It's not necessary that a current variable depends on all the other variables in the past. It's necessary that you can compute state (t+1) from state (t) uniquely for all variables involved.
For this reason, I guess it would be safer to use a nonlinear solver.
If you deduced a relationship such that [k(t+1) c(t+1) i(t+1) y(t+1)] can be computed from known values of k, c, t and y at earlier times than t+1, you are done. Why should a nonlinear solver change the resulting time series ?
I have a quick run to this model and I am getting some inifite values on the jacobian, is there a any reference / paper for the equations so we can check for errors?
Also, do you have any values for the parameteres beta, theta, g, gamma, delta, initial values for l_path, n_path? Just to make sure that my values are not off here.
@Edu Benet Cerda Sure, here is the original paper which describes the model that I am trying to replicate: https://www.nber.org/papers/w31351
@Torsten If we start instead from the last period, the recursions are not possible anymore and one would need a nonlinear solver. Do you know how this solver would look like then?
@Sergiu, Thanks for sharing the paper. This seems to be a Ramsey-Cass-Koopmans model. There is a MATLAB tool called dynare that is well suited to solving some of these models. Below you will find an implementation of a very similar model where some of the equations are straight the same or very close.
If you have any issues running it, feel free to reach out directly at ebenetce@mathworks.com

Sign in to comment.

Answers (1)

Torsten
Torsten on 13 Oct 2023
Edited: Torsten on 13 Oct 2023
  1. Set the right-hand sides of the resource constraint and the production constraint equal and solve for i(t). You will get an equation where i(t) depends on k(t) and c(t) (l(t) is externally given).
  2. Insert the equation for k(t) (law of motion for capital) in the equation under (1). Now equation (1) for i(t) depends on i(t-1), k(t-1) and c(t) (l(t) and n(t) are externally given).
  3. The equation for c(t) (Euler equation) depends on c(t-1) and k(t) (l(t) is externally given). For k(t), insert equation (2) (law of motion for capital). Now the equation for c(t) depends on c(t-1),i(t-1),k(t-1) (n(t) and l(t) are externally given).
  4. Now continue step (2) and in the equation for i(t), insert the equation for c(t) derived under (3). Now i(t) depends on i(t-1), k(t-1) and c(t-1) (l(t) and n(t) are externally given).
  5. Summarizing: You now have an equation for k(t) that depends on i(t-1) and k(t-1) (n(t) is externally given), you have an equation for c(t) that depends on c(t-1),i(t-1),k(t-1) (n(t) and l(t) are externally given) and you have an equation for i(t) that depends on i(t-1), k(t-1) and c(t-1) (l(t) and n(t) are externally given).
  6. So specify initial conditions for c, i and k and use the recursions described above.
If you want to start with conditions for the last period and derive the "correct" three initial conditions, define c(0), i(0) and k(0) as unknowns for the nonlinear solver (e.g. "fsolve") and define the residuals as c_pre(T)-c(T), i_pre(T)-i(T), k_pre(T)-k(T) where c_pre(T), i_pre(T) and k_pre(T) are your prescribed values in period T.
This is a highly nonlinear system - I'm not sure "fsolve" will be able to find a solution. It would be better if you found a backwards recursion. Further you should take in mind that only a very limited number of end conditions allow suitable initial conditions, i.e. most of the backwards recursion problems won't have a solution.

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Products

Release

R2023a

Asked:

on 11 Oct 2023

Commented:

on 13 Oct 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!