fpca: Functional principal component analysis

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Performs a functional principal component analysis.

Usage

1
fpca(data=data, dimBase=4, fpcCtrl=NULL, regTime=NULL)

Arguments

data

Dataset in "Format1" for irregular or "Format2" for regular time measurements (see formatFuncy).

dimBase

Dimension of the basis.

fpcCtrl

Control object, see fpcCtrl.

regTime

Optional vector of time points if original data is in "Format2".

Details

A functional principal component analysis is executed. Therefore, a smoothed mean curve and a smoothed covariance matrix are built and upon these, eigenvalues and eigenvectors are calculated. If average=TRUE, data is stored in a sparse matrix of dimension (nr_curves x nr_union_time_points) and matrix operations speed up the calculation. However, if the curves do not have many common time points, average should be set to FALSE. If the smoothing parameter (either for the mean or for the covariance) specified in fpcCtrl led to NA-values in the smoothing process, it is automatically increased by 10% of its actual value and a warning is printed. This process is repeated until smoothing is possible.

Value

yreg

Smoothed dataset evaluated at union time points.

time

Vector of union time points.

meanfcn

Smoothed mean function.

covfcn

Smoothed covariance matrix.

base

Basis functions.

eigval

Eigenvalues.

coeffs

Coefficients for the basis functions.

varprop

Proportion of the variance.

Author(s)

Christina Yassouridis

See Also

fpcCtrl

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
##Generate a regular dataset
set.seed(2804)
ds <- sampleFuncy(obsNr=40, timeNr=15, reg=TRUE)

##Execute functional principal component analysis
res <- fpca(Data(ds))
matplot(res$base,type='l')

##Generate an irregular dataset
set.seed(2804)
ds <- sampleFuncy(obsNr=30, k=5, timeNrMin=5, timeNrMax=7, reg=FALSE)

##Execute functional principal component analysis
res <- fpca(Data(ds))
matplot(res$base, type='l', main="First 4 basis functions.")

Example output

Loading required package: flexclust
Loading required package: grid
Loading required package: lattice
Loading required package: modeltools
Loading required package: stats4
Loading required package: splines
Warning message:
In fpc(Yin = Yin, Tin = Tin, Tout = NULL, isobs = isobs, dimBase = dimBase,  :
  Another smoothing parameter-9.192 is used for covariance smoothing on transformed points.
Warning message:
system call failed: Cannot allocate memory 

funcy documentation built on May 2, 2019, 9:22 a.m.

Related to fpca in funcy...