跳转到主要内容

基于ARCH包构建的多元单变量ARCH建模工具箱

项目描述

MUArch

持续集成

Build Status Build status

文档

Documentation Status

覆盖率

Coverage Status

安装

使用 pip 和 conda 安装和更新。

这是对Kevin Sheppard的 ARCH 包的包装。其目的是

  1. 启用更快的蒙特卡洛模拟
  2. 通过copula边缘模拟创新

在包中,有2个类可以帮助您 - UArchMUArchUArch 类可以使用与原始 arch 包中的 arch_model 相似的API定义。 MUArch 是这些 UArch 模型的集合。

因此,如果您有一个生成均匀边缘的函数,如copula,您可以在模拟GARCH过程时在不同边缘之间创建依赖结构。

如果您需要一个copula包,我有一个 在这里。 :)

示例

我将列出执行AR-GARCH-Copula模拟的简单步骤。

from muarch import MUArch, UArch
from muarch.datasets import load_etf
from copulae import NormalCopula


returns = load_etf()  # load returns data
num_assets = returns.shape[1]

# sets up a MUArch model collection where each model defaults to 
# mean: AR(1)
# vol: GARCH(1, 1)
# dist: normal 
models = MUArch(num_assets, mean='AR', lags=1) 

# set first model to AR(1)-GARCH(1, 1) with skewt innovations  
models[0] = UArch('AR', lags=1, dist='skewt')  

# fit model, if you get complaints regarding non-convergence, you can scale the data up 
# using the scale parameter in the UArch or MUArch. i.e. UArch(..., scale=100). This will
# reduce numerical errors. Don't worry, I'll rescale the simulation values subsequently
models.fit(returns)

# Usually you'll want to fit the residuals to the copula, use the copula to generate the
# residuals and subsequently transform it back to returns 

residuals = models.residuals() # defaults to return the standardized residuals


cop = NormalCopula(dim=num_assets) # use a normal copula, you could of course use a TCopula
cop.fit(residuals)

# simulate 10 steps into the future, over 4 repetitions. This will return a (10 x 4 x 3) array
models.simulate_mc(10, 4, custom_dist=cop.random)

未来工作

这实际上是一个临时解决方案,以便其他人可以进行GARCH Copula模拟。另一个问题是,使用原始的arch包很难指定(和模拟)ARFIMA均值模型。您可以指定ARFIMA(或者甚至只是为了这个问题指定ARMA模型),单独拟合它,然后使用残差拟合零均值模型(纯GARCH)。然而,以这种方式,模拟并不直接,因为您将不得不将GARCH过程和均值模型过程的模拟拼接起来。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。

源代码发行版

muarch-0.2.2.tar.gz (436.7 kB 查看哈希)

上传时间

构建发行版

muarch-0.2.2-cp38-cp38-win_amd64.whl (432.5 kB 查看哈希)

上传时间 CPython 3.8 Windows x86-64

muarch-0.2.2-cp38-cp38-manylinux1_x86_64.whl (916.0 kB 查看哈希)

上传时间 CPython 3.8

muarch-0.2.2-cp37-cp37m-win_amd64.whl (431.6 kB 查看哈希)

上传时间 CPython 3.7m Windows x86-64

muarch-0.2.2-cp37-cp37m-manylinux1_x86_64.whl (907.2 kB 查看哈希)

上传时间 CPython 3.7m

由以下支持