fknn.forecast: Functional knn forecasting

View source: R/fknn.forecast.R

fknn.forecastR Documentation

Functional knn forecasting

Description

Functional knn forecasting

Usage

fknn.forecast(data, focal, k, h, distance, typePoint, theta = 1)

Arguments

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.

Value

a matrix containing the point forecast.

Examples


# 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)


aefdz/nnFTS documentation built on March 17, 2023, 3:22 a.m.