To implement the conditional variance of x, I use

A=x(+1)

cond_var=x(+1)^2 –A^2

According to Jensen’s inequality con_var should always be positive. Using 3rd order simulation I find that cond_var is on average positive but is sometimes negative. Any views on this?

It seems to be related to the imprecision of the numerical approximation. So I take it out of the dynare and use more stable numerical methods to compute the variance.