Learn R Programming

cSFM (version 1.1)

uni.fpca: Functional Principle Component Analysis with Corpula

Description

uni.fpca is used to do regular FPCA for univariate data with given covariance matrix. The sample covariance matrix will be used if covariance matrix is not given.

Usage

uni.fpca(Y, Kendall = NULL, Y.pred = NULL, 
         nbasis.mean = 10, nbasis = 10, pve = 0.99, npc = NULL, 
         center = TRUE, gam.method = "REML")

Arguments

Y
matrix for the fully observed curves; each row corresponds to one subject
Kendall
given covariance matrix for Y (raw matrix up to smoothing); typically obtained using Kendall's Tau approach. See 'Details'
Y.pred
partically observed curves to be predicted; default is null indicating no predication on new data set
nbasis.mean
number of basis functions to smooth the mean
nbasis
number of basis functions for each direction to smooth the covariance matrix
pve
threshold of the percentage of variance explained to select number of principal components
npc
prespecified value for the number of principal components to be included in the expansion (if given, this overrides 'pve').
center
if TRUE, we center the curves; otherwise, do not center the curves and assume the curves have mean 0 already
gam.method
estimation method when using gam

Value

  • A list of the following components:
  • Yhatmatrix whose rows are the estimates through Functional FPCA of the curves in Y
  • scoresmatrix of estimated principal component scores
  • muestimated mean function
  • efunctionsmatrix of estimated eigenfunctions of the functional covariance operator, i.e., the FPC basis functions
  • evaluesestimated eigenvalues of the covariance operator, i.e., variances of FPC scores
  • npcnumber of FPCs: either the supplied npc, or the minimum number of basis functions needed to explain proportion pve of the variance in the observed curves
  • K.tildeSmoothed covariance matrix of Y after removing white noises
  • K.hatSmoothed covariance matrix of Y
  • sigma2estimated measurement error variance

Details

This function is build in the spirit of the function fpca.sc in the package refund, but here the corpula plays a role. The covariance matrix Kendall is typically estimated before the application of this function, for instance, via Kendall's Tau approach. It is highly recommended that the Knedall's Tau covariance matris should be provided here since it is more stable.

References

[1]. Yao, F., Mueller, H.-G., and Wang, J.-L. (2005). Functional data analysis for sparse longitudinal data. Journal of the American Statistical Association, 100(470):577-590.

[2]. Goldsmith, J., Greven, S., and Crainiceanu, C. (2013). Corrected confidence bands for functional data using principal components. Biometrics, 69(1), 41-51.

Examples

Run this code
data(data.simulation)
fpca <- uni.fpca(Y = DST$obs, Y.pred=DSV$obs)

# visualize the data and predicted surface
par(mfrow = c(1,2))
persp(DSV$cp, DSV$tp, DSV$obs, theta=60, phi=15,
      ticktype = "detailed", col="lightblue", 
      xlab = "covariate", ylab = "time",
      zlab="data", main="data surface (partically observed)")
persp(DSV$cp, DSV$tp, fpca$Yhat, theta=60, phi=15,
      ticktype = "detailed", col="lightblue", 
      xlab = "covariate", ylab = "time",
      zlab="data", main="predicted surface via univariate FPCA")

# predication error
mean(((fpca$Yhat - DSV$obs.full)[!is.na(DSV$obs)])^2)

Run the code above in your browser using DataLab