Learn R Programming

funHDDC (version 2.3.1)

mfpca: Functional principal component analysis for univariate or multivariate functional data

Description

It provides functional principal component analysis for univariate or multivariate functional data.

Usage

mfpca(fdobj,center)

Arguments

fdobj

For univariate FPCA: a functional data object produced by fd() function of fda package, for multivariate FPCA: a list of functional data objects.

center

If TRUE (default), it centers each lines of data coefficients by the mean before calculating the FPCA.

Value

eigval

A list of eigen values.

harmonics

A functional data object for the harmonics or eigenfunctions.

scores

A matrix of scores on the harmonics.

varprop

A vector giving the proportion of variance explained by each harmonic.

meanfd

A functional data object giving the mean function after centering (default) or the mean function of raw data.

Examples

Run this code
# NOT RUN {
  ####Univariate case: "Canadian temperature" data (Ramsey & Silverman)
  daybasis65 <- create.fourier.basis(c(0, 365), nbasis=65, period=365)
  daytempfd <- smooth.basis(day.5, CanadianWeather$dailyAv[,,"Temperature.C"], daybasis65,
                                  fdnames=list("Day", "Station", "Deg C"))$fd

  res.pca<-mfpca(daytempfd)
  plot.mfpca(res.pca)


  ####Multivariate case: "Canadian temperature" data (Ramsey & Silverman)
  daybasis65 <- create.fourier.basis(c(0, 365), nbasis=65, period=365)
  daytempfd <- smooth.basis(day.5, CanadianWeather$dailyAv[,,"Temperature.C"], daybasis65,
                                  fdnames=list("Day", "Station", "Deg C"))$fd
  dayprecfd<-smooth.basis(day.5, CanadianWeather$dailyAv[,,"Precipitation.mm"], daybasis65,
                                fdnames=list("Day", "Station", "Mm"))$fd

  res.pca<-mfpca(list(daytempfd,dayprecfd))
  plot.mfpca(res.pca)

# }

Run the code above in your browser using DataLab