pyamr.core.stats package
Submodules
pyamr.core.stats.adfuller module
Classes:
|
The Augmented Dickey-Fuller test can be used to test for a unit root in a univariate process in the presence of serial correlation. |
- class pyamr.core.stats.adfuller.ADFWrapper(estimator=None, evaluate=True)[source]
Bases:
BaseWrapper
The Augmented Dickey-Fuller test can be used to test for a unit root in a univariate process in the presence of serial correlation. It tests the null hypothesis that a unit root is present in a time series sample. The alternative hypothesis is different depending on which version of the test is used, but is usually stationarity or trend-stationarity. The more negative the statistic, the stronger the rejection of the hypothesis that there is a unit root at some level of confidence.
H
Hypothesis
Stationarity
H0
The series has a unit root
Non-stationary
H1
The series has no unit root
Stationary
/Trend-Stationary
If p-value > 0.05: Failed to reject H0.If p-value <= 0.05: Reject H0.The absence of unit root is not a proof of non-stationarity. As such, it is also possible to use the Kwiatkowski–Phillips–Schmidt–Shin (KPSS) test to identify the existence of an underlying trend which can also be removed to obtain a stationary process. These are called trend-stationary processes.
In both, unit-root and trend-stationary processes, the mean can be increasing or decreasing over time; however, in the presence of a shock, trend-stationary processes revert to this mean tendency in the long run (deterministic trend) while unit-root processes have a permanent impact (stochastic trend).
Methods:
as_summary
([alpha, verbose])This method creates the summary to display.
evaluate
(**kwargs)Evaluates the model.
is_stationary
([alpha])This method returns a boolean with the stationarity outocme.
stationarity
([alpha])This method returns the stationarity outcome.
pyamr.core.stats.correlation module
Classes:
|
The Pearson Correlation Coefficient measures the linear correlation between two variables with a value within the range [-1,1]. |
- class pyamr.core.stats.correlation.CorrelationWrapper(estimator=None, evaluate=True)[source]
Bases:
BaseWrapper
The Pearson Correlation Coefficient measures the linear correlation between two variables with a value within the range [-1,1]. Coefficient values of -1, 0 and 1 indicate total negative linear correlation, no inear correlation and total positive correlation respectively. In this study, the coefficient is used to assess whether or not there is a linear correlation between the number of observations (susceptibility test records) and the computed resistance index.
The Spearman Correlation Coefficient…
The Cross-Correlation ….
Methods:
as_summary
([alpha])This method displays the summary.
evaluate
([alpha])This method sets all the variables into this class.
fit
(x1, x2, **kwargs)This method computes kendall for monotonic increase
pyamr.core.stats.kendall module
Classes:
|
The Kendall statistical test, also known as Kendall's rank correlation test or Kendall's tau test, is a nonparametric statistical test used to assess the strength and direction of association between two variables. |
Functions:
|
Computes the kendall statistical test |
- class pyamr.core.stats.kendall.KendallWrapper(estimator=None, evaluate=True)[source]
Bases:
BaseWrapper
The Kendall statistical test, also known as Kendall’s rank correlation test or Kendall’s tau test, is a nonparametric statistical test used to assess the strength and direction of association between two variables. It is particularly suited for analyzing ranked or ordinal data, where the values of the variables are ranked or ordered but not necessarily quantitatively measurable. The coefficient ranges from -1 to +1, where a value of +1 indicates a perfect positive rank correlation, -1 indicates a perfect negative rank correlation, and 0 indicates no rank correlation.
Methods:
as_summary
([alpha])This method displays the summary.
evaluate
([alpha])Evaluates the model for the specified alpha.
trend_direction
(alpha)This method returns the trend direction.
trend_exists
(alpha)This method returns a boolean with the stationarity outocme.
- pyamr.core.stats.kendall.kendall(x)[source]
Computes the kendall statistical test
- Parameters:
x (a vector of data)
alpha (significance level (0.05 default))
- Returns:
trend (tells the trend (increasing, decreasing or no trend))
h (True (if trend is present) or False (if trend is absence))
p (p value of the significance test)
z (normalized test statistics)
pyamr.core.stats.kpss module
Classes:
|
The Kwiatkowski–Phillips–Schmidt–Shin (KPSS) test is used to identify whether a time series is stationary around a deterministic trend (thus trend stationary) against the alternative of a unit root. |
- class pyamr.core.stats.kpss.KPSSWrapper(estimator=None, evaluate=True)[source]
Bases:
BaseWrapper
The Kwiatkowski–Phillips–Schmidt–Shin (KPSS) test is used to identify whether a time series is stationary around a deterministic trend (thus trend stationary) against the alternative of a unit root.
In the KPSS test, the absence of a unit root is not a proof of stationarity but, by design, of trend stationarity. This is an important distinction since it is possible for a time series to be non-stationary, have no unit root yet be trend-stationary.
In both, unit-root and trend-stationary processes, the mean can be increasing or decreasing over time; however, in the presence of a shock, trend-stationary processes revert to this mean tendency in the long run (deterministic trend) while unit-root processes have a permanent impact (stochastic trend).
H
Hypothesis
Stationarity
H0
The series has no unit root
Trend-stationary
H1
The series has a unit root
No Trend-Stationary
If p-value > alpha: Failed to reject H0If p-value <= alpha: Reject H0
pyamr.core.stats.stationarity module
Classes:
|
In time series analysis, "stationarity" refers to a key assumption about the behavior of a time series over time. |
- class pyamr.core.stats.stationarity.StationarityWrapper(estimator=None, evaluate=True)[source]
Bases:
BaseWrapper
In time series analysis, “stationarity” refers to a key assumption about the behavior of a time series over time. A stationary time series is one in which statistical properties, such as mean, variance, and autocorrelation, remain constant over time. Stationarity is an important concept because many time series analysis techniques rely on this assumption for their validity. There are different types of stationarity that can be observed in time series data.
The augmented Dickey–Fuller test or
ADF
can be used to determine the presence of a unit root. When the other roots of the characteristic function lie inside the unit circle the first difference of the process is stationary. Due to this property, these are also called difference-stationary processes. Since the absence of unit root is not a proof of non-stationarity, the Kwiatkowski–Phillips–Schmidt–Shin orKPSS
test can be used to identify the existence of an underlying trend which can also be removed to obtain a stationary process. These are called trend-stationary processes. In both, unit-root and trend-stationary processes, the mean can be increasing or decreasing over time; however, in the presence of a shock, trend-stationary processes (blue) revert to this mean tendency in the long run (deterministic trend) while unit-root processes (green) have a permanent impact (stochastic trend). The significance level of the tests is usually set to 0.05.ADF
KPSS
Outcome
Note
Non-Stationary
Non-Stationary
Non-Stationary
Stationary
Stationary
Stationary
Non-Stationary
Stationary
Trend-Stationary
Check the de-trended series
Stationary
Non-Stationary
Difference-Stationary
Check the differenced-series
Methods:
as_summary
([alpha])This method creates the summary to display.
evaluate
([alpha])This method initialises the series.
fit
(x[, adf_kwargs, kpss_kwargs])This method studies the stationarity of a given time-series.
- fit(x, adf_kwargs={}, kpss_kwargs={}, **kwargs)[source]
This method studies the stationarity of a given time-series.
The parameters which can be passed to the adfuller and kpss methods are listed below:
adfuller_kwargs = {x, maxlag, regression, autolag, store, regresults}
kpss_kwargs = {x, regression, lags, store}
@see statsmodels.tsa.stattools.adfuller @see statsmodels.tsa.stattoosl.kpss
- Parameters:
x (array-like) – The time series
adf_kwargs (dict-like) – The parameters to pass to the adfuller function
kpss_kwargs (dict-like) – The parameters to apss to the kpss function
- Returns:
object
- Return type:
An StationarityWrapper objects.
pyamr.core.stats.wbase module
Classes:
|
Base Wrapper |
Functions:
|
Finds parameters in kwargs tho use in function. |
|
This method creates a dictionary with pairs name and value. |
- class pyamr.core.stats.wbase.BaseWrapper(estimator=None, evaluate=True)[source]
Bases:
object
Base Wrapper
Methods:
as_series
([flabel, label])This method returns a series with all the information.
This method displays the final summary.
evaluate
(**kwargs)fit
(**kwargs)This method performs the fit.
from_list_dataframe
(wrapper_list, **kwargs)This methods creates a dataframe summary from a list.
grid_search
(grid_params[, verbose])This method computes grid search.
load
(fname)This method loads the wrapper.
save
(fname)This method saves the wrapper.
- as_series(flabel=True, label=None)[source]
This method returns a series with all the information.
- Parameters:
flabel (boolean) – Wether to include a label before the attributes.
label (string) – The label to include before the attributes. By default it includes the value of the attribute self._name in lowercase.
- Returns:
series
- Return type:
pandas series with the results, configuration and model.
- fit(**kwargs)[source]
This method performs the fit.
- Parameters:
kwargs (dict-like) – The arguments that will be passed to the method.
- from_list_dataframe(wrapper_list, **kwargs)[source]
This methods creates a dataframe summary from a list.
- Parameters:
wrapper_list (array-like) – The list with wrapper objects.
flabel (boolean) – Wether to include a label before the attributes.
label (string) – The label to include before the attributes. By default it includes the value of the attribute self._name in lowercase.
- Returns:
summary
- Return type:
pandas dataframe.