forked from gbonte/gbcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKNN.acf.Rd
More file actions
64 lines (55 loc) · 1.71 KB
/
Copy pathKNN.acf.Rd
File metadata and controls
64 lines (55 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mstep.R
\name{KNN.acf}
\alias{KNN.acf}
\title{KNN.acf}
\usage{
KNN.acf(X, Y, X.ts, k = 10, dist = "euclidean", C = 2, F = 0, Acf, Pacf,
TS, del = 0)
}
\arguments{
\item{X:}{training input [N,n]}
\item{Y:}{training output [N,m]}
\item{X.ts:}{test input [N.ts,n]}
\item{k:}{min number of neighbours}
\item{dist:}{type of distance: \code{euclidean, cosine}}
\item{F:}{forgetting factor}
\item{C:}{integer parameter which sets the maximum number of neighbours (Ck)}
\item{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}
\item{Acf:}{autocorrelation function of the training series}
}
\value{
vector of N.ts predictions
}
\description{
Multioutput KNN
}
\details{
KNN.acf
Multioutput KNN for multi-step-ahed prediction. It performs a locally constant model with weighted combination of local model on the basis of the dynamic properties of the training time series.
}
\examples{
## Multi-step ahead time series forecasting
library(lazy)
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)
Y.cont<-KNN.acf(X,Y,rev(TS.tr[(N.tr-H):N.tr]),TS=TS.tr)
plot(t[(N-H+1):N],TS.ts)
lines(t[(N-H+1):N],Y.cont)
}
\references{
\emph{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}
}
\author{
Gianluca Bontempi \email{gbonte@ulb.ac.be}
}