Fits a linear model or other regression method to to lagged elements, using the Tower approach. Here k is the number of nearest neighbors as in toweranNA. Currently predicts only the component that is just past the end of the data.
towerTS(xts,lag,k,regFtnName='lm')
Arguments
xts: A time series.
lag: Lag. A positive integer.
regFtnName: Regression model to be used, currently 'lm', 'glm' (family=binomial), or 'towerKNN'.
k: k nearest neighbors
Details
See ?towerLM and ?regtools::TStoX
Returns
Predicted value for the next item in the series.
Author(s)
Norm Matloff, Pete Mohanty
Examples
# create noisy cylcic series set.seed(2020)x <- rnorm(1000)x <- runif(1000)* sin(x)+ rnorm(1000)w <- x
# introduce 10 percent missingnessx[sample(1000,100)]<-NA# make predictions with lag 3 using k=4 nearest neighbors towerTS(x, lag=10, k=4)# -0.1685019