This function is a slightly adapted version of the fpca.sc function in the refund package for calculating univariate functional principal components based on a smoothed covariance function. The smoothing basis functions are penalized splines.
Y.pred: A matrix of functions (by row) to be approximated using the functional principal components. Defaults to NULL, i.e. the prediction is made for the functions in Y.
nbasis: An integer, giving the number of B-spline basis to use. Defaults to 10.
pve: A value between 0 and 1, giving the percentage of variance explained in the data by the functional principal components. This value is used to choose the number of principal components. Defaults to 0.99
npc: The number of principal components to be estimated. Defaults to NULL. If given, this overrides pve.
makePD: Logical, should positive definiteness be enforced for the covariance estimate? Defaults to FALSE.
cov.weight.type: The type of weighting used for the smooth covariance estimate. Defaults to "none", i.e. no weighting. Alternatively, "counts" (corresponds to fpca.sc in refund ) weights the pointwise estimates of the covariance function by the number of observation points.
Returns
fit: The approximation of Y.pred (if NULL, the approximation of Y) based on the functional principal components.
scores: A matrix containing the estimated scores (observations by row). - mu: The estimated mean function. - efunctions: A matrix containing the estimated eigenfunctions (by row). - evalues: The estimated eigenvalues. - npc: The number of principal comopnents that were calculated. - sigma2: The estimated variance of the measurement error. - estVar: The estimated smooth variance function of the data.
References
Di, C., Crainiceanu, C., Caffo, B., and Punjabi, N. (2009). Multilevel functional principal component analysis. Annals of Applied Statistics, 3, 458--488. Yao, F., Mueller, H.-G., and Wang, J.-L. (2005). Functional data analysis for sparse longitudinal data. Journal of the American Statistical Association, 100, 577--590.