Movatterモバイル変換


[0]ホーム

URL:


rofanova

R build status

The packagerofanova implements the robustnonparametric functional ANOVA method (RoFANOVA) proposed by Centofantiet al. (2021). RoFANOVA addresses the functional analysis of variance(FANOVA) problem, which aims to identify the presence of significantdifferences, in terms of functional mean, among groups of a functionaldata, by being robust against the presence of possible outliers. It is apermutation test whose test statistics rely on the functionalequivariant M-estimator, the functional extension of the classicalrobust M-estimator, which is based on the functional normalized medianabsolute deviation (FuNMAD) estimator.

The main function isrofanova which implements theRoFANOVA method both for univariate and bi-variate functional data byusing several families of loss functions. The functionsfusem andfunmad implement the functionalequivariant M-estimator and the FuNMAD estimator, respectively.

Installation

You can install the development version ofrofanovafromGitHub with:

# install.packages("devtools")devtools::install_github("unina-sfere/rofanova")

Example

This is a basic example which shows you how to apply the mainfunctionrofanova to perform both one-way and two-wayFANOVA when data are univariate functional data. The data are generatedas described in the first scenario of the simulation study in Centofantiet al. (2021).

We start by loading and attaching therofanovapackage.

library(rofanova)

Then, we generate the data and, just as an example, we fix the numberof permutationsB to 20.

data_out<-simulate_data(scenario="one-way")label_1=data_out$label_1X_fdata<-data_out$X_fdataB=20

We compute the p-values corresponding to the RoFANOVA test with themedian, the Huber, the bisquare, the Hampel, and the optimal lossfunctions.

per_list_median<-rofanova(X_fdata,label_1,B = B,family="median")pvalue_median<-per_list_median$pval_vecper_list_huber<-rofanova(X_fdata,label_1,B = B,family="huber")pvalue_huber<-per_list_huber$pval_vecper_list_bisquare<-rofanova(X_fdata,label_1,B = B,family="bisquare")pvalue_bisquare<-per_list_bisquare$pval_vecper_list_hampel<-rofanova(X_fdata,label_1,B = B,family="hampel")pvalue_hampel<-per_list_hampel$pval_vecper_list_optimal<-rofanova(X_fdata,label_1,B = B,family="optimal")pvalue_optimal<-per_list_optimal$pvalpvalues<-c(pvalue_median,pvalue_huber,pvalue_bisquare,pvalue_hampel,pvalue_optimal)names(pvalues)=c("median","Huber","bisquare","Hampel","optimal")

The p-values for the significance of the main factor are

print(pvalues)#>   median    Huber bisquare   Hampel  optimal#>     0.70     0.80     0.65     0.65     0.70

Similarly, two-way FANOVA can be performed as follows.

data_out<-simulate_data(scenario="two-way")label_1=data_out$label_1label_2=data_out$label_2X_fdata<-data_out$X_fdataB=20per_list_median<-rofanova(X_fdata,label_1,label_2,B = B,family="median")pvalue_median<-per_list_median$pval_vecper_list_huber<-rofanova(X_fdata,label_1,label_2,B = B,family="huber")pvalue_huber<-per_list_huber$pval_vecper_list_bisquare<-rofanova(X_fdata,label_1,label_2,B = B,family="bisquare")pvalue_bisquare<-per_list_bisquare$pval_vecper_list_hampel<-rofanova(X_fdata,label_1,label_2,B = B,family="hampel")pvalue_hampel<-per_list_hampel$pval_vecper_list_optimal<-rofanova(X_fdata,label_1,label_2,B = B,family="optimal")pvalue_optimal<-per_list_optimal$pvalpvalues<-cbind(pvalue_median,pvalue_huber,pvalue_bisquare,pvalue_hampel,pvalue_optimal)colnames(pvalues)=c("median","Huber","bisquare","Hampel","optimal")

The p-values for the significance of the whole model, the two mainfactors and the interaction are

print(pvalues)#>     median Huber bisquare Hampel optimal#> MOD   0.45  0.40     0.45   0.40    0.15#> F1    0.65  0.55     0.75   0.55    0.50#> F2    0.40  0.80     0.70   0.65    0.40#> INT   0.40  0.30     0.15   0.30    0.15

References


[8]ページ先頭

©2009-2025 Movatter.jp