The code below implements the discrete-time extended Kalman filter (EKF) in R.

For numerical stability and precision the implemented EKF uses a Singular Value Decomposition (SVD) based square root filter. For a description of this SVD-based square root filter see *Appendix B* of Petris and colleagues’ 2009 book *Dynamic linear models with R*. Continue reading R code for implementing the extended Kalman filter