Performs a functional principal component analysis.
Usage
fpca(data=data, dimBase=4, fpcCtrl=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.
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
##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.")