Learn R Programming

fda.usc (version 1.2.3)

min.np: Smoothing of functional data using nonparametric kernel estimation

Description

Smoothing of functional data using nonparametric kernel estimation with cross-validation (CV) or generalized cross-validation (GCV) methods.

Usage

## S3 method for class 'np':
min(fdataobj,h=NULL,W=NULL,Ker=Ker.norm,
type.CV=GCV.S,type.S=S.NW,par.CV=list(trim=0,draw=FALSE),
verbose=FALSE,...)

Arguments

fdataobj
fdata class object.
h
Smoothing parameter or bandwidth.
W
Matrix of weights.
Ker
Type of kernel used, by default normal kernel.
type.CV
Type of cross-validation. By default generalized cross-validation (GCV) method. Possible values are GCV.S and CV.S
type.S
Type of smothing matrix S. By default S is calculated by Nadaraya-Watson kernel estimator (S.NW). Possible values are S.NW and S.KNN
par.CV
List of parameters for type.CV: trim, the alpha of the trimming and draw=TRUE.
verbose
If TRUE information about GCV values and input parameters is printed. Default is FALSE.
...
Further arguments passed to or from other methods. Arguments to be passed for kernel method.

Value

  • Returns GCV or CV values calculated for input parameters.
  • gcvGCV or CV for a vector of values of the smoothing parameter h
  • fdataobjfdata class object.
  • fdata.estEstimated fdata class object.
  • h.opth value that minimizes CV or GCV method.
  • S.optSmoothing matrix for the minimum CV or GCV method.
  • gcv.optMinimum of CV or GCV method.
  • hSmoothing parameter or bandwidth.

Details

Calculate the minimum GCV for a vector of values of the smoothing parameter h. Nonparametric smoothing is performed by the kernel function. The type of kernel to use with the parameter Ker and the type of smothing matrix S to use with the parameter type.S can be selected by the user, see function Kernel. W is the matrix of weights of the discretization points.

References

Ferraty, F. and Vieu, P. (2006). Nonparametric functional data analysis. Springer Series in Statistics, New York. Wasserman, L. All of Nonparametric Statistics. Springer Texts in Statistics, 2006. Hardle, W. Applied Nonparametric Regression. Cambridge University Press, 1994. Febrero-Bande, M., Oviedo de la Fuente, M. (2012). Statistical Computing in Functional Data Analysis: The R Package fda.usc. Journal of Statistical Software, 51(4), 1-28. http://www.jstatsoft.org/v51/i04/

See Also

See Also as S.NW. Alternative method: min.basis

Examples

Run this code
# Exemple, phoneme DATA
data(phoneme)
mlearn<-phoneme$learn[1:100]

out1<-min.np(mlearn,type.CV=CV.S,type.S=S.NW)
np<-ncol(mlearn)
# variance calculations
y<-mlearn
out<-out1
i<-1
z=qnorm(0.025/np)
fdata.est<-out$fdata.est
tt<-y[["argvals"]]
var.e<-Var.e(y,out$S.opt)
var.y<-Var.y(y,out$S.opt)
var.y2<-Var.y(y,out$S.opt,var.e)

# plot estimated fdata and point confidence interval
upper.var.e<-fdata.est[i,]-z*sqrt(diag(var.e))
lower.var.e<-fdata.est[i,]+z*sqrt(diag(var.e))
dev.new()
plot(y[i,],lwd=1,
ylim=c(min(lower.var.e$data),max(upper.var.e$data)),xlab="t")
lines(fdata.est[i,],col=gray(.1),lwd=1)
lines(fdata.est[i,]+z*sqrt(diag(var.y)),col=gray(0.7),lwd=2)
lines(fdata.est[i,]-z*sqrt(diag(var.y)),col=gray(0.7),lwd=2)
lines(upper.var.e,col=gray(.3),lwd=2,lty=2)
lines(lower.var.e,col=gray(.3),lwd=2,lty=2)
legend("bottom",legend=c("Var.y","Var.error"),
col = c(gray(0.7),gray(0.3)),lty=c(1,2))

Run the code above in your browser using DataLab