# Conditional variance of variables in the model block

Dear Professor Pfeifer,

Do you have an idea whether it is possible to define the conditional variance of an endogenous variable (say x_t) within a model in DYNARE. In particular, I have empirical data on the conditional variance of output-gap-growth and would like to use it as an observable for a Bayesian estimation. The model is solved with second order approximation. Concretely, if x_t is the growth of the output gap, I’d like to have a new variable “CV” corresponding to the conditional variance

E_t[x_{t+1} - E_t(x_{t+1})]^2 .

I tried by specifying in DYNARE:

CV=EXPECTATION(0)(x(+1) - EXPECTATION(0)(x(+1)))^2;

but it seems to be a constant. Is the specification of CV wrong? Note, that the model is a replication of the New-Keynesian-Vulnerability (NKV) by Adrian et al (2020), where one of the shocks is assumed to have conditional heteroscedasticity. I.e., there is a shock with a time varying standard deviation V(X), where the function V(X) depends on endogenous and exogenous state variables.

The MOD-File is attached. I’m happy to provide further information on the model.

conditional_variance.mod (1.9 KB)

Have a look at DSGE_mod/Basu_Bundick_2017.mod at master · JohannesPfeifer/DSGE_mod · GitHub
It contains the conditional variance of equity returns, but uses third order.

Thank you very much for your response!

I have implemented the conditional variance. As in Adrian et al (2020), I first linearized my model and then added a term that is multiplied by the demand shock. This term consists of endogenous state variables. This makes the model linear-quadratic. Estimating order one without this quadratic term worked well. However, when I try to estimate the model with higher order approximations and the quadratic term, I keep running into the same error:

``````ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: If this is not a problem with the setting of options (check the error message below),
ESTIMATION_CHECKS: you should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):

Error using chol
Matrix must be positive definite.
(...)
``````

I tried different specifications, but I could not solve the problem. Sometimes the kernel density maximization started but stopped after one iteration.

Please find the .mod file and data attached. I would be grateful if you could take a look at it.
Particle Filter.zip (43.6 KB)

The problem is that your using `order=3` with the particle filter, which relies on simulations. These simulations can be explosive unless `pruning` is used. However, the particle filter routines in Dynare currently do not allow for pruning at order=3.