simFunData {funData}R Documentation

Simulate univariate functional data

Description

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

f_i(t) = \sum_{m = 1}^M \xi_{i,m} \phi_m(t).

on one- or higher-dimensional domains. The eigenfunctions (basis functions) \phi_m(t) are generated using eFun, the scores \xi_{i,m} are simulated independently from a normal distribution with zero mean and decreasing variance based on the eVal function. For higher-dimensional domains, the eigenfunctions are constructed as tensors of marginal orthonormal function systems.

Usage

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 or a list of the marginal observation points.

M

An integer, giving the number of univariate basis functions to use. For higher-dimensional data, M is a vector with the marginal number of eigenfunctions. See Details.

eFunType

A character string specifying the type of univariate orthonormal basis functions to use. For data on higher-dimensional domains, eFunType can be a vector, specifying the marginal type of eigenfunctions to use in the tensor product. See eFun for details.

ignoreDeg

A vector of integers, specifying the degrees to ignore when generating the univariate orthonormal bases. Defaults to NULL. For higher-dimensional data, ignoreDeg can be supplied as list with vectors for each marginal. 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

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")

# Higher-dimensional domains
simImages <- simFunData(argvals = list(seq(0,1,0.01), seq(-pi/2, pi/2, 0.02)), 
             M = c(5,4), eFunType = c("Wiener","Fourier"), eValType = "linear", N = 4)
for(i in 1:4) 
   plot(simImages$simData, obs = i, main = paste("Observation", i))
               
par(oldPar)

[Package funData version 1.3-9 Index]