GenDataKL {KFPCA}R Documentation

Generate functional/longitudinal data via KL expansion

Description

Generate functional/longitudinal data via Karhunen–Loève expansion.

Usage

GenDataKL(n, interval, sparse, regular, meanfun, score, eigfun, sd)

Arguments

n

number of sample size.

interval

A vector of length two denoting the supporting interval.

sparse

A vector denoting the possible numbers of observation size. The elements are chosen with equal chance. The length of sparse must be one if regular = TRUE.

regular

Logical; If TRUE, the observation grids are equally-spaced.

meanfun

A function for the mean.

score

A n by nK matrix containing the estimates of the FPC scores, where nK is the number of FPCs.

eigfun

A list containing the eigenfunctions.

sd

A scalar denoting the standard deviation of measurement errors.

Value

A list containing the following components:

Lt

A list of n vectors, where n is the sample size. Each entry contains the observation time in ascending order for each subject.

Ly

A list of n vectors, where n is the sample size. Each entry contains the measurements of each subject at the observation time correspond to Lt.

Examples

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, regular = FALSE,
                     meanfun = function(x){0}, score = score,
                     eigfun = eigfun, sd = sqrt(0.1))

[Package KFPCA version 2.0 Index]