#'@title Get projection scores from the estimated eigenfunctions
#'@description After getting estimated eigenfunctions, this function can be used to compute projection scores of observed functional data.
#'@param X.curve The input matrix of observed values. Rows represent repititions or samples, and columns represent observed time points
#'@param phi A matrix containing normalized eigenfunctions, which is always generated by \code{FOBJ}
#'@param t A input time grid vector
#'@return It returns a matrix:
#'\item{Xi}{A matrix containing the projection scores}
#'@import fdapace
#'@export
getXi <- function(X.curve, phi, t){ #This function get the projection score. See the paper algorithm part.
if(! is.numeric(t)) stop("t should be recorded time points!")
xi <- NULL
if(is.vector(X.curve)){
xi <- apply(apply(phi, 2, function(x) {x * X.curve}), 2, function(x){return(trapzRcpp(t, x))})
}
else{
for (i in 1:ncol(phi)){
xi <- cbind(xi ,apply(t(matrix(rep(phi[, i], nrow(X.curve)), length(t))) * X.curve, 1, function(x){return(trapzRcpp(t, x))}))
} #The Jth column is the series of Jth scores
}
return(xi)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.