Learn R Programming

fdANOVA (version 0.1.2)

fmanova.ptbfr: Permutation Tests Based on a Basis Function Representation for FMANOVA Problem

Description

Performs the permutation tests based on a basis function representation for multivariate analysis of variance for functional data, i.e., the W, LH, P and R tests. For details of the tests, see Section 2.2 of the vignette file (vignette("fdANOVA", package = "fdANOVA")).

We consider independent vectors of random functions $$\mathbf{X}_{ij}(t)=(X_{ij1}(t),\dots,X_{ijp}(t))^{\top}\in SP_p(\boldsymbol{\mu}_i,\mathbf{\Gamma}),$$ \(i=1,\dots,l,\) \(j=1,\dots,n_{i}\) defined over the interval \(I=[a,b]\), where \(SP_{p}(\boldsymbol{\mu},\boldsymbol{\Gamma})\) is a set of \(p\)-dimensional stochastic processes with mean vector \(\boldsymbol{\mu}(t)\), \(t\in I\) and covariance function \(\boldsymbol{\Gamma}(s, t)\), \(s,t\in I\). Let \(n=n_1+\dots+n_l\). In the multivariate analysis of variance problem for functional data (FMANOVA), we have to test the null hypothesis as follows: $$ H_0:\boldsymbol{\mu}_1(t)=\dots=\boldsymbol{\mu}_l(t),\ t\in I. $$ The alternative is the negation of the null hypothesis. We assume that each functional observation is observed on a common grid of \(\mathcal{T}\) design time points equally spaced in \(I\) (see Section 3.1 of the vignette file, vignette("fdANOVA", package = "fdANOVA")).

Usage

fmanova.ptbfr(x = NULL, group.label, int, B = 1000,
              parallel = FALSE, nslaves = NULL,
              basis = c("Fourier", "b-spline", "own"),
              own.basis, own.cross.prod.mat,
              criterion = c("BIC", "eBIC", "AIC", "AICc", "NO"),
              commonK = c("mode", "min", "max", "mean"),
              minK = NULL, maxK = NULL, norder = 4, gamma.eBIC = 0.5)

Arguments

x

a list of \(\mathcal{T}\times n\) matrices of data, whose each column is a discretized version of a function and rows correspond to design time points. The \(m\)th element of this list contains the data of \(m\)th feature, \(m=1,\dots,p\). Its default values is NULL, because a basis representation of the data can be given instead of raw observations (see the parameter own.basis below).

group.label

a vector containing group labels.

int

a vector of two elements representing the interval \(I=[a,b]\). When it is not specified, it is determined by a number of design time points.

B

a number of permutation replicates.

parallel

a logical indicating whether to use parallelization.

nslaves

if parallel = TRUE, a number of slaves. Its default value means that it will be equal to a number of logical processes of a computer used.

basis

a choice of basis of functions used in the basis function representation of the data.

own.basis

if basis = "own", a list of length \(p\), whose elements are \(K_m\times n\) matrices (\(m=1,\dots,p\)) with columns containing the coefficients of the basis function representation of the observations.

own.cross.prod.mat

if basis = "own", a \(KM\times KM\) cross product matrix corresponding to a basis used to obtain the list own.basis.

criterion

a choice of information criterion for selecting the optimum value of \(K_m\), \(m=1,\dots,p\). criterion = "NO" means that \(K_m\) are equal to the parameter maxK defined below. Further remarks about this argument are the same as for the function fanova.tests.

commonK

a choice of method for selecting the common value for all observations from the values of \(K_m\) corresponding to all processes.

minK

a minimum value of \(K_m\). Further remarks about this argument are the same as for the function fanova.tests.

maxK

a maximum value of \(K_m\). Further remarks about this argument are the same as for the function fanova.tests.

norder

if basis = "b-spline", an integer specifying the order of b-splines.

gamma.eBIC

a \(\gamma\in[0,1]\) parameter in the eBIC.

Value

A list with class "fmanovaptbfr" containing the following components:

W

a value of the statistic W.

pvalueW

p-value for the W test.

LH

a value of the statistic LH.

pvalueLH

p-value for the LH test.

P

a value of the statistic P.

pvalueP

p-value for the P test.

R

a value of the statistic R.

pvalueR

p-value for the R test,

the values of parameters used and eventually
data

a list containing the data given in x.

Km

a vector \((K_1,\dots,K_p)\).

KM

a maximum of a vector Km.

References

Gorecki T, Smaga L (2015). A Comparison of Tests for the One-Way ANOVA Problem for Functional Data. Computational Statistics 30, 987-1010.

Gorecki T, Smaga L (2017). Multivariate Analysis of Variance for Functional Data. Journal of Applied Statistics 44, 2172-2189.

See Also

fanova.tests, fmanova.trp, plotFANOVA

Examples

Run this code
# NOT RUN {
# Some of the examples may run some time.

# gait data (both features)
library(fda)
gait.data.frame <- as.data.frame(gait)
x.gait <- vector("list", 2)
x.gait[[1]] <- as.matrix(gait.data.frame[, 1:39])
x.gait[[2]] <- as.matrix(gait.data.frame[, 40:78])

# vector of group labels
group.label.gait <- rep(1:3, each = 13)
# }
# NOT RUN {
# the tests based on a basis function representation with default parameters
set.seed(123)
(fmanova1 <- fmanova.ptbfr(x.gait, group.label.gait))
summary(fmanova1)

# the tests based on a basis function representation with non-default parameters
set.seed(123)
fmanova2 <- fmanova.ptbfr(x.gait, group.label.gait, int = c(0.025, 0.975), B = 5000,
                          basis = "b-spline", criterion = "eBIC", commonK = "mean",
                          minK = 5, maxK = 20, norder = 4, gamma.eBIC = 0.7)
summary(fmanova2)

# the tests based on a basis function representation
# with predefined basis function representation
library(fda)
fbasis <- create.fourier.basis(c(0, nrow(x.gait[[1]])), 17)
own.basis <- vector("list", 2)
own.basis[[1]] <- Data2fd(1:nrow(x.gait[[1]]), x.gait[[1]], fbasis)$coefs
own.basis[[2]] <- Data2fd(1:nrow(x.gait[[2]]), x.gait[[2]], fbasis)$coefs
own.cross.prod.mat <- diag(rep(1, 17))
set.seed(123)
fmanova3 <- fmanova.ptbfr(group.label = group.label.gait,
                          B = 1000, basis = "own",
                          own.basis = own.basis,
                          own.cross.prod.mat = own.cross.prod.mat)
summary(fmanova3)

library(fda)
fbasis <- create.bspline.basis(c(0, nrow(x.gait[[1]])), 20, norder = 4)
own.basis <- vector("list", 2)
own.basis[[1]] <- Data2fd(1:nrow(x.gait[[1]]), x.gait[[1]], fbasis)$coefs
own.basis[[2]] <- Data2fd(1:nrow(x.gait[[2]]), x.gait[[2]], fbasis)$coefs
own.cross.prod.mat <- inprod(fbasis, fbasis)
set.seed(123)
fmanova4 <- fmanova.ptbfr(group.label = group.label.gait,
                          B = 1000, basis = "own",
                          own.basis = own.basis,
                          own.cross.prod.mat = own.cross.prod.mat)
summary(fmanova4)
# }

Run the code above in your browser using DataLab