Stock beta is an important parameter used in Financial modelling of time series or Value at Risk estimation.
Here we simulate 3 stochastic processes :
1. market index returns - this becomes an input parameter of observation equation
2. stock returns - this becomes the output of observation equation
3. beta parameter - this is the transition equation
After simulating the processes, we start with some arbitrary initial values and use the equations for Kalman filter maximum likelihood estimation to find out the unknown parameters. The optimizer is used to solve the function minima which gives the estimated parameters. Finally the actual beta process is compared with the beta process estimated though the predictor corrector loop of Kalman filter equations.
In the below figure, red line indicates the beta process that was actually generated from simulation. Green line is the beta process using estimated parameters.