【代码实践】R语言,ugarchspec函数(待完善)

本文详细介绍了如何在R语言中使用ugarchspec函数创建单变量GARCH模型,包括sGARCH、fGARCH等多种模型选择,以及自回归、移动平均、外部回归变量等设置。此外,还涵盖了模型的分布选择、初始参数和固定参数的设定,并解释了优化过程和输出结果。该模型可用于金融市场波动性建模和风险管理。
摘要由CSDN通过智能技术生成

一、描述

创建单变量GARCH

二、用法

ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1), 
submodel = NULL, external.regressors = NULL, variance.targeting = FALSE), 
mean.model = list(armaOrder = c(1, 1), include.mean = TRUE, archm = FALSE, 
archpow = 1, arfima = FALSE, external.regressors = NULL, archex = FALSE), 
distribution.model = "norm", start.pars = list(), fixed.pars = list(), ...)

三、参数

1、variance.model

List containing the variance model specification:

model Valid models (currently implemented) are “sGARCH”, “fGARCH”, “eGARCH”, “gjrGARCH”, “apARCH” and “iGARCH” and “csGARCH”.

garchOrder The ARCH (q) and GARCH (p) orders.

submodel If the model is “fGARCH”, valid submodels are “GARCH”, “TGARCH”, “AVGARCH”, “NGARCH”, “NAGARCH”, “APARCH”,“GJRGARCH” and “ALLGARCH”.

external.regressors A matrix object containing the external regressors to include in the variance equation with as many rows as will be included in the data (which is passed in the fit function).

variance.targeting (Logical or Numeric) If logical, indicates whether to use variance targeting for the conditional variance intercept “omega”, else if numeric, the value provided is used instead of the unconditional variance for the calculation of the intercept (in combination with the persistence value). Care should be taken if using the numeric option for apARCH and fGARCH models since the intercept is not the variance but sigma raised to the power of some positive value. Finally, if scaling is used (from the fit.control option in ugarchfit), the value provided is adjusted accordingly by the routine.

2、mean.model

List containing the mean model specification:

armaOrder The autoregressive (ar) and moving average (ma) orders (if any).

自回归系数和移动平均项。

include.mean Whether to include the mean.

archm Whether to include ARCH volatility in the mean regression.

archpow Indicates whether to use st.deviation (1) or variance (2) in the ARCH in mean regression.

arfima Whether to fractional differencing in the ARMA regression.

external.regressors A matrix object containing the external regressors to include in the mean equation with as many rows as will be included in the data (which is passed in the fit function).

archex (integer) Whether to multiply the last 'archex' external regressors by the conditional standard deviation.

3、distribution.model模型分布

The conditional density to use for the innovations. Valid choices are “norm” for the normal distibution, “snorm” for the skew-normal distribution, “std” for the student-t, “sstd” for the skew-student, “ged” for the generalized error distribution, “sged” for the skew-generalized error distribution, “nig” for the normal inverse gaussian distribution, “ghyp” for the Generalized Hyperbolic, and “jsu” for Johnson's SU distribution. Note that some of the distributions are taken from the fBasics package and implenented locally here for convenience. The “jsu” distribution is the reparametrized version from the “gamlss” package.

4、start.pars

List of staring parameters for the optimization routine. These are not usually required unless the optimization has problems converging.

5、fixed.pars

List of parameters which are to be kept fixed during the optimization. It is possible that you designate all parameters as fixed so as to quickly recover just the results of some previous work or published work. The optional argument “fixed.se” in the ugarchfit function indicates whether to calculate standard errors for those parameters fixed during the post optimization stage.

四、输出

A '>uGARCHspec object containing details of the GARCH specification.

输入>uGARCHspec即可查看模型参数。

五、细节

The specification allows for a wide choice in univariate GARCH models, distributions, and mean equation modelling.

大量的可选项

For the “fGARCH” model, this represents Hentschel's omnibus model which subsumes many others. For the mean equation, ARFIMAX is fully supported in fitting, forecasting and simulation. There is also an option to multiply the external regressors by the conditional standard deviation, which may be of use for example in calculating the correlation coefficient in a CAPM type setting. The “iGARCH” implements the integrated GARCH model. For the “EWMA” model just set “omega” to zero in the fixed parameters list. The asymmetry term in the rugarch package, for all implemented models, follows the order of the arch parameter alpha. Variance targeting, referred to in Engle and Mezrich (1996), replaces the intercept “omega” in the variance equation by 1 minus the persistence multiplied by the unconditional variance which is calculated by its sample counterpart in the squared residuals during estimation. In the presence of external regressors in the variance equation, the sample average of the external regresssors is multiplied by their coefficient and subtracted from the variance target. In order to understand which parameters can be entered in the start.pars and fixed.pars optional arguments, the list below exposes the names used for the parameters across the various models:(note that when a parameter is followed by a number, this represents the order of the model. Just increment the number for higher orders, with the exception of the component sGARCH permanent component parameters which are fixed to have a lag-1 autoregressive structure.):、

1、Mean Model

  • constant: mu

  • AR term: ar1

  • MA term: ma1

  • ARCH-in-mean: archm

  • exogenous regressors: mxreg1

  • arfima: arfima

ugarchspec-methods function - RDocumentation

RPubs - Value at Risk estimation using GARCH model

  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
variance.model = list(model = "sGARCH", garchOrder = c(1, 1),submodel = NULL, external.regressors = NULL, variance.targeting = FALSE) distribution.model = "norm" ugarchfit(spec, datax, out.sample = 0, solver = "solnp", solver.control = list(),fit.control = list(stationarity = 1, fixed.se = 0, scale = 0)) myspec=ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1), submodel = NULL, external.regressors = NULL, variance.targeting = FALSE), mean.model = list(armaOrder = c(1, 1), include.mean = TRUE, archm = FALSE, archpow = 1, arfima = FALSE, external.regressors = NULL, archex = FALSE), distribution.model = "norm") myfit=ugarchfit(myspec,data=datax,solver="solnp") #rugarch包中模型结果的提取要依靠as.data.frame函数。比如提取模型的拟合值 as.data.frame(myfit,which="fitted") #提取残差序列: as.data.frame(myfit,which=" residuals") #提取方差序列: as.data.frame(myfit,which="sigma") #当然,也可以同时查看所有: as.data.frame(myfit,which=all) #通过plot(myfit)可以对模型结果进行图形诊断: plot(myfit) #如果模型通过检验,可以用ugarchforcast函数对未来进行预测: for<-ugarchforcast(myfit,n.ahead=20) library(zoo) #时间格式预处理 library(xts) #同上 library(timeSeires) #同上 library(urca) #进行单位根检验 library(tseries) #arma模型 library(fUnitRoots) #进行单位根检验 library(FinTS) #调用其中的自回归检验函数 library(fGarch) #GARCH模型 library(nlme) #调用其中的gls函数 library(fArma) #进行拟合和检验
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值