fpcaBasis: Calculate a functional principal component basis...

Description Usage Arguments Value See Also Examples

View source: R/univDecomp.R

Description

This function calculates a functional principal component basis representation for functional data on one-dimensional domains. The FPCA is calculated via the PACE function, which is built on fpca.sc in the refund package.

Usage

1
2
fpcaBasis(funDataObject, nbasis = 10, pve = 0.99, npc = NULL,
  makePD = FALSE, cov.weight.type = "none")

Arguments

funDataObject

An object of class funData containing the observed functional data samples and for which the FPCA is to be calculated.

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).

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).

npc

An integer, giving a prespecified value for the number of principal components. Defaults to NULL. If given, this overrides pve (cf. fpca.sc).

makePD

Logical: should positive definiteness be enforced for the covariance surface estimate? Defaults to FALSE (cf. fpca.sc).

cov.weight.type

The type of weighting used for the smooth covariance estimate in PACE. Defaults to "none", i.e. no weighting. Alternatively, "counts" (corresponds to fpca.sc ) weights the pointwise estimates of the covariance function by the number of observation points.

Value

scores

A matrix of scores (coefficients) with dimension N x K, reflecting the weights for each principal component in each observation, where N is the number of observations in funDataObject and K is the number of functional principal components.

ortho

Logical, set to TRUE, as basis functions are orthonormal.

functions

A functional data object, representing the functional principal component basis functions.

meanFunction

The smoothed mean function.

See Also

univDecomp, PACE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# simulate N = 100 observations of functional data based on polynomial eigenfunctions on [0,1]
sim <- simFunData(argvals = seq(0,1,0.01), M = 5, eFunType = "Poly", eValType = "linear", N = 100)

# estimate the first 5 functional principal components from the data
fpca <- MFPCA:::fpcaBasis(sim$simData, npc = 5)

oldpar <- par(no.readonly = TRUE)
par(mfrow = c(1,2))
plot(sim$trueFuns, obs = 1:5, main = "True eigenfunctions")
plot(fpca$functions, main = "Estimated eigenfunctions")

# Flip if necessary
plot(sim$trueFuns, obs = 1:5, main = "True eigenfunctions")
plot(flipFuns(sim$trueFuns[1:5], fpca$functions),
     main = "Estimated eigenfunctions\n(flipped)")

par(oldpar)

MFPCA documentation built on May 2, 2019, 2:49 p.m.