TimeSeriesTest

class hyppo.time_series.base.TimeSeriesTest(compute_distance=None, max_lag=0, **kwargs)

A base class for a time-series test.

Parameters
  • compute_distance (str, callable, or None, default: "euclidean") -- A function that computes the distance among the samples within each data matrix. Valid strings for compute_distance are, as defined in sklearn.metrics.pairwise_distances,

    • From scikit-learn: ["euclidean", "cityblock", "cosine", "l1", "l2", "manhattan"] See the documentation for scipy.spatial.distance for details on these metrics.

    • From scipy.spatial.distance: ["braycurtis", "canberra", "chebyshev", "correlation", "dice", "hamming", "jaccard", "kulsinski", "mahalanobis", "minkowski", "rogerstanimoto", "russellrao", "seuclidean", "sokalmichener", "sokalsneath", "sqeuclidean", "yule"] See the documentation for scipy.spatial.distance for details on these metrics.

    Set to None or "precomputed" if x and y are already distance matrices. To call a custom function, either create the distance matrix before-hand or create a function of the form metric(x, **kwargs) where x is the data matrix for which pairwise distances are calculated and **kwargs are extra arguements to send to your custom function.

  • max_lag (float, default: 0) -- The maximium lag to consider when computing the test statistics and p-values.

  • **kwargs -- Arbitrary keyword arguments for compute_distance.

Methods Summary

TimeSeriesTest.statistic(x, y)

Calulates the time-series test statistic.

TimeSeriesTest.test(x, y[, reps, workers, ...])

Calulates the time-series test test statistic and p-value.


abstract TimeSeriesTest.statistic(x, y)

Calulates the time-series test statistic.

Parameters

x,y (ndarray of float) -- Input data matrices. x and y must have the same number of samples. That is, the shapes must be (n, p) and (n, q) where n is the number of samples and p and q are the number of dimensions. Alternatively, x and y can be distance matrices, where the shapes must both be (n, n).

abstract TimeSeriesTest.test(x, y, reps=1000, workers=1, random_state=None, is_distsim=False)

Calulates the time-series test test statistic and p-value.

Parameters
  • x,y (ndarray of float) -- Input data matrices. x and y must have the same number of samples. That is, the shapes must be (n, p) and (n, q) where n is the number of samples and p and q are the number of dimensions. Alternatively, x and y can be distance matrices, where the shapes must both be (n, n).

  • reps (int, default: 1000) -- The number of replications used to estimate the null distribution when using the permutation test used to calculate the p-value.

  • workers (int, default: 1) -- The number of cores to parallelize the p-value computation over. Supply -1 to use all cores available to the Process.

  • is_distsim (bool, default: False) -- Whether or not x and y are input matrices.

Returns

  • stat (float) -- The computed time-series independence test statistic.

  • pvalue (float) -- The computed time-series independence p-value.

  • null_dist (list) -- The time-series independence p-value.

Examples using hyppo.time_series.base.TimeSeriesTest