by OndraKamenik » Fri Jun 16, 2006 7:18 am
Dear Tamas,
there are three things needed to be specified: order of columns in the multidimensional index, order of rows, and contents of the tensors.
1. Order of columns: k-order tensor (dyn_g_k) has its k-dimensional multiindex over a vector of state variables. The state variables vector is a concatenation of predetermined variables (those appearing at t-1) and shocks.
The order of variables is given by dyn_state_vars. The tensor is folded, which means that symmetric derivatives are dropped. This means that if there are m state variables (length of dyn_state_vars), than dyn_g_k has (m+k-1)!/((m-1)!*k!) columns. An unfolded version would have m^k columns. In tl.pdf, a section called @<FTensor::getOffsetRecurse code@> gives a description how multiindices are ordered in the folded tensor, and more importantly how to calculate an offset of a given multiindex. Following the example in that section having m=4 and k=3, an offset of multiindex (1,2,2) (starting from zero) will be 14. And if dyn_state_vars=('x','y','w','z') than the derivative with multiindex (1,2,2) is a derivative with respect y*w^2 and can be found in the 14-th column.
2. Order of rows is given by dyn_vars.
3. The solution is y(t)=g(y(t-1),u(t)), where y is a vector of all endogenous variables, and y(t-1) appearing as an argument of g is restricted only to those variables appearing at time t-1. See point 1 above. A k-dimensional tensor dyn_g_k is equal to k-th derivative of g with respect to stacked vector of y(t-1) and u(t) divided by (k!). So if one wants to recover pure derivatives, he must multiply dyn_g_k with (k!).
One more thing is worth noting: the tensors dyn_g_k were folded by erasing symmetric elements. When the tensor polynomial is evaluated (see tl.pdf sections @<TensorPolynomial::evalTrad code@> and @<TensorPolynomial::evalHorner code@>) the multiple symmetricities of some elements are counted not when derivatives are folded but when powers of x are folded. The later folds row-wise tensor which sums symmetric elements. In Dynare++, the convention is that column-wise folding erases symmetric elements and row-wise folding sums symmetric elements. That's why the evaluation is correct.
regards,
Ondra K.