# Maximum likelihood parameter estimation for state space model (Kalman Filter)

it´s about a state space model that I want to run using the Kalman filter. However, certain parameters are unknown and must be estimated by the maximum likelihood method. The state space model is as follows: Alpha evolves according to an autoregressive process. If we use the following notation we get the following system

\begin{align} \alpha_{t+1} &= (1-G)B+G\alpha_{t}+\phi^ix_t+v^i_{t+1} \\ R^i_{i+1}&=\beta^i_{i+1}R^M_{t+1}+\eta^i_{t+1}\\ B&=B: \text{unobserved} \end{align}

$$x_t$$ is a two-dimensional vector with known stationary exogenous state variables. If we use the following notation:

$$\xi_t= \left(\begin{array}{c} B \\ \alpha_t \end{array}\right)$$ $$\widetilde{G}= \left( \begin{array}{ll} 1 & 0 \\ 1-G & G \\ \end{array}\right)$$ $$V_{t+1}= \left(\begin{array}{c} 0 \\ v_{t+1} \end{array}\right)$$ $$\Phi_{t}= \left(\begin{array}{c} 0^T \\ \phi^T \end{array}\right)$$ $$H_t= \left(\begin{array}{c} 0 \\ R^M_t \end{array}\right)$$

where 0 is a vector of zeros of the same dimension as $$x_t$$

we get the following system

\begin{align} \xi_{i+1}&= \widetilde{G}\xi_t+\phi x_t + V_{t+1} \\ R_{t}&= H^T\xi_t +\eta_t \end{align}

The autoregressive parameter G, the standard deviations of error terms $$(\sigma_\eta)^2$$ and $$(\sigma_v)^2$$, and the loadings on the conditioning variables $$\phi$$ should be estimated using maximum likelihood on the whole history of portfolio returns $$R_t$$,the market returns $$R^M_t$$, and the state variables $$x_t$$.

I have read in books that yes there are different likelihood functions according to state space model and parameters already known. Unfortunately, I am not sure which likelihood function is the correct one. Is there a concrete function in Python/Matlab/R that provide a function or package for exactly this case to determine these parameters via ML? I know that for such a system in a paper the parameters were determined. Unfortunately, it was not discussed how to implement this concretely.

I would really appreciate any help.

With kind regards

New contributor
Marv91 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.