I try to implement a RLS of x on y and here is my formula. unfortunately it does not work. X and Y are both time series.
## input for recursive algorithm
int <- rep(1, length(unempl.1))
x <- cbind(int, infl.1, infl.2, infl.3, unempl.1, unempl.2, unempl.3, unempl.4)
y <- infl
## recursive algorithm
ist = 6
xpxi = NULL
xpy0 = NULL
if(!is.matrix(x))x=as.matrix(x)
nT=dim(x)[1]
k=dim(x)[2]
#
if(is.null(xpxi)){
if(ist <= k)ist=k+1
xpx0=t(x[1:ist,])%*%x[1:ist,]
xpxi=solve(xpx0)
xpy0=t(x[1:ist,])%*%matrix(y[1:ist],ist,1)
}
ist=ist+1
resi=NULL
beta=matrix(c(xpxi%*%xpy0),1,k)
r=matrix(xpxi,1,k)
for (t in ist:nT){
r=shift(r)+t^-1*(t(x[1:ist,])%*%x[1:ist,]-shift(r))
beta=shift(beta)+x%*%(y[t]-shift(beta)%*%t(x))/r/t
}
beta=beta[-1,]