tiny arch
Project description
archette
GARCH is a minimal implementation of the GARCH(1,1) model with zero mean and Gaussian noise.
Usage
Installation
Install latest from the GitHub repository:
$ pip install git+https://github.com/xiaochuany/archette.git
Documentation
Documentation can be found hosted on this GitHub repository’s pages.
How to use
import numpy as np
from archette import GARCHETTE
y = np.random.randn(20)
mod = GARCHETTE()
mod.fit(y)
<archette.core.GARCHETTE>
One can get inspect the fit params: a triplet of omega, alpha and beta as in
$$ \begin{align*} Y_t &= \sigma_t W_t \ \sigma_t^2 &= \omega + \alpha Y_{t-1}^2 + \beta \sigma^2_{t-1} \end{align*} $$
mod.params
array([1.46162489e+00, 0.00000000e+00, 4.34165554e-16])
The conditional variance of the fit model is computed by the recursion
$$ \hat{\sigma}t^2 = \hat{\omega} + \hat{\alpha} + \hat{\beta} \hat{\sigma}{t-1}^2 $$
which depends entirely on the unobserved $\sigma_0^2$. The model sets a sensible default value for it.
mod.vs
array([1.6637509 , 1.46162489, 1.46162489, 1.46162489, 1.46162489,
1.46162489, 1.46162489, 1.46162489, 1.46162489, 1.46162489,
1.46162489, 1.46162489, 1.46162489, 1.46162489, 1.46162489,
1.46162489, 1.46162489, 1.46162489, 1.46162489, 1.46162489])
The standardised residual is deduced from the conditional variance
$$ r_t = \frac{y_t}{\hat{\sigma}_t} $$
mod.std_resids
array([ 1.83606806, 0.40202783, -0.05913285, -0.47174874, -0.59056739,
-2.20575562, 0.71528908, 0.26541164, -0.20129438, 1.33214741,
-0.50849529, 0.2951227 , -0.84969512, 1.53542218, 0.44267321,
-1.95023795, -1.68947028, -0.23377285, -0.18693467, 0.7959041 ])
Finally, one can forecast the condtional variance and simulate the process with the fit parameters with a given horizon
mod.forecast_vs(horizon=5)
array([1.46162489, 1.46162489, 1.46162489, 1.46162489, 1.46162489])
mod.simulate(horizon=5, method="bootstrap", n_rep=2, seed=1)
array([[-2.66670736, 0.35679649, -1.02726169, -0.24336023, 1.61053531],
[ 0.35679649, -2.66670736, -2.35779243, 2.21976368, -2.04253036]])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file archette-0.1.1.tar.gz.
File metadata
- Download URL: archette-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b9296aaaa9919823824103450c30714ce0c76ba30fd268fb366c60ac43b0589
|
|
| MD5 |
c4fbac15aaee9eb3fad765380586448d
|
|
| BLAKE2b-256 |
e015ca08b209cfeda5b26e73e83e313a1b04db0c957bb605106b03895da54b92
|
File details
Details for the file archette-0.1.1-py3-none-any.whl.
File metadata
- Download URL: archette-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3763b31badb0d432e6e6273bc8618cf366b0b7d47a984ea38399df0fd169e593
|
|
| MD5 |
4f3bba1485fc3b8c73d10371238498ad
|
|
| BLAKE2b-256 |
ad3a259ea36e271427e831c071ee0860e074b0b1ff40d338c1a7cf9e82abdcdb
|