mfpca: Functional principal component analysis for univariate or...

Description Usage Arguments Value Examples

View source: R/mfpca.R

Description

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

Usage

1
  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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
  ####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)

funHDDC documentation built on March 17, 2021, 5:06 p.m.