# How does Kalman filtering of beta in pairs trading model work in R?

Could anyone show how this could be done in R? The dlm package seems to be a good start, but I can't really find any good examples to learn from.

Currently I have two timeseries of the closing prices for two stocks. I then do a rolling regression that gives me the corresponding timeseries of the beta between the two stocks.

How would I go about to implement a Kalman filter for this beta?

-