Skip to contents

Compute fucntional coefficients from functional data (fdata class object) represented in a basis (fixed of data-driven basis).

Usage

fdata2basis(fdataobj, basis, method = c("grid", "inprod"))

# S3 method for class 'basis.fdata'
summary(object, draw = TRUE, index = NULL, ...)

Arguments

fdataobj

fdata class object.

basis

a functional basis object defining the basis

method

character string, if it is "grid" the fdata object is evaluated in the grid (argvals of fdata), if it is "inprod" the basis representation of functional data is computed by inner product (inprod.fdata(fdataobj,basis)).

object

basis.fdata class object calculated by: fdata2basis

draw

logical, original curves and their basis representation are plotted

index

vector, by default (if NULL) the first n curves are plotted, where n = min(4, length(fdataobj)). Otherwise, index vector indicates taht curvesare plotted.

...

Further arguments passed to or from other methods.

Value

The fdata2basis function returns:

  • coef: A matrix or two-dimensional array of coefficients.

  • basis: Basis of fdata class evaluated on the same grid as fdataobj.

And summary function return:

  • R: a matrix with a measure similar to R-sq for each curve aproximation (by row) and number of basis elements (by column).

See also

Inverse function: gridfdata. Alternative method: fdata2pc, fdata2pls.

Author

Manuel Febrero-Bande, Manuel Oviedo de la Fuente manuel.oviedo@usc.es

Examples

if (FALSE) { # \dontrun{
T <- 71
S <- 51
tj <- round(seq(0,1,len=T),3)
si <- round(seq(0,1,len=S),3)
beta1 <- outer(si,tj,function(si,tj){exp(-5*abs((tj-si)/5))})
nbasis.s =7
nbasis.t=11
base.s <- create.fourier.basis(c(0,1),nbasis=nbasis.s)
base.t <- create.fourier.basis(c(0,1),nbasis=nbasis.t)
y1 <- fdata(rbind(log(1+tj),1-5*(tj-0.5)^2),argvals=tj,rangeval=c(0,1))
aa <- fdata2basis(y1,base.t,method="inprod")
summary(aa)
plot(gridfdata(aa$coefs,aa$basis))
lines(y1,lwd=2,col=c(3,4),lty=2)
} # }