KNN.acf.lin | R Documentation |
Multioutput KNN
X: |
training input [N,n] |
Y: |
training output [N,m] |
X.ts: |
test input [N.ts,n] |
k: |
min number of neighbours |
dist: |
type of distance: |
F: |
forgetting factor |
C: |
integer parameter which sets the maximum number of neighbours (Ck) |
wta: |
if TRUE a winner-takes-all strategy is used; otherwise a weigthed combination is done on the basis of the l-o-o error |
Acf: |
autocorrelation function of the training series |
Reg: |
number (>1) of null terms to regularise the mean |
KNN.acf.lin
Multioutput KNN for multi-step-ahed prediction. It performs a locally constant model with weighted combination of local model on the basis of the autocorrelation and partial correlation properties of the training time series.
vector of N.ts predictions
Gianluca Bontempi Gianluca.Bontempi@ulb.be
Bontempi G. Ben Taieb S. Conditionally dependent strategies for multiple-step-ahead prediction in local learning, International Journal of Forecasting Volume 27, Issue 3, July–September 2011, Pages 689–699
## Multi-step ahead time series forecasting
require(gbcode)
t=seq(0,200,by=0.1)
N<-length(t)
H<-500 ## horizon prediction
TS<-sin(t)+rnorm(N,sd=0.1)
TS.tr=TS[1:(N-H)]
N.tr<-length(TS.tr)
TS.ts<-TS[(N-H+1):N]
TS.tr=array(TS.tr,c(length(TS.tr),1))
E=MakeEmbedded(TS.tr,n=3,delay=0,hor=H,1)
X<-E$inp
Y<-E$out
N<-NROW(X)
ACF.lag<-5
Y.cont<-KNN.acf.lin(X,Y,rev(TS.tr[(N.tr-H):N.tr]),Acf=acf(TS.tr,lag.max=ACF.lag,plot=FALSE)$acf,Pacf=pacf(TS.tr,lag.max=ACF.lag,plot=FALSE)$acf,TS=TS.tr)
plot(t[(N-H+1):N],TS.ts)
lines(t[(N-H+1):N],Y.cont)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.