oneway_anova#
- skfda.inference.anova.oneway_anova(first: T, *rest: T, n_reps: int = 2000, return_dist: Literal[False] = False, random_state: int | RandomState | Generator | None = None, p: int = 2, equal_var: bool = True) Tuple[float, float] [source]#
- skfda.inference.anova.oneway_anova(first: T, *rest: T, n_reps: int = 2000, return_dist: Literal[True], random_state: int | RandomState | Generator | None = None, p: int = 2, equal_var: bool = True) Tuple[float, float, ndarray[Any, dtype[float64]]]
Perform one-way functional ANOVA.
This function implements an asymptotic method to test the following null hypothesis:
Let \(\{X_i\}_{i=1}^k\) be a set of \(k\) independent samples each one with \(n_i\) trajectories, and let \(E(X_i) = m_i( t)\). The null hypothesis is defined as:
\[H_0: m_1(t) = \dots = m_k(t)\]This function calculates the value of the statistic
v_sample_stat()
\(V_n\) with the means of the given samples. Under the null hypothesis this statistic is asymptotically equivalent tov_asymptotic_stat()
, where each sample is replaced by a gaussian process, with mean zero and the same covariance function as the original.The simulation of the distribution of the asymptotic statistic \(V\) is implemented using a bootstrap procedure. One observation of the \(k\) different gaussian processes defined above is simulated, and the value of
v_asymptotic_stat()
is calculated. This procedure is repeated n_reps times, creating a sampling distribution of the statistic.This procedure is from Cuevas [1].
- Parameters:
first – First group of functions.
rest – Remaining groups.
n_reps – Number of simulations for the bootstrap procedure. Defaults to 2000 (This value may change in future versions).
return_dist – Flag to indicate if the function should return a numpy.array with the sampling distribution simulated.
random_state – Random state.
p – p of the lp norm. Must be greater or equal than 1. If p=’inf’ or p=np.inf it is used the L infinity metric. Defaults to 2.
equal_var – If True (default), perform a One-way ANOVA assuming the same covariance operator for all the groups, else considers an independent covariance operator for each group.
- Returns:
Tuple containing the value of the sample statistic, p-value (and sampling distribution of the simulated asymptotic statistic if return_dist is True).
Examples
>>> import skfda >>> from skfda.inference.anova import oneway_anova
>>> X = skfda.datasets.make_gaussian_process( ... n_samples=100, ... random_state=0, ... ) >>> X1, X2, X3 = X[:33], X[33:66], X[66:] >>> statistic, pvalue = oneway_anova(X1, X2, X3, random_state=1) >>> round(statistic, 2) 6.26 >>> pvalue 0.121 >>> _, _, dist = oneway_anova(X1, X2, X3, n_reps=3, ... random_state=1, ... return_dist=True) >>> dist.round(1) array([ 7.9, 0.7, 4.4])
References
Examples using skfda.inference.anova.oneway_anova
#
One-way functional ANOVA with real data
One-way functional ANOVA with synthetic data