oneway_anova#

skfda.inference.anova.oneway_anova(first: T, *rest: T, n_reps: int = 2000, return_dist: typing_extensions.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: typing_extensions.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 to v_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

>>> from skfda.inference.anova import oneway_anova
>>> from skfda.datasets import fetch_gait
>>> from numpy.random import RandomState
>>> from numpy import printoptions
>>> fd = fetch_gait()["data"].coordinates[1]
>>> fd1, fd2, fd3 = fd[:13], fd[13:26], fd[26:]
>>> oneway_anova(fd1, fd2, fd3, random_state=RandomState(42))
(179.52499999999998, 0.56)
>>> _, _, dist = oneway_anova(fd1, fd2, fd3, n_reps=3,
...     random_state=RandomState(42),
...     return_dist=True)
>>> with printoptions(precision=4):
...     print(dist)
[ 174.8663  202.1025  185.598 ]

References

Examples using skfda.inference.anova.oneway_anova#

One-way functional ANOVA with real data

One-way functional ANOVA with real data

One-way functional ANOVA with synthetic data

One-way functional ANOVA with synthetic data