View source: R/fknn.forecast.R
fknn.forecast | R Documentation |
Functional knn forecasting
fknn.forecast(data, focal, k, h, distance, typePoint, theta = 1)
data |
matrix PXN being N the total number of functions and P the total number of observed values for each function. The columns are ordered by time from 1 to T. |
focal |
the name of the curve to envelope. In the article, the most recent curve. |
k |
number of nearest neighbourds. |
h |
forecasting horizon. If Dynamic Updating the forecasting horizon, h, will be such that the partially observed part it completed. |
distance |
vector of distances $D(i,N)$, i.e. distance between the last observed curve and the others. |
typePoint |
type of point estimate: "w" for weighted mean and "exp" for exponentially weighted mean. |
theta |
parameter for the "exp" point type. The default value is 1. |
a matrix containing the point forecast.
# One-period-ahead data(electricityDemand) focal <- "saturday/29/12/2018" data <- rainbow::fts(electricityDemand$x, electricityDemand$y[,1:1825]) point <- fknn.forecast(data, focal, k = 5, h = 1, distance = "l2", typePoint = "expw", theta = 1) # DU half day focal <- "monday/31/12/2018" data <- electricityDemand data$y[72:144, focal] <- NA point <- fknn.forecast(data, focal, k = 5, h = 1, distance = "l2", typePoint = "expw", theta = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.