# Mismatch in the simulation output

Hi,

I have a general question regarding a mismatch in simulation results, but let me use an example to explain. Suppose I am interested in the “carry trade” profits in a model. In this trade, agent borrows in the currency with a low interest rate, converts it into a currency that has a high interest rate, deposits money there and then in the next time period when the deposit matures converts back into the original currency to pay off the borrowing.

The profits of this trade depend on the gross interest rate at which the agent borrows (say Rb), the gross interest rate at which the agent deposits / lends (Rd), the exchange rate (say E) in the two periods and the size of the position (say q). The borrowing and deposit rates are known at time t, but paid at t + 1 (they are risk free), as is obviously the current exchange rate E_t, but the realised return on the trade will not be known until period t + 1 when E_{t+1} is realized. The realised return (say pi) in period t + 1 then is:

pi_{t+1} = ( Rd_t * E_{t+1} / E_t - Rb_t ) * q_t

To translate this into Dynare, I write the realised profit of the trade as the following in the mod file:

pi = ( Rd(-1) * E / E(-1) - Rb(-1) ) * q(-1)

Clearly, the profits in any period depend on 4 variables that were determined in the previous period: the two gross interest rates that pay out today (but were already known in previous period), the exchange rate in previous period and the size of the position that was put on, again known in the previous period.

Now to the question. If I simulate the model for t time periods (using stoch_simul), that will give me a time series of length t for each variable.

From those, I can construct the analogue of the realised carry trade profits from the simulated variables as follows:

profits = ( Rd(1:end-1) .* E(2:end) ./ E(1:end-1) - Rb(1:end-1) ) .* q(1:end-1)

However, if I compare this with the vector that is directly generated by the simulation, i.e. pi, the two do not match. Why is it that “pi” does not equal “profits” in the above?