I'm working on a project that involves developing a financial forecasting model. The equations used in the model will largely be linear difference equations (estimated via some form of regression analysis). Along with the difference equations will be additional equations that are simple identities, e.g., a[t] == b[t] + c[t], with no sort of time lag.
I've been experimenting with RecurrenceTable, using some simple hypothetical examples. For instance, this set of equations evaluates correctly:
In[763]:=
model1 = RecurrenceTable[
{
x[t + 2] ==
0.25 + x[t + 1] - 1.5*x[t] + 0.5*y[t + 1] + y[t + 2] ,
y[t + 2] == -0.50*y[t + 1] + 0.25*y[t] + x[t + 1] - 0.75*x[t + 2] ,
z[t + 2] == 0.20*z[t + 1] + z[t] - 0.25*y[t + 2] - 1.5*x[t + 2] ,
x[0] == 1, x[1] == 1,
y[0] == 0, y[1] == 2,
z[0] == 0, z[1] == 1},
{x, y, z}, {t, 1, 10}
]
Out[763]= {{1., 2., 1.}, {0.428571, -0.321429, -0.3625}, {0.0612245,
1.04337, 0.574821}, {-0.200437, -0.390488, 0.150742}, {0.0103603,
0.247878, 0.52746}, {0.270717, -0.414239, -0.0462812}, {0.478779,
0.180722, -0.245145}, {0.398813, -0.0142515, -0.689967}, {0.214079,
0.29056, -0.776897}, {0.0436432, 0.0325037, -0.918937}}
If I modify this to include an additional equation, q[t+2] that simply sums the results of the other equations:
In[761]:= fcstB = RecurrenceTable[
{
x[t + 2] ==
0.25 + x[t + 1] - 1.5*x[t] + 0.5*y[t + 1] + y[t + 2] ,
y[t + 2] == -0.50*y[t + 1] + 0.25*y[t] + x[t + 1] - 0.75*x[t + 2] ,
z[t + 2] == 0.20*z[t + 1] + z[t] - 0.25*y[t + 2] - 1.5*x[t + 2] ,
q[t + 2] == x[t + 2] + y[t + 2] + z[t + 2],
x[0] == 1, x[1] == 1,
y[0] == 0, y[1] == 2,
z[0] == 0, z[1] == 1,
q[0] == 1, q[1] == 4},
{x, y, z, q}, {t, 1, 10}
]
Out[761]= RecurrenceTable[{x[2 + t] ==
0.25 - 1.5 x[t] + x[1 + t] + 0.5 y[1 + t] + y[2 + t],
y[2 + t] == x[1 + t] - 0.75 x[2 + t] + 0.25 y[t] - 0.5 y[1 + t],
z[2 + t] == -1.5 x[2 + t] - 0.25 y[2 + t] + z[t] + 0.2 z[1 + t],
q[2 + t] == x[2 + t] + y[2 + t] + z[2 + t], x[0] == 1, x[1] == 1,
y[0] == 0, y[1] == 2, z[0] == 0, z[1] == 1, q[0] == 1,
q[1] == 4}, {x, y, z, q}, {t, 1, 10}]
The result does not evaluate. In looking through the documentation, it appears that RecurrenceTable will not handle trivial recurrence equations. I'm hoping someone can verify this for me, or perhaps suggest an alternative. The actual model I'm developing will consist of thousands of equations, and so it seems I will need to organize blocks of equations in such a way to isolate identities in order to evaluate the entire system
Thanks!