# Issue with the Kalman filter

Hi all,

I am very new to Dynare, but I have studied the program to the point where I have written a very simple model. This model seems to function well (steady states and simulation work fine), but the estimation of the model persistently fails with the error message:
“The forecast error variance in the multivariate Kalman filter became singular.”

I have tried several things to round the issue, but with very little success.
All tips to solve as well as explanations why this error rises would be very very much appreciated!

Basic_model.mod (1.1 KB)
Model_estimation.mod (2.0 KB)
data.xlsx (11.6 KB)

The problem is known as “stochastic singularity”, which happens if a linearized model implies an exact linear combination between observables. That in turn means that the density of observing that variables is either 1 (the exact linear combination in the model holds in the data; rarely the case) or 0 (the exact linear combination does not hold; the typical case). As you can imagine with a log density of minus infinity, estimation will not work.

exp(y_tilde) = exp(k_tilde)^(alph);


But you observe k and y. That’s where the problem comes from. The model says that the ratio of y and k is a constant \alpha. Plotting the ratio shows that this is not the case in the data:

Hello professor Pfeifer and thank you very much for your prompt reply!

I do understand the issue now, but I still don’t know how to get around the problem. I have tried e.g.:

a) To use only one observable variable in the estimation (Dynare shouldn’t be able to decide if the data contains exact linear combination or not if there is only one observable)
→ In case a) I still get the error message and the estimation does not work.

b) Adding a measurement error to the observables to tell Dynare that the linear combination does not hold in the observed data when there are more than one observed variables
→ In case b) the estimation goes through, but all variation is accounted to the measurement errors. Furthermore, the posteriors of the estimations appear to coincide with the prior distributions since everything is accounted to the measurement error.

c) Adding new shocks, e.g. TFP shock to production function that follows AR1-structure, to break an exact linear combination.
→ Still, Dynare does not compute the simulation and the same error message come up.

Is there something else that I could try or am I missing something / doing some elementary mistakes in the code/data?

Another question that has puzzled me regarding Dynare:
I would prefer if the shocks on b-variables could only get values from the positive side of the normal distribution). How does Dynare/estimation react if I force the normally distributed shocks to follow some Gamma distribution by squaring the shocks? Or is there some other way to force the shocks positive (that would also work in the estimation)?

1. Use
stoch_simul(irf=0,order=1);


to verify that all of your variables are constant as they are not affected by the shocks. That explains the error message.
2. Regarding non-normal shocks, first have a look at previous posts like Models with non-normal shocks (Non-linear transformation of shocks)

Oh, there was an elementary mistake with the shock process!
Thank you very much for pointing out the two problems I had and for nudging me back on track! I will go through earlier chats regarding non-normal shocks too.