How to ensure covariance matrix is positive semi definite in linear dynamical model learning?

I am trying to learn a linear dynamical model for a data using expectation-maximization algorithm. The model is defined as follows: $$x_0 \sim \mathcal{N}(\mu_0 ,\Sigma_0)$$ $$x_{t+1} = Fx_t + w_t, \hspace{7pt} w_t\sim \mathcal{N}(\mu^s ,Q)$$ $$y_t = Hx_t+v_t, \hspace{7pt} v_t \sim \mathcal{N}(\mu^o,R)$$ where $x_t$ represents the the state vector at time $t$, $y_t$ is the observation vector at time $t$. All the parameters of the LDM remain constant over time. The parameters are estimated using EM algorithm as given here. $w_t$ and $v_t$ in the linked paper are zero mean, so the expressions were modified appropriately. After the maximisation step of each iteration, the covariance matrix of the observation noise $R$, is not necessarily coming out to be positive semi-definite. Is it guaranteed that the covariance matrix obtained after the maximisation step is positive semi-definite?

If yes, then what could I have been possibly doing wrong. If no, then what are the possible solutions here?

The expression for the observation noise covariance matrix in the maximisation step is given by:

$$R = \frac{1}{T}(\Gamma_1 - H_{new} \Gamma_2^\intercal - \mu^o_{new} \zeta_1^\intercal )$$ where $H_{new}$ is the newly estimated matrix that maps the state space vector to the observation vector, $T$ are the number of observations, $\mu^o$ is the newly estimated mean of the observation noise, $$\Gamma_1 = \sum_t y_ty_t^\intercal$$ $$\Gamma_2 = \sum_t y_t \hat{x}_{t|T}^\intercal$$ $\hat{x}_{t|T}$ are the estimated state vectors using Kalman smoothing given all the $T$ observation vectors. $$\zeta = \sum_t y_t$$

The snippet for the above expression for $R$ from the above linked paper is shown below:

In the snippet, the observation noise is zero mean, so the last term in the expression of $R$ is missing. Also it uses $C$ for $H$

A similar problem is being experienced when estimating the covariance matrix $Q$.

• It would be easier to help if you wrote our your model, or just said more. I don't think this is enough information to diagnose your problem. – Taylor Feb 23 '17 at 1:52
• If $x$ is the state and $H$ maps the state to the observation, why is $H$ hitting $y$ and not $x$? What is that middle term for? Is $R$ the marginal covariance of the observations, or is it conditional on the current state? If the latter, why not subtract the expected emission $H\hat x_{t|T}$ from the observed emission inside the first term? – eric_kernfeld Feb 23 '17 at 3:19
• You could get some ideas here: pdfs.semanticscholar.org/2ff5/… – kjetil b halvorsen Feb 23 '17 at 20:22