Simulate univariate functional data

Share:

Description

This functions simulates (univariate) functional data f_1,…, f_N based on a truncated Karhunen-Loeve representation:

f_i(t) = ∑_{m = 1}^M ξ_{i,m} φ_m(t).

The eigenfunctions (basis functions) φ_m(t) are generated using eFun, the scores ξ_{i,m} are simulated independently from a normal distribution with zero mean and decreasing variance based on the eVal function.

Usage

1
simFunData(argvals, M, eFunType, ignoreDeg = NULL, eValType, N)

Arguments

argvals

A numeric vector, containing the observation points (a fine grid on a real interval) of the functional data that is to be simulated.

M

An integer, giving the number of unvariate basis functions to use. See Details.

eFunType

A character string specifying the type of univariate orthonormal basis functions to use. See eFun for details.

ignoreDeg

A vector of integers, specifying the degrees to ignore when generating the univariate orthonormal bases. Defaults to NULL. See eFun for details.

eValType

A character string, specifying the type of eigenvalues/variances used for the generation of the simulated functions based on the truncated Karhunen-Loeve representation. See eVal for details.

N

An integer, specifying the number of multivariate functions to be generated.

Value

simData

A funData object with N observations, representing the simulated functional data.

trueFuns

A funData object with M observations, representing the true eigenfunction basis used for simulating the data.

trueVals

A vector of numerics, representing the true eigenvalues used for simulating the data.

See Also

funData, eFun, eVal, addError, sparsify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
oldPar <- par(no.readonly = TRUE)

# Use Legendre polynomials as eigenfunctions and a linear eigenvalue decrease
test <- simFunData(seq(0,1,0.01), M = 10, eFunType = "Poly", eValType = "linear", N = 10)

plot(test$trueFuns, main = "True Eigenfunctions")
plot(test$simData, main = "Simulated Data")

# The use of ignoreDeg for eFunType = "PolyHigh"
test <- simFunData(seq(0,1,0.01), M = 4, eFunType = "Poly", eValType = "linear", N = 10)
test_noConst <-  simFunData(seq(0,1,0.01), M = 4, eFunType = "PolyHigh",
                            ignoreDeg = 1, eValType = "linear", N = 10)
test_noLinear <-  simFunData(seq(0,1,0.01), M = 4, eFunType = "PolyHigh",
                             ignoreDeg = 2, eValType = "linear", N = 10)
test_noBoth <-  simFunData(seq(0,1,0.01), M = 4, eFunType = "PolyHigh",
                           ignoreDeg = 1:2, eValType = "linear", N = 10)

par(mfrow = c(2,2))
plot(test$trueFuns, main = "Standard polynomial basis (M = 4)")
plot(test_noConst$trueFuns, main = "No constant basis function")
plot(test_noLinear$trueFuns, main = "No linear basis function")
plot(test_noBoth$trueFuns, main = "Neither linear nor constant basis function")

par(oldPar)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.