dynare++: interpreting dyn_g_n

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

dynare++: interpreting dyn_g_n

Postby tpapp » Fri Jun 09, 2006 2:27 pm

Hi,

I am trying to use the results of dynare in R, especially for the
decision rule g(). R can load the resulting matlab file, and I
see all variables, I just need to interpret them.

The manual says that the tensors are folded into line vectors of
dyn_g_n, in a row for each variable, to avoid duplication of
symmetrical derivatives. Could somebody please tell me what the
mapping is for this folding? For example, if n=3, and I need
g_ijk, what is the corresponding index? Pointers to source code
in dynare++, or formulas would be appreciated.

Thanks,

Tamas
tpapp
 
Posts: 2
Joined: Wed Jun 07, 2006 4:03 pm

OK, I got the answer

Postby tpapp » Sat Jun 10, 2006 3:16 pm

I found the answer to my question. In case anybody needs this, the folding algorithm is explained on page 91 (Section 230) of tl.pdf in the Dynare++ documentation.

Best,

Tamas
tpapp
 
Posts: 2
Joined: Wed Jun 07, 2006 4:03 pm

Postby 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.
OndraKamenik
 
Posts: 73
Joined: Mon Dec 20, 2004 8:32 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 5 guests