Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predict.FPCA

Predict FPC scores and curves for a new sample given an FPCA object


Description

Return a list containing the matrix with the first k FPC scores according to conditional expectation or numerical integration, the matrix of predicted trajectories and the prediction work grid.

Usage

## S3 method for class 'FPCA'
predict(object, newLy, newLt, sigma2 = NULL, K = NULL, xiMethod = "CE", ...)

Arguments

object

An FPCA object.

newLy

A list of n vectors containing the observed values for each individual.

newLt

A list of n vectors containing the observation time points for each individual corresponding to y.

sigma2

The user-defined measurement error variance. A positive scalar. (default: rho if applicable, otherwise sigma2 if applicable, otherwise 0 if no error. )

K

The scalar defining the number of clusters to define; (default: from user-specified FPCA Object).

xiMethod

The integration method used to calculate the functional principal component scores (standard numerical integration 'IN' or conditional expectation 'CE'); default: 'CE'.

...

Not used.

Value

A list containing the following fields:

scores

A matrix of size n-by-k which comprise of the predicted functional principal component scores.

predCurves

A matrix of size n-by-l where l is the length of the work grid in object.

predGrid

A vector of length l which is the output grid of the predicted curves. This is same is the workgrid of object.

Examples

set.seed(1)
n <- 50
pts <- seq(0, 1, by=0.05)
# The first n samples are for training and the rest testing
sampWiener <- Wiener(2 * n, pts)
sparsity <- 2:5
train <- Sparsify(sampWiener[seq_len(n), , drop=FALSE], pts, sparsity)
test <- Sparsify(sampWiener[seq(n + 1, 2 * n), , drop=FALSE], pts, sparsity)
res <- FPCA(train$Ly, train$Lt)
pred <- predict(res, test$Ly, test$Lt, K=3)
plot(pred$predGrid, pred$predCurves[1,])

fdapace

Functional Data Analysis and Empirical Dynamics

v0.5.6
BSD_3_clause + file LICENSE
Authors
Cody Carroll [aut, cre] (<https://orcid.org/0000-0003-3525-8653>), Alvaro Gajardo [aut], Yaqing Chen [aut], Xiongtao Dai [aut], Jianing Fan [aut], Pantelis Z. Hadjipantelis [aut], Kyunghee Han [aut], Hao Ji [aut], Shu-Chin Lin [ctb], Paromita Dubey [ctb], Hans-Georg Mueller [cph, ths, aut], Jane-Ling Wang [cph, ths, aut]
Initial release
2021-01-10,

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.