# Converting the covariance matrix in DYNARE from logs to levels

Hello,

I am wondering if there is a formula to convert the covariance matrix(oo_.gamma_y{1}) in DYNARE that is in log deviations to covariance matrix in levels. To be more precise, assume that in model part you have variables in logs such as
exp[C] and exp[Y]
Then after stoch_simul you retrieve the covariance matrix with oo_.gamma_y{1}) and get
cov (log[C],log[Y])

I am wondering how to go to cov(Y,C) from cov (log[C],log[Y])

Thanks a lot for your help

I am not aware of an easy method. Due to Jensen’s Inequality, one cannot easily work with the Jacobian transformation.

Thanks Johannes for the answer. I am wondering which of the following approaches would make it easier to deal with this issue

1. Run the original dynare file in LEVELS, so that the covariance matrix I would get is also going to be in levels and then i can get the relevant moments. But I am not sure if that could cause some technical problems.

2. Run the dynare file with log deviations (i.e define variables as exp©) but when you look at the covariance matrix of deviations assume that for small deviations log deviation and level deviatons are equivalent. using log(1+e)=e for small e, One could argue that log deviations around steady state are equivalent to level deviations log(xt)-log(xbar)=(xt-xbar)/xbar

Thanks a lot and again wish you a wonderful weekend

I would go for option 3. Take your mod-file in log-deviations and define an auxiliary variable
y_level=exp(y)

Sidenote: I do not understand your approach 2. If you want level deviations, you are interested in x_t-x, not \frac{x_t-x}{x}.

Thanks Johannes,

by approach 2 i meant to say

if variables are expressed in model part of dynare as exp(x) then the covariance matrix is going to be E{ (log[ x_t ]-log[xbar] ) (log[ Y_t ]-log[Ybar] ) }
but using log(1+epsilon)=epsilon then i can rewrite the above expression as

E{ (log[ x_t ]-log[xbar] ) * (log[ Y_t ]-log[Ybar] ) }=xbarYbarE{ ( x_t -xbar ) ( Y_t -Ybar ) }

but not sure if this will give the same result. these nested first order approximations might cause some problems

Thanks for the suggestion option 3 :))

appreciate your help and wish you a wonderful weekend