API¶
|
Pareto Hybrids with Asymmetric Tails |
|
Class for forecasting time series via ARMA-GARCH process. |
-
class
phat.dists.
Phat
(mu: float, sig: float, xi_l: float, xi_r: float, p: Optional[Iterable] = None)¶ Pareto Hybrids with Asymmetric Tails
- Twin-tailed distribution combines:
1) right-tailed CarBen with 2) left-tailed CarBen
Per Carreau and Bengio (2008).
The properites of the body in both distributions are equivalent; thus, the mixture requires just four parameters: two parameters for the Gaussian body and the tail index for each of the two tails. In all, the distribution has 8 parameters:
> Left tail: xi, a, b > Right tail: xi, a, b > Center: mu, sig
As with any mixture model, this mix is the weighted average result of values from the two components. Default weights are 0.5 / 0.5.
Weights could otherwise be estimated via machine learning, threshold analysis (for the tails), and gaussian statistics (for the body).
xi_l: inverse of tail index of left-tailed generalized Pareto tail xi_r: inverse of tail index of right-tailed generalized Pareto tail mu: mean of the Gaussian body sig: standard deviation of the Gaussian body p: relative weights of the two CarBen hybrids. Default: [.5, .5]
left: left-tailed CarBenHybrid object right: right-tailed CarBenHybrid object args: list of values of 8 parameters of Phat distribution params: name-value pairs of 8 parameters of Phat distribution learnable_params: name-value pairs of 4 given parameters of Phat distribution
> handle helper and common distribution functions that are agnostic to tail-direction
-
PARAM_NAMES
= ['mu', 'sig', 'xi_l', 'xi_r', 'a_l', 'a_r', 'b_l', 'b_r']¶
-
property
args
¶
-
property
params
¶
-
property
learnable_params
¶ Params tuned by machine learning approach
-
pdf
(x: Union[float, Iterable[Sequence[float]]] = None) → numpy.ndarray¶ x: float, m x n iterable of floats of random variable samples
float or iterable of floats returning the likelihood of occurence of each sample
-
cdf
(x: Union[float, Iterable[Sequence[float]]] = None) → numpy.ndarray¶ x: float, m x n iterable of floats of random variable samples
float or iterable of floats returning cumulative probability of each sample
-
sf
(x: Union[float, Iterable[Sequence[float]]] = None) → numpy.ndarray¶ x: float, m x n iterable of floats of random variable samples
float or iterable of floats returning survival probability of each sample
-
ppf
(q: Union[float, Iterable[Sequence[float]]] = None) → numpy.ndarray¶ q: float, iterable of floats between [0, 1]
float or iterable of floats returning x values corresponding to the given quantiles
-
loglike
(x=None)¶
-
nll
(x: Union[float, Iterable[Sequence[float]]] = None) → numpy.ndarray¶ Negative loglikelihood used in machine learning cost functions
-
rvs
(size: Optional[Union[int, Iterable[Sequence[int]]]] = None, seed: Optional[int] = None) → Union[float, Iterable[Sequence[float]]]¶ Generates random draws
Draws randomly from [0,1] uniform distribution
Calls quantile function for each draw
Mimics scipy process: https://github.com/scipy/scipy/blob/28e4811d48c99b7c68e41992eda5cff859c1fa2b/scipy/stats/_distn_infrastructure.py#L1032
size: int or iterable of ints providing dimensions of return array seed: int; initialize with specific random state for replication
-
mean
() → float¶
-
var
() → float¶
-
std
()¶
-
std_rvs
(*args, **kwargs)¶ Generates random variables standardized by dividing by the standard deviation
Resulting samples should have a standard deviation of 1
-
static
fit
(values, xi_l: Optional[float] = None, xi_r: Optional[float] = None) → phat.dists.PhatFit¶ Generates standard log-likelihood fit to Phat distribution
PhatFit object, which is a light wrapper for statsmodels GenericLogLikelihood
-
class
phat.tseries.
Garchcaster
(garch: Optional[Union[arch.univariate.base.ARCHModelResult, Iterable[float]]] = None, arma: Optional[Union[pmdarima.arima.arima.ARIMA, Iterable[float]]] = None, y: Optional[Iterable[float]] = None, vols: Optional[Iterable[float]] = None, resids: Optional[Iterable[float]] = None, iters: int = 1, periods: int = 252, order: Optional[tuple] = None, dist: Optional[Union[phat.dists.Phat, scipy.stats._distn_infrastructure.rv_frozen]] = None, use_backcast: bool = True)¶ Class for forecasting time series via ARMA-GARCH process.
Instances of a pmdarima-based ARIMA object and/or an ARCHModelResult from the arch package can be provided directly. Alternatively, the user can provide all residuals, standardized residuals, conditional volatilities, the parameters for the ARMA-GARCH process, and the order.
- arma: instance of pmdarima ARIMA class OR iterable of floats;
Either provide a pmdarima instance or the params derived from any arima process. If None, will search for AR process in garch, otherwise assumes ConstantMean.
- garch: instance of arch ARCHModelResult class OR iterable of floats;
either provide an ARCHModelResult instance or the params derived from any garch process
- y: float or iterable of floats;
iters x periods standardized residuals after filtering an ARMA-GARCH. Only required if garch is not ARCHModelResult type.
- vols: float or iterable of floats;
iters x periods conditional volatilities resulting from an ARMA-GARCH process. Only required if garch is not ARCHModelResult type.
- resids: float or iterable of floats; iters x periods residuals after filtering an ARMA-GARCH.
Only required if garch is not ARCHModelResult type.
iters: int; number of iterations of forecast periods: int; number of periods in each iteration of the forecast dist: Phat or scipy rv_frozen class; distribution used to generate residuals use_backcast: bool; use procedure to smooth values. See https://arch.readthedocs.io/en/latest/univariate/generated/generated/arch.univariate.GARCH.backcast.html
-
forecast
(iters: int = None, periods: int = None, dist: Union[phat.dists.Phat, scipy.stats._distn_infrastructure.rv_frozen] = None, innovs: Iterable = None, seed: int = None) → phat.tseries.GarchcastResults¶ User-facing interface with forecast generator
iters: int; number of iterations of forecast periods: int; number of periods in each iteration of the forecast dist: Phat or scipy rv_frozen class; distribution used to generate residuals innovs: iters x periods np.ndarray of garch residuals seed: int; random state for innovation determination if innovs is not provided
GarchcastResults