'regression of two vectors by kalman filter example

Here is an example of how I do a roll linear regression of two vectors

x <- rnorm(100)
y <- rnorm(100)
res <- rep(NA,length(x))
for(i in 5:length(x)){
  ii <- (i-4):i
   LR <- lm(y[ii]~x[ii])$residuals  
    res[i] <- tail(LR,1)}

I would like to see an example of how this can be done with an adaptive kalman filter

I'm interested in this article but the code examples are too incomprehensible for me, I would like to get a simpler and more understandable use case



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source