fpcscore {cvmaPLFAM}R Documentation

Calculate functional principal component (fpc) scores

Description

Conduct functional principal component analysis (FPCA) on the observation matrix of the functional predictor.

Usage

fpcscore(Z, nbasis, tt)

Arguments

Z

An n by nT matrix. The recording/measurement matrix of the functional predictor.

nbasis

The number of basis functions used for spline approximation.

tt

The vector of recording/measurement points for the functional predictor.

Value

A list of

score

An n by nbasis matrix. The estimated functional principal component scores.

eigv

A vector of estimated eigen-values related to FPCA.

varp

A vector of percents of variance explained related to FPCA.

Examples

# Generate a recording/measurement matrix of the functional predictor
fddata = matrix(rnorm(1000), nrow = 10, ncol = 100)
tpoints = seq(0, 1, length.out = 100)

library(fda)
# Using 20 basis functions for spline approximation
fpcscore(fddata, nbasis = 20, tt = tpoints)

# Generate simulated data
simdata = data_gen(R = 0.7, K = 1, n = 20, M0 = 20, typ = 1, design = 1)
# Extract functional data from 'simdata', columns (M0+1):(M0+100)
simfd = simdata[[1]][,21:120]
# Calculate fpc scores
fpcres = fpcscore(simfd, nbasis = 50, tt = seq(0, 1, length.out = 100))
fpcres$score
fpcres$eigv
cumsum(fpcres$varp)


[Package cvmaPLFAM version 0.1.0 Index]