PACE function

Univariate functional principal component analysis by smoothed covariance

Univariate functional principal component analysis by smoothed covariance

This function calculates a univariate functional principal components analysis by smoothed covariance based on code from fpca.sc in package refund .

PACE( funDataObject, predData = NULL, nbasis = 10, pve = 0.99, npc = NULL, makePD = FALSE, cov.weight.type = "none" )

Arguments

  • funDataObject: An object of class funData or irregFunData containing the functional data observed, for which the functional principal component analysis is calculated. If the data is sampled irregularly (i.e. of class irregFunData), funDataObject is transformed to a funData object first.
  • predData: An object of class funData, for which estimated trajectories based on a truncated Karhunen-Loeve representation should be estimated. Defaults to NULL, which implies prediction for the given data.
  • nbasis: An integer, representing the number of B-spline basis functions used for estimation of the mean function and bivariate smoothing of the covariance surface. Defaults to 10 (cf. fpca.sc in refund ).
  • pve: A numeric value between 0 and 1, the proportion of variance explained: used to choose the number of principal components. Defaults to 0.99 (cf. fpca.sc in refund ).
  • npc: An integer, giving a prespecified value for the number of principal components. Defaults to NULL. If given, this overrides pve (cf. fpca.sc in refund ).
  • makePD: Logical: should positive definiteness be enforced for the covariance surface estimate? Defaults to FALSE (cf. fpca.sc in refund ).
  • 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

  • mu: A funData object with one observation, corresponding to the mean function. - values: A vector containing the estimated eigenvalues. - functions: A funData object containing the estimated functional principal components. - scores: An matrix of estimated scores for the observations in funDataObject. Each row corresponds to the scores of one observation. - fit: A funData object containing the estimated trajectories based on the truncated Karhunen-Loeve representation and the estimated scores and functional principal components for predData (if this is not NULL) or funDataObject

    (if predData is NULL). - npc: The number of functional principal components: either the supplied npc, or the minimum number of basis functions needed to explain proportion pve of the variance in the observed curves (cf. fpca.sc in refund ).

  • sigma2: The estimated measurement error variance (cf. fpca.sc in refund ). - estVar: The estimated smooth variance function of the data.

Warning

This function works only for univariate functional data observed on one-dimensional domains.

Examples

oldPar <- par(no.readonly = TRUE) # simulate data sim <- simFunData(argvals = seq(-1,1,0.01), M = 5, eFunType = "Poly", eValType = "exponential", N = 100) # calculate univariate FPCA pca <- PACE(sim$simData, npc = 5) # Plot the results par(mfrow = c(1,2)) plot(sim$trueFuns, lwd = 2, main = "Eigenfunctions") # flip estimated functions for correct signs plot(flipFuns(sim$trueFuns,pca$functions), lty = 2, add = TRUE) legend("bottomright", c("True", "Estimate"), lwd = c(2,1), lty = c(1,2)) plot(sim$simData, lwd = 2, main = "Some Observations", obs = 1:7) plot(pca$fit, lty = 2, obs = 1:7, add = TRUE) # estimates are almost equal to true values legend("bottomright", c("True", "Estimate"), lwd = c(2,1), lty = c(1,2)) par(oldPar)

See Also

funData, fpcaBasis, univDecomp