Predict FPC scores
Predict FPC scores using least square estimate (LSE) for a new sample.
## S3 method for class 'KFPCA' predict(object, newLt, newLy, nK, more = FALSE, ...)
object |
A KFPCA object obtained from |
newLt |
A |
newLy |
A |
nK |
An integer denoting the number of FPCs. |
more |
Logical; If |
... |
Not used. |
If more = FALSE
, a n by nK
matrix
containing the predictions of the FPC scores is returned, where n is the new sample size. If more = TRUE
, a list
containing the following components is returned:
score_new |
a n by |
meanest_new |
Mean function estimates at the new observation time points. |
FPC_dis_new |
Eigenfunction estimates at the new observation time points. |
# Generate training data n <- 100 interval <- c(0, 10) lambda_1 <- 9 #the first eigenvalue lambda_2 <- 1.5 #the second eigenvalue eigfun <- list() eigfun[[1]] <- function(x){cos(pi * x/10)/sqrt(5)} eigfun[[2]] <- function(x){sin(pi * x/10)/sqrt(5)} score <- cbind(rnorm(n, 0, sqrt(lambda_1)), rnorm(n, 0, sqrt(lambda_2))) DataNew <- GenDataKL(n, interval = interval, sparse = 6:8, meanfun = function(x){0}, score = score, eigfun = eigfun, sd = sqrt(0.1)) basis <- fda::create.bspline.basis(interval, nbasis = 13, norder = 4, breaks = seq(0, 10, length.out = 11)) Klist <- KFPCA(DataNew$Lt, DataNew$Ly, interval, nK = 2, bw = 1, nRegGrid = 51, fdParobj = basis) # Generate test data n_test <- 20 score_test <- cbind(rnorm(n_test, 0, sqrt(lambda_1)), rnorm(n_test, 0, sqrt(lambda_2))) Data_test <- GenDataKL(n_test, interval = interval, sparse = 6:8, meanfun = function(x){0}, score = score_test, eigfun = eigfun, sd = sqrt(0.1)) # Prediction score_pre <- predict(Klist, Data_test$Lt, Data_test$Ly, nK = 2) plot(score_test[,1], score_pre[,1])
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.