Package 'rofanova'

Title: Robust Functional Analysis of Variance
Description: Implements the robust functional analysis of variance (RoFANOVA), described in Centofanti et al. (2021) <arXiv:2112.10643>. It allows testing mean differences among groups of functional data by being robust against the presence of outliers.
Authors: Fabio Centofanti [cre, aut], Bianca Maria Colosimo [aut], Marco Luigi Grasso [aut], Antonio Lepore [aut], Alessandra Menafoglio [aut], Biagio Palumbo [aut], Simone Vantini [aut]
Maintainer: Fabio Centofanti <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2024-11-16 06:55:10 UTC
Source: CRAN

Help Index


Robust Functional Analysis of Variance

Description

Implements the robust functional analysis of variance (RoFANOVA), described in Centofanti et al. (2021) <arXiv:2112.10643>. It allows testing mean differences among groups of functional data by being robust against the presence of outliers.

Details

Package: rofanova
Type: Package
Version: 1.0.0
Date: 2022-01-21
License: GPL-3

Author(s)

Fabio Centofanti, Bianca Maria Colosimo, Marco Luigi Grasso, Antonio Lepore, Alessandra Menafoglio, Biagio Palumbo, Simone Vantini

References

Centofanti, F., Colosimo, B.M., Grasso, M.L., Menafoglio, A., Palumbo, B., Vantini, S. (2021). Robust Functional ANOVA with Application to Additive Manufacturing. arXiv preprint arXiv:2112.10643.

See Also

rofanova fusem funmad

Examples

library(rofanova)
data_out<-simulate_data(scenario="one-way")
label_1=data_out$label_1
X_fdata<-data_out$X_fdata
B=10
cores=1
per_list_median<-rofanova(X_fdata,label_1,B = B,family="median",cores=cores)
pvalue_median_vec<-per_list_median$pval_vec
per_list_huber<-rofanova(X_fdata,label_1,B = B,family="huber",cores=cores)
pvalue_huber_vec<-per_list_huber$pval_vec
per_list_bisquare<-rofanova(X_fdata,label_1,B = B,family="bisquare",cores=cores)
pvalue_bisquare_vec<-per_list_bisquare$pval_vec
per_list_hampel<-rofanova(X_fdata,label_1,B = B,family="hampel",cores=cores)
pvalue_hampel_vec<-per_list_hampel$pval_vec
per_list_optimal<-rofanova(X_fdata,label_1,B = B,family="optimal",cores=cores)
pvalue_optimal<-per_list_optimal$pval

The functional normalized median absolute deviation estimators

Description

Compute the functional normalized median absolute deviation (FuNMAD) estimator as described in Centofanti et al. (2021).

Usage

funmad(X, ...)

Arguments

X

Either an object of class fdata for monodimensional functional data or an object of class fdata2d for bi-dimensional functional data.

...

Additional argument to be passed to fusem.

Value

The FuNMAD estimator.

References

Centofanti, F., Colosimo, B.M., Grasso, M.L., Menafoglio, A., Palumbo, B., Vantini, S. (2021). Robust Functional ANOVA with Application to Additive Manufacturing. arXiv preprint arXiv:2112.10643.

See Also

rofanova fusem

Examples

library(rofanova)
data_out<-simulate_data(scenario="one-way")
X_fdata<-data_out$X_fdata
per_list_median<-funmad(X_fdata)

The scale equivariant functional M-estimator

Description

Compute the scale equivariant functional M-estimator as described in Centofanti et al. (2021).

Usage

fusem(
  X,
  family = "bisquare",
  eff = 0.95,
  maxit = 50,
  tol = 1e-04,
  mu0_g = NULL,
  sig0_g = NULL
)

Arguments

X

Either an object of class fdata for monodimensional functional data or an object of class fdata2d for bi-dimensional functional data.

family

The family of loss function for the calculation of the equivariant functional M-estimator. The values allowed are "bisquare" for the bisquare or Tukey's biweight family of loss functions; "huber" for the the Huber's family of loss functions; "optimal" for the optimal family of loss functions; "hampel" for the the Hampel's family of loss functions; "median" for the median loss function. A non-robust functional estimator of the mean based on the standard least squares loss function is used with the value "mean". Default is "bisquare".

eff

Asymptotic efficiency of the equivariant functional M-estimator. When family is either "mean" or "median", eff is ignored.

maxit

The maximum number of iterations allowed in the re-weighted least-squares algorithm to compute the equivariant functional M-estimator.

tol

The tolerance for the stopping condition of the re-weighted least-squares algorithm to compute the equivariant functional M-estimator. The algorithm stops when the relative variation of the weighted norm sum between two consecutive iterations is less than tol.

mu0_g

Initial estimate used in re-weighted least-squares algorithm to compute the equivariant functional M-estimator. If NULL the standard non-robust functional mean is used. Default is NULL.

sig0_g

Estimate of the standard error of X. If NULL, the functional mean is used. Default is NULL.

Value

A list containing the following arguments:

  • mu: The scale equivariant functional M-estimator .

  • mu0_g: mu0_g.

  • sig0_g: sig0_g.

References

Centofanti, F., Colosimo, B.M., Grasso, M.L., Menafoglio, A., Palumbo, B., Vantini, S. (2021). Robust Functional ANOVA with Application to Additive Manufacturing. arXiv preprint arXiv:2112.10643.

See Also

rofanova funmad

Examples

library(rofanova)
data_out<-simulate_data(scenario="one-way")
X_fdata<-data_out$X_fdata
per_list_median<-fusem(X_fdata)

Robust Functional Analysis of Variance

Description

Robust Functional Analysis of Variance (RoFANOVA) allows identifying the presence of significant differences, in terms of functional mean, among groups of a functional data by being robust against the presence of outliers (Centofanti et al., 2021).

Usage

rofanova(
  X,
  label_1,
  label_2 = NULL,
  B = 100,
  cores = 1,
  family = "bisquare",
  eff = 0.95,
  mu0_g = NULL,
  scale = NULL,
  maxit = 50,
  tol = 1e-04
)

Arguments

X

Either an object of class fdata for monodimensional functional data or an object of class fdata2d for bi-dimensional functional data.

label_1

A vector of containing group label corresponding to the first main effect.

label_2

A vector of containing group label corresponding to the second main effect. If it is NULL, the one-way RoFANOVA is performed. Otherwise, the two-way RoFANOVA with interaction is employed. Default is NULL.

B

The number of permutations used to approximate the p-value in the permutation test. Default is 1000.

cores

If cores>1, then parallel computing is used, with cores cores. Default is 1.

family

The family of loss function for the calculation of the equivariant functional M-estimator. The values allowed are "bisquare" for the bisquare or Tukey's biweight family of loss functions; "huber" for the the Huber's family of loss functions; "optimal" for the optimal family of loss functions; "hampel" for the the Hampel's family of loss functions; "median" for the median loss function. A non-robust functional estimator of the mean based on the standard least squares loss function is used with the value "mean". Default is "bisquare".

eff

Asymptotic efficiency of the equivariant functional M-estimator. When family is either "mean" or "median", eff is ignored.

mu0_g

Initial estimate used in re-weighted least-squares algorithm to compute the equivariant functional M-estimator. If NULL the standard non-robust functional mean is used. Default is NULL.

scale

Estimate of the standard error of X. If NULL, the functional normalized median absolute deviation estimator is used. Default is NULL.

maxit

The maximum number of iterations allowed in the re-weighted least-squares algorithm to compute the equivariant functional M-estimator.

tol

The tolerance for the stopping condition of the re-weighted least-squares algorithm to compute the equivariant functional M-estimator. The algorithm stops when the relative variation of the weighted norm sum between two consecutive iterations is less than tol.

Value

pval_vec Vector of p-value of corresponding to the test of significance of the whole model, the main effects and the interaction. For one-way RoFANOVA, it is the p-value corresponding to the test of the main effect.

Tr_obs The observed value of the test statistic.

Tr_perm The values of the test statistic for each permutation.

mod A list containing the following arguments:

  • Tr: The observed value of the test statistic.

  • global_mean: The robust estimate of functional grand mean.

  • group_mean_1: The robust estimate of the first functional main effect.

  • group_mean_2: The robust estimate of the second functional main effect. For one-way RoFANOVA, it is NULL.

  • group_mean_ij: The robust estimate of the group functional mean. For one-way, it RoFANOVA is NULL.

  • scale: The robust estimate of functional standard deviation.

  • scale_1: The robust estimate of functional standard deviation corresponding to the first functional main effect.

  • scale_2: The robust estimate of functional standard deviation corresponding to the second functional main effect. For one-way RoFANOVA, it is NULL.

  • scale_re: The robust estimate of the functional standard deviation of the error distribution. For one-way RoFANOVA, it is NULL.

  • X: The variable X.

  • label_1: The vector of containing group label corresponding to the first main effect.

  • label_2: The vector of containing group label corresponding to the second main effect. For one-way RoFANOVA, it is NULL.

  • family: The family of loss function for the calculation of the equivariant functional M-estimator.

References

Centofanti, F., Colosimo, B.M., Grasso, M.L., Menafoglio, A., Palumbo, B., Vantini, S. (2021). Robust Functional ANOVA with Application to Additive Manufacturing. arXiv preprint arXiv:2112.10643.

See Also

fusem funmad

Examples

library(rofanova)
data_out<-simulate_data(scenario="one-way")
label_1=data_out$label_1
X_fdata<-data_out$X_fdata
B=10
cores=1
per_list_median<-rofanova(X_fdata,label_1,B = B,family="median",cores=cores)
pvalue_median_vec<-per_list_median$pval_vec
per_list_huber<-rofanova(X_fdata,label_1,B = B,family="huber",cores=cores)
pvalue_huber_vec<-per_list_huber$pval_vec
per_list_bisquare<-rofanova(X_fdata,label_1,B = B,family="bisquare",cores=cores)
pvalue_bisquare_vec<-per_list_bisquare$pval_vec
per_list_hampel<-rofanova(X_fdata,label_1,B = B,family="hampel",cores=cores)
pvalue_hampel_vec<-per_list_hampel$pval_vec
per_list_optimal<-rofanova(X_fdata,label_1,B = B,family="optimal",cores=cores)
pvalue_optimal<-per_list_optimal$pval

Simulate data for Robust Functional ANOVA

Description

Generate synthetic data as in the simulation study of Centofanti et al. (2021) with the addition of the case of bi-variate functional data. All the details are in Centofanti et al. (2021).

Usage

simulate_data(
  scenario = "one-way",
  mean = "M1",
  con = "C0",
  p = 0.1,
  M = 1,
  n_i = 25,
  k_1 = 3,
  k_2 = 3,
  alpha = 0,
  beta = 0,
  sd = 0.01,
  grid = seq(0, 1, length.out = 30),
  err = "s"
)

Arguments

scenario

A character strings indicating the scenario considered. It could be "one-way", "two-way", "one-way surface" and "two-way surface".

mean

A character strings indicating the type of mean function in one-way ANOVA. It could be "M1", "M2", and "M3".

con

A character strings indicating the type of contamination function. It could be "C0", for no contamination, "C1", "C2", "C3", "C4", "C5", and "C6".

p

The parameter related to the bernoulli variable in the contamination function.

M

The contamination size constant.

n_i

The number of observation for each group.

k_1

The number of level for the first main effect.

k_2

The number of level for the second main effect. For One-way ANOVA, it is ignored.

alpha

The parameter a in the Two-way ANOVA scenarios. For One-way ANOVA, it is ignored.

beta

The parameter b in the Two-way ANOVA scenarios. For One-way ANOVA, it is ignored.

sd

The sigma parameter in the covariance of the error function.

grid

The grid over which the functional data are observed.

err

The direction of the dependence in the error function for the case of bi-variate functional data. It could be either "s", for dependence along the first dimension or "t" for dependence along the second dimension.

Value

A list containing the following arguments:

  • X_fdata: The generated functional data.

  • label_1: The vector of containing group label corresponding to the first main effect.

  • label_2: The vector of containing group label corresponding to the second main effect. For one-way ANOVA, it is NULL.

References

Centofanti, F., Colosimo, B.M., Grasso, M.L., Menafoglio, A., Palumbo, B., Vantini, S. (2021). Robust Functional ANOVA with Application to Additive Manufacturing. arXiv preprint arXiv:2112.10643.

See Also

rofanova fusem funmad

Examples

library(rofanova)
data_out<-simulate_data(scenario="one-way")
label_1=data_out$label_1
X_fdata<-data_out$X_fdata
B=10
cores=1
per_list_median<-rofanova(X_fdata,label_1,B = B,family="median",cores=cores)
pvalue_median_vec<-per_list_median$pval_vec
per_list_huber<-rofanova(X_fdata,label_1,B = B,family="huber",cores=cores)
pvalue_huber_vec<-per_list_huber$pval_vec
per_list_bisquare<-rofanova(X_fdata,label_1,B = B,family="bisquare",cores=cores)
pvalue_bisquare_vec<-per_list_bisquare$pval_vec
per_list_hampel<-rofanova(X_fdata,label_1,B = B,family="hampel",cores=cores)
pvalue_hampel_vec<-per_list_hampel$pval_vec
per_list_optimal<-rofanova(X_fdata,label_1,B = B,family="optimal",cores=cores)
pvalue_optimal<-per_list_optimal$pval