fpcaCor: Functional Principal Analysis using Correlation Matrix

Description Usage Arguments Value Examples

View source: R/fpcaCor.R

Description

Extract eigen-functions from smoothed correlation matrix which comes from a Gaussian latent model.

Usage

1
2
3
4
5
6
7
8
fpcaCor(
  X = NULL,
  types = "con",
  argvals = NULL,
  nbasis = 10,
  pve = 0.99,
  npc = NULL
)

Arguments

X

a numeric matrix (n x p). It is supplied by user. Here n is the number of samples and p is the number of observations.

types

a vector of length p representing the type of each of the p variables in X. For our case, it is "con". Users can learn more about it here: latentcor.

argvals

the argument values of the function evaluations in Y, defaults to a equidistant grid from 0 to 1.

nbasis

number of B-spline basis functions used for estimation of the mean function and bivariate smoothing of the covariance surface.

pve

proportion of variance explained: used to choose the number of principal components. It should be supplied by users.The default is 0.99. (See fpca.sc.)

npc

the number of principal components.if it is given, this overrides pve; the default is NULL. (See fpca.sc.)

Value

A list with the elements

npc

The number of principal components. If it is given, the given value. Otherwise it is calculated in the function based on given pve

eigenfuncs

A (p x npc) matrix where its colums are eigenfunction extracted from the smoothed correlation matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#To see the difference when we have 2 different pve values.
# set.seed(53787)
#Create a matrix from Gaussian latent data
X = gaussian_copula_cor(n = 10, ntime = 30)$Y
#Example 1
output1 = fpcaCor(X = X, types = "con", argvals = NULL, nbasis = 10, pve = 0.99, npc = NULL)
## Change pve value to obtain a different number of eigen-functions.
#Example 2
output2 = fpcaCor(X = X, types = "con", argvals = NULL, nbasis = 10, pve = 0.95, npc = NULL)
#Example 3
#If pnc is supplied by user. (npc overrides pve.)
output3 = fpcaCor(X = X, types = "con", argvals = NULL, nbasis = 10, pve = 0.95, npc = 5)

gozdesert/fpcaCor documentation built on Feb. 13, 2022, 6:31 p.m.