Learn R Programming

ddalpha (version 1.3.16)

FKS: Fast Kernel Smoothing

Description

Produces a kernel smoothed version of a function based on the vectors given in the input. Bandwidth is selected using cross-validation.

Usage

FKS(dataf, Tout, kernel = c("uniform", "triangular", "Epanechnikov",
  "biweight", "triweight", "Gaussian"), m = 51, K = 20)

Value

A dataf object corresponding to Tout of smoothed functional values.

Arguments

dataf

A set of functional data given by a dataf object that are to be smoothed.

Tout

vector of values in the domain of the functions at which the resulting smoothed function is evaluated

kernel

Kernel used for smoothing. Admissible values are uniform, triangular, Epanechnikov, biweight, triweight and Gaussian. By default, uniform is used.

m

Number of points in the grid for choosing the cross-validated bandwidth.

K

Performs K-fold cross-validation based on randomly shuffled data.

Author

Stanislav Nagy, nagy@karlin.mff.cuni.cz

Details

A vector of the same length as Tout corresponding to the values of the function produced using kernel smoothing, is provided. Bandwidth is selected using the K-fold cross-validation of randomly shuffled input values.

Examples

Run this code
d = 10
T = sort(runif(d))
X = T^2+ rnorm(d,sd=.1)
Tout = seq(0,1,length=101)

plot(T,X)
dataf = list(list(args=T,vals=X))
data.sm = FKS(dataf,Tout,kernel="Epan")
lines(data.sm[[1]]$args,data.sm[[1]]$vals,col=2)

datafs = structure(list(dataf=dataf,labels=1:length(dataf)),class="functional")
plot(datafs)
points(T,X)
data.sms = structure(list(dataf=data.sm,labels=1:length(data.sm)),class="functional")
plot(data.sms)

n = 6
dataf = list()
for(i in 1:n) dataf[[i]] = list(args = T<-sort(runif(d)), vals = T^2 + rnorm(d,sd=.1))
data.sm = FKS(dataf,Tout,kernel="triweight")
data.sms = structure(list(dataf=data.sm,labels=1:length(data.sm)),class="functional")
plot(data.sms)

Run the code above in your browser using DataLab