GenBinaryFD {SLFPCA} | R Documentation |
Generate binary functional data
Description
Generate binary functional data through latent process.
Usage
GenBinaryFD(n, interval, sparse, regular, meanfun, score, eigfd)
Arguments
n |
An integer denoting the number of sample size. |
interval |
A |
sparse |
A |
regular |
Logical; If |
meanfun |
A function for the mean. |
score |
A n by |
eigfd |
A |
Value
A list
containing the following components:
Lt |
A |
Lx |
A |
Ly |
A |
Examples
n <- 100
npc <- 2
interval <- c(0, 10)
gridequal <- seq(0, 10, length.out = 51)
basis <- fda::create.bspline.basis(c(0, 10), nbasis = 13, norder = 4,
breaks = seq(0, 10, length.out = 11))
meanfun <- function(t){2 * sin(pi * t/5)/sqrt(5)}
lambda_1 <- 3^2 #the first eigenvalue
lambda_2 <- 2^2 #the second eigenvalue
score <- cbind(rnorm(n, 0, sqrt(lambda_1)), rnorm(n, 0, sqrt(lambda_2)))
eigfun <- list()
eigfun[[1]] <- function(t){cos(pi * t/5)/sqrt(5)}
eigfun[[2]] <- function(t){sin(pi * t/5)/sqrt(5)}
eigfd <- list()
for(i in 1:npc){
eigfd[[i]] <- fda::smooth.basis(gridequal, eigfun[[i]](gridequal), basis)$fd
}
DataNew <- GenBinaryFD(n, interval, sparse = 8:12, regular = FALSE,
meanfun = meanfun, score, eigfd)