| Title: | Robust Functional Analysis of Variance |
|---|---|
| Description: | Implements the robust functional analysis of variance (RoFANOVA), described in Centofanti et al. (2023) <doi:10.1093/jrsssc/qlad074>. It allows testing mean differences among groups of functional data by being robust against the presence of outliers. |
| Authors: | Fabio Centofanti [cre, aut] |
| Maintainer: | Fabio Centofanti <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.1 |
| Built: | 2026-05-17 07:32:34 UTC |
| Source: | https://github.com/fabiocentofanti/rofanova |
Implements the robust functional analysis of variance (RoFANOVA), described in Centofanti et al. (2023) doi:10.1093/jrsssc/qlad074. It allows testing mean differences among groups of functional data by being robust against the presence of outliers.
| Package: | rofanova |
| Type: | Package |
| Version: | 1.0.1 |
| Date: | 2025-12-27 |
| License: | GPL-3 |
Fabio Centofanti
Centofanti, F., Colosimo, B. M., Grasso, M. L., Menafoglio, A., Palumbo, B., & Vantini, S. (2023). Robust functional ANOVA with application to additive manufacturing. Journal of the Royal Statistical Society Series C: Applied Statistics, 72(5), 1210-1234.
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$pvallibrary(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
Compute the functional normalized median absolute deviation (FuNMAD) estimator as described in Centofanti et al. (2023).
funmad(X, ...)funmad(X, ...)
X |
Either an object of class |
... |
Additional argument to be passed to |
The FuNMAD estimator.
Centofanti, F., Colosimo, B. M., Grasso, M. L., Menafoglio, A., Palumbo, B., & Vantini, S. (2023). Robust functional ANOVA with application to additive manufacturing. Journal of the Royal Statistical Society Series C: Applied Statistics, 72(5), 1210-1234. arXiv preprint arXiv:2112.10643.
library(rofanova) data_out<-simulate_data(scenario="one-way") X_fdata<-data_out$X_fdata per_list_median<-funmad(X_fdata)library(rofanova) data_out<-simulate_data(scenario="one-way") X_fdata<-data_out$X_fdata per_list_median<-funmad(X_fdata)
Compute the scale equivariant functional M-estimator as described in Centofanti et al. (2023).
fusem( X, family = "bisquare", eff = 0.95, maxit = 50, tol = 1e-04, mu0_g = NULL, sig0_g = NULL )fusem( X, family = "bisquare", eff = 0.95, maxit = 50, tol = 1e-04, mu0_g = NULL, sig0_g = NULL )
X |
Either an object of class |
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 |
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 |
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 |
A list containing the following arguments:
mu: The scale equivariant functional M-estimator .
mu0_g: mu0_g.
sig0_g: sig0_g.
Centofanti, F., Colosimo, B. M., Grasso, M. L., Menafoglio, A., Palumbo, B., & Vantini, S. (2023). Robust functional ANOVA with application to additive manufacturing. Journal of the Royal Statistical Society Series C: Applied Statistics, 72(5), 1210-1234.
library(rofanova) data_out<-simulate_data(scenario="one-way") X_fdata<-data_out$X_fdata per_list_median<-fusem(X_fdata)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 (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., 2023).
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 )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 )
X |
Either an object of class |
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 |
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 |
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 |
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 |
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.
Centofanti, F., Colosimo, B. M., Grasso, M. L., Menafoglio, A., Palumbo, B., & Vantini, S. (2023). Robust functional ANOVA with application to additive manufacturing. Journal of the Royal Statistical Society Series C: Applied Statistics, 72(5), 1210-1234.
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$pvallibrary(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
Generate synthetic data as in the simulation study of Centofanti et al. (2023) with the addition of the case of bi-variate functional data. All the details are in Centofanti et al. (2023).
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" )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" )
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. |
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.
Centofanti, F., Colosimo, B. M., Grasso, M. L., Menafoglio, A., Palumbo, B., & Vantini, S. (2023). Robust functional ANOVA with application to additive manufacturing. Journal of the Royal Statistical Society Series C: Applied Statistics, 72(5), 1210-1234.
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$pvallibrary(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