# How to model Macroeconomic dynamics?

I am rather new to Mathematica and I wanted to see if I could get some help with the following. I am trying to generate a model of macroeconomic indicators defined by the following functions, but I do not know how to input these in Mathematica or be able to manipulate them a bit more.

Y(T+2)    =  C(T+2) + I(T+2) + Govlev(T+2) + X(T+2) ;
YD(T+2)   = (1 - TX(T+2)) * Y(T+2) ;
C(T+2)    = a + b * YD(T+2) ;
I(T+2)    =  e - d * R(T+2) ;
Mlev(T+2) / plev(T+2) = k * Y(T+2) - h * R(T+2);
Pie(T+2)  = alpha * Pi(T+1) + beta * Pi(T) ;
Pi(T+2)   = Pie(T+2)+ f * (Y(T+1) - YNlev(T+2))  /  YNlev(T+2) ;
plev(T+2) = plev(T+1) * (1 + Pi(T+2)) ;
Ex(T+2) * plev(T+2) / plevw(T+2) = E = q +  v * R(T+2) ;
X(T+2)    = gamma - mu * Y(T+2) - n * ( Ex(T+2) * plev(T+2) / plevw(T+2)) ;
GD(T+2)   = Govlev(T+2) - TX(T+2) * Y(T+2) ;
U(T+2)    = UN(T+2) - s * (Y(T+2) - YNlev(T+2)) / YNlev(T+2) ;

• If you do not know how to input an equation of the type in your question into Mathematica wouldn't the documentation be a good place to start looking, reading, and learning some of the syntax? After that, and assuming you have T=0 values for these variables, then check out functions like Nest and Fold which will (probably) help you solve your equations for (presumably) a series of time steps into the future (?). Sorry if that seems blunt but I don't think this is a forum to learn how to type equations into Mathematica. – Mike Honeychurch Oct 15 '12 at 3:11
• I agree with Mike here. If you are completely new to Mathematica, then starting with the documentation (or the virtual book) might be a better idea. Unfortunately, this site is not the place to learn Mathematica from scratch. However, if you're having troubles along the way that are not adequately addressed by the documentation or existing questions here, feel free to ask and we'll certainly help. If you're in a hurry to implement these, I would suggest sticking to whatever programming language/software you know best – rm -rf Oct 15 '12 at 3:17
• This URL might also have some useful links: wolfram.com/support/learn – Mike Honeychurch Oct 15 '12 at 3:28

## 2 Answers

Since you don't sem to have any explicit forward-looking / rational expectations elements in your system (the equation for Pie depends only on lags), I don't know why you are expressing your time subscripts as $T+2$ rather than $t$, $t-1$, $t-2$.

Your system is essentially linear, so I would suggest that you define your system as a vector state variable with a matrix of coefficients, which you can then update to simulate a time series using NestList. If you also had stochastic elements, which the above equations don't seem to do, then you would use FoldList. Because you have two lags of variables on the right-hand side of the equations, the first lag is also a state variable, which you need to track as part of the state vector.

Once you do that, you will realise that you have not specified equations for some of your variables, including $R$ (I'm guessing interest rates) and $YNlev$ (I'm guessing nominal GDP). You need to do this to have a complete system. In the latter case, it is presumably just the identity that $YNlev = Ylev * Pi$.

Now, to comment on your usage of Mathematica. You can definitely do this in Mathematica, but before you start, as with any new programming language, you really need to familiarise yourself with some very basic aspects of the syntax. The most relevant ones given your proposed input are:

1. It's always better to use lower-case letters for single-letter variable names, to avoid conflicts with built-in Mathematica symbols. In the case of your input, C and I will conflict with the default symbol for constants and the square root of -1, and of course Pi conflicts with $\pi$.
2. Understand the difference between Set (=), SetDelayed (:=) and Equal (==). For your application, you need Equal, not Set as you’ve used.
3. In Mathematica, parentheses are only for grouping, eg Expand[2(a+b)] gives 2 a + 2 b. Parameters of any kind of function or expression are contained in square brackets [ ]. You will probably find the tutorial on the four kinds of bracketing in Mathematica useful.

The other functions that might be useful to you are RSolve and RecurrenceTable. Rather than solve out your system for you, here is a simple example of the kind of output you might expect.

simple = RecurrenceTable[{y[t + 2] ==  0.8 y[t + 1] + 0.15 y[t] - 0.2 r[t + 1],
r[t + 2] == r[t + 1] + 0.1 y[t + 1], y == 2, y == 2, r == 1},
{y, r}, {t, 1, 250}];

ListLinePlot[simple] • ...and maybe RecurrenceTable[] as well. – J. M.'s ennui Oct 15 '12 at 6:31

Maybe this will help. It's a collection of macro growth theory solved in Mathematica