├── .Rinstignore ├── ChangeLog ├── DESCRIPTION ├── MD5 ├── NAMESPACE ├── R ├── copula-classes.R ├── copula-distributions.R ├── copula-fn.R ├── copula-likelihoods.R ├── copula-main.R ├── copula-methods.R ├── copula-postestimation.R ├── copula-solver.R ├── copula-transformations.R ├── fdcc-likelihoods.R ├── fdcc-main.R ├── gogarch-classes.R ├── gogarch-distributions.R ├── gogarch-main.R ├── gogarch-methods.R ├── rdcc-classes.R ├── rdcc-likelihoods.R ├── rdcc-main.R ├── rdcc-mdistributions.R ├── rdcc-methods.R ├── rdcc-plots.R ├── rdcc-postestimation.R ├── rdcc-solver.R ├── rmgarch-classes.R ├── rmgarch-extrafun.R ├── rmgarch-functions.R ├── rmgarch-ica.R ├── rmgarch-mmean.R ├── rmgarch-scenario.R ├── rmgarch-series.R ├── rmgarch-tests.R ├── rmgarch-var.R └── zzz.R ├── README.md ├── TODO ├── build └── vignette.rds ├── data └── dji30retw.rda ├── inst ├── CITATION ├── COPYRIGHTS ├── doc │ ├── The_rmgarch_models.Rnw │ └── The_rmgarch_models.pdf └── rmgarch.tests │ ├── rmgarch.test1.R │ ├── rmgarch.test2.R │ ├── rmgarch.test3.R │ ├── rmgarch.test4.R │ ├── rmgarch.test5.R │ ├── rmgarch.test6.R │ └── runtests.R ├── man ├── DCCfilter-class.Rd ├── DCCfit-class.Rd ├── DCCforecast-class.Rd ├── DCCroll-class.Rd ├── DCCsim-class.Rd ├── DCCspec-class.Rd ├── DCCtest.Rd ├── cGARCHfilter-class.Rd ├── cGARCHfit-class.Rd ├── cGARCHsim-class.Rd ├── cGARCHspec-class.Rd ├── cgarchfilter-methods.Rd ├── cgarchfit-methods.Rd ├── cgarchsim-methods.Rd ├── cgarchspec-methods.Rd ├── cordist.Rd ├── dccfilter-methods.Rd ├── dccfit-methods.Rd ├── dccforecast-methods.Rd ├── dccroll-methods.Rd ├── dccsim-methods.Rd ├── dccspec-methods.Rd ├── dji30retw.Rd ├── fMoments-class.Rd ├── fScenario-class.Rd ├── fastica.Rd ├── fmoments-methods.Rd ├── fscenario-methods.Rd ├── goGARCHfft-class.Rd ├── goGARCHfilter-class.Rd ├── goGARCHfit-class.Rd ├── goGARCHforecast-class.Rd ├── goGARCHroll-class.Rd ├── goGARCHsim-class.Rd ├── goGARCHspec-class.Rd ├── gogarchfilter-methods.Rd ├── gogarchfit-methods.Rd ├── gogarchforecast-methods.Rd ├── gogarchroll-methods.Rd ├── gogarchsim-methods.Rd ├── gogarchspec-methods.Rd ├── goload-methods.Rd ├── last-methods.Rd ├── mGARCHfilter-class.Rd ├── mGARCHfit-class.Rd ├── mGARCHforecast-class.Rd ├── mGARCHroll-class.Rd ├── mGARCHsim-class.Rd ├── mGARCHspec-class.Rd ├── radical.Rd ├── rmgarch-package.Rd ├── varxfit.Rd └── wmargin.Rd ├── src ├── Makevars ├── Makevars.win ├── copulas.cpp ├── copulas.h ├── gogarch.cpp ├── gogarch.h ├── ica.cpp ├── ica.h ├── init.c ├── rdcc.cpp ├── rdcc.h ├── rmdist.cpp └── rmdist.h └── vignettes ├── The_rmgarch_models.Rnw ├── rmgarch1.tex └── rmgarchbib.bib /.Rinstignore: -------------------------------------------------------------------------------- 1 | ./vignettes/The_rmgarch_models.tex 2 | ./vignettes/rmgarch1.tex 3 | rmgarch.tests -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: rmgarch 2 | Type: Package 3 | Title: Multivariate GARCH Models 4 | Version: 1.3-9 5 | Date: 2022-02-03 6 | Author: Alexios Galanos 7 | Maintainer: Alexios Galanos 8 | Depends: R (>= 3.0.2), methods, rugarch (>= 1.4-7), parallel 9 | LinkingTo: Rcpp (>= 0.10.6), RcppArmadillo (>= 0.2.34) 10 | Imports: Rsolnp, MASS, Matrix, zoo, xts, Bessel, ff, shape, pcaPP, spd, 11 | Rcpp, utils, graphics, stats, grDevices, corpcor 12 | Description: Feasible multivariate GARCH models including DCC, GO-GARCH and Copula-GARCH. 13 | Collate: rmgarch-extrafun.R rmgarch-var.R rmgarch-functions.R 14 | rmgarch-classes.R rmgarch-ica.R rmgarch-series.R 15 | rmgarch-mmean.R gogarch-classes.R gogarch-distributions.R 16 | gogarch-main.R gogarch-methods.R rdcc-classes.R rdcc-main.R 17 | rdcc-likelihoods.R rdcc-plots.R fdcc-likelihoods.R fdcc-main.R 18 | rdcc-methods.R rdcc-mdistributions.R rdcc-postestimation.R 19 | rdcc-solver.R copula-classes.R copula-distributions.R 20 | copula-likelihoods.R copula-solver.R copula-fn.R 21 | copula-transformations.R copula-main.R copula-postestimation.R 22 | copula-methods.R rmgarch-tests.R rmgarch-scenario.R zzz.R 23 | LazyLoad: yes 24 | URL: http://www.unstarched.net, https://github.com/alexiosg/rmgarch 25 | License: GPL-3 26 | NeedsCompilation: yes 27 | Packaged: 2022-02-04 22:51:09 UTC; alexios 28 | Repository: CRAN 29 | Date/Publication: 2022-02-05 00:30:06 UTC 30 | -------------------------------------------------------------------------------- /MD5: -------------------------------------------------------------------------------- 1 | da6689d0ee17f0f62f23decc36704377 *ChangeLog 2 | 1e5f7b388b83dabbe42c9d4fe99a5000 *DESCRIPTION 3 | 0d66ac76a272694da38dae257d35758b *NAMESPACE 4 | 8f8a9830325239ae97723c4bb0aec1ea *R/copula-classes.R 5 | f64fb5b06f7ed4716acf614f897e65c4 *R/copula-distributions.R 6 | 3e91e05866e36fc1a834d65c1651f1ac *R/copula-fn.R 7 | f82a5e3d00d8e041a85a9abfe9c968ca *R/copula-likelihoods.R 8 | e5260284e82b53b1b7af62ffca129a80 *R/copula-main.R 9 | b32455cd262fd5d7ac15c3eb996b8e94 *R/copula-methods.R 10 | c933c727d2dda456ff77ee4f3453e1d2 *R/copula-postestimation.R 11 | 8548cd1c2f927d2795757c8898b2ba11 *R/copula-solver.R 12 | b973c4ebd0e1744be82e0a3d7506343b *R/copula-transformations.R 13 | cc4cb432c145fd3cd7168e8568b4f24b *R/fdcc-likelihoods.R 14 | a35598979d0f5c9cac1e434eb9359cf3 *R/fdcc-main.R 15 | 9409cbcaf852bf2b6bf37d8f7fd2e4df *R/gogarch-classes.R 16 | 701b23718b304089202d481ad0ab39a8 *R/gogarch-distributions.R 17 | 9ae5c9d5a275592fb519a2d41f873550 *R/gogarch-main.R 18 | 90182ddfc97691966a5e9d2a058da5a8 *R/gogarch-methods.R 19 | 556cdd7d2430c9f66412dc072e73af50 *R/rdcc-classes.R 20 | 9080c778fa9473432e38c29dc1aeded7 *R/rdcc-likelihoods.R 21 | 21e63c0356c1bd069da7e1b62369add5 *R/rdcc-main.R 22 | 9b334ca0af684440a8f015b7a7b203d2 *R/rdcc-mdistributions.R 23 | dd1760b550127b259f0775ba23fe28d4 *R/rdcc-methods.R 24 | 5e2b02ba33ae529927980c41919a6066 *R/rdcc-plots.R 25 | b67870e9e8edbb8d7f738365d5a7f4cf *R/rdcc-postestimation.R 26 | 0647a4cee62d5dbe0dc0c0413af07094 *R/rdcc-solver.R 27 | 69cba8b7db9e66cfc8ecf80939249075 *R/rmgarch-classes.R 28 | db2da603e857b25d753d4846f3aa79cf *R/rmgarch-extrafun.R 29 | e8f307a96c70f85f1d3382e063ca3c49 *R/rmgarch-functions.R 30 | 342363f865be0b5275c526d2bb8d5d4f *R/rmgarch-ica.R 31 | a0357722bd2c868892bb8504bb6279b5 *R/rmgarch-mmean.R 32 | 427ed35a9ee5444de8c47ae277d5ecfd *R/rmgarch-scenario.R 33 | 8a6d64fa4b3af6862756ef970cbcfb81 *R/rmgarch-series.R 34 | 6ad54ca36ec5bcbd0b52ee1cba97f9f7 *R/rmgarch-tests.R 35 | ca1a4600e8304ab2d4ccbe9641925c69 *R/rmgarch-var.R 36 | 4358dba1f8442dd9bf6bbff527458555 *R/zzz.R 37 | 945d2bf1fe2e2b89a39eb41811aa25ee *README.md 38 | 71ee9626abcd6eab5880997f76a162ee *TODO 39 | e45ced575a4b6cf4c385b5c9ba6f2b3b *build/vignette.rds 40 | 420ec2fc9209af62681c5c0738efb297 *data/dji30retw.rda 41 | e3210f96a9774a7e9a12ec845602b16f *inst/CITATION 42 | b7284de524621d8f1297901485f6729b *inst/COPYRIGHTS 43 | 624b2d82c1debe71ed3ecc4030f87c34 *inst/doc/The_rmgarch_models.Rnw 44 | f38bf5e78537ef4865f7c44e44e67e4c *inst/doc/The_rmgarch_models.pdf 45 | 40adaa0ce749c403272ccf3b040a792b *inst/rmgarch.tests/rmgarch.test1.R 46 | 4a32ea8c85e2c4c903c53dd71c91feb4 *inst/rmgarch.tests/rmgarch.test2.R 47 | 54429fc7b1f5e9802f0bd3764f32ee59 *inst/rmgarch.tests/rmgarch.test3.R 48 | 2aede7f21beceba26e6e3a9133866283 *inst/rmgarch.tests/rmgarch.test4.R 49 | faa30840117436d0f31edd61e9954e5e *inst/rmgarch.tests/rmgarch.test5.R 50 | 8ab54176d71b7f9db0c0ac8d572c84a4 *inst/rmgarch.tests/rmgarch.test6.R 51 | d095e570b3dd132eed1e5cc2c2ca3637 *inst/rmgarch.tests/runtests.R 52 | 2342eb5f25d587f117a8b8c2ad68b75f *man/DCCfilter-class.Rd 53 | 8bc475041101c2141b7bd437930e3d86 *man/DCCfit-class.Rd 54 | e6a7c4d400488321825819b9e982443f *man/DCCforecast-class.Rd 55 | 18400c69770dbddc0f5f59933f09fccd *man/DCCroll-class.Rd 56 | 87dce689be7efea010ef9b78425c025f *man/DCCsim-class.Rd 57 | e6e3c9de0ffe7b1d1c5fe5eb9e339ec5 *man/DCCspec-class.Rd 58 | d284cd610936105862beb968b83fb51a *man/DCCtest.Rd 59 | 9e4818dd9c8e6b2a25363d27a5d3a432 *man/cGARCHfilter-class.Rd 60 | b02ad6be910743c93d872ca9baf94a02 *man/cGARCHfit-class.Rd 61 | d54132b3f220e20813ee43b157d696ab *man/cGARCHsim-class.Rd 62 | 3990e577ccb918bdedc2761648f8fc2c *man/cGARCHspec-class.Rd 63 | 8e024e94036bfe80343aed16c9c60958 *man/cgarchfilter-methods.Rd 64 | da1624ba0670a49f813c72226a17afaa *man/cgarchfit-methods.Rd 65 | 03aad9121922ab6124617655e8683f95 *man/cgarchsim-methods.Rd 66 | b634448105ee76f04294cd2d1a674cd3 *man/cgarchspec-methods.Rd 67 | 945d8010cc7cb17f8635636a49eddb1a *man/cordist.Rd 68 | 7c86ba1361f82dbb5ad6155392985048 *man/dccfilter-methods.Rd 69 | a145a524a6b99c1028dfec9923d8ece6 *man/dccfit-methods.Rd 70 | b69a6548d0296329159feba29e58809f *man/dccforecast-methods.Rd 71 | 934170495ee8fe305376d4c474155ba5 *man/dccroll-methods.Rd 72 | f9c49f986c34899c4b4164ef36efc86d *man/dccsim-methods.Rd 73 | 9ee2599f4bc7e906544d8ea2db087c0f *man/dccspec-methods.Rd 74 | d709c645a960bba70b6e5ee65a53c39a *man/dji30retw.Rd 75 | 7799280a36bd9b8a2e9390b08ab551c6 *man/fMoments-class.Rd 76 | 4bd4ca34f0408e1dd80c142dee1139d6 *man/fScenario-class.Rd 77 | 6011305d48033fe284dead07739b7c12 *man/fastica.Rd 78 | 2059bf316df70a2bf11f486ef115510b *man/fmoments-methods.Rd 79 | 89c4b7c41e5a74e6703d9507396f6b04 *man/fscenario-methods.Rd 80 | ee9b00adf3910a6e33375e9a20598ebf *man/goGARCHfft-class.Rd 81 | ae2c5a8d0999b38c1b3800622a574413 *man/goGARCHfilter-class.Rd 82 | fce3007dae843aa6fa5ec7ab16a0d2a4 *man/goGARCHfit-class.Rd 83 | 2fafbc1ac49de9a67d4088ce149fa011 *man/goGARCHforecast-class.Rd 84 | f08dd96be2649029a7e664b36e4df4b9 *man/goGARCHroll-class.Rd 85 | 96111eb83633dd5090a9e628954e0cde *man/goGARCHsim-class.Rd 86 | 9a67c423fcd3a5c2dfec598357f67e0e *man/goGARCHspec-class.Rd 87 | 80a5220dad631dbba9aab0bf73ce82db *man/gogarchfilter-methods.Rd 88 | 7e4fe02601eb7fabb0f084547da142e5 *man/gogarchfit-methods.Rd 89 | 8976e5a6e642e8ef2349f164d2680df9 *man/gogarchforecast-methods.Rd 90 | bb9503dbbd4d9c201775dcce705543c3 *man/gogarchroll-methods.Rd 91 | 402e2c000bca9643cc5e6a51ff9afa2d *man/gogarchsim-methods.Rd 92 | 9a895b665e55a7f83dcb14693ec3a663 *man/gogarchspec-methods.Rd 93 | f0436fe5280fb7f7999b98809da6b664 *man/goload-methods.Rd 94 | af5602290d44819094c38fcbc08ab38e *man/last-methods.Rd 95 | 7d6a530070a74019596dd5173178adb8 *man/mGARCHfilter-class.Rd 96 | 8dbea91b4e18bfc8e8d016dc3a12ad7d *man/mGARCHfit-class.Rd 97 | 78d2d1d9be04ddb0614e15e405483ef2 *man/mGARCHforecast-class.Rd 98 | cea78b2514f026c8c0e26b38f89e079d *man/mGARCHroll-class.Rd 99 | f686c314d0e2c79e0c657aec56a43c8b *man/mGARCHsim-class.Rd 100 | c5ec8f377f36be5d52df2dc21417f79c *man/mGARCHspec-class.Rd 101 | 992a8acedc6495d2916dd1fe8d10e8f6 *man/radical.Rd 102 | 19b33d7c0506acb9849b39d969d9ef8b *man/rmgarch-package.Rd 103 | 48989b57774c2db2033f5fa1dd5557ee *man/varxfit.Rd 104 | 26e649e4fce8cd9eedb495f3fb19c6d9 *man/wmargin.Rd 105 | 38394f3734100525a670e01ce2231677 *src/Makevars 106 | 15b9696d8f39701559354621b9c19758 *src/Makevars.win 107 | ba0b6238b3fc8ec25dc47f35213897cb *src/copulas.cpp 108 | ca3f2814341592291073c1af12d22b40 *src/copulas.h 109 | 4b2468062455ecc02142b5f9f371969c *src/gogarch.cpp 110 | 04f38cadf8204529c4190c67cc4b6d42 *src/gogarch.h 111 | 57607f2995c17ff987d35a82e9380fd2 *src/ica.cpp 112 | 21f93c19ed52bac8d2e600a62697fb7c *src/ica.h 113 | 3fa06dec7f6be85a987d66ca33af841c *src/init.c 114 | f27eca14bce983aa47e0c35f2214cd71 *src/rdcc.cpp 115 | ac5573d63d5867f5f7b50c7b65d15f28 *src/rdcc.h 116 | 90fbca28e2469be9b14ef02244f1722a *src/rmdist.cpp 117 | d082914dbb4a617cb5a4b5326c4e640d *src/rmdist.h 118 | 624b2d82c1debe71ed3ecc4030f87c34 *vignettes/The_rmgarch_models.Rnw 119 | 4537b62ac5d8a3f81f4a301599463164 *vignettes/rmgarch1.tex 120 | 66d36088ab0a1115b18d9136c85dd527 *vignettes/rmgarchbib.bib 121 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | useDynLib(rmgarch,.registration = TRUE) 2 | importFrom("graphics", "plot", "lines", "abline", "axis", "contour", "grid", "image", "layout", "legend", "mtext", "par", "persp", "title") 3 | importFrom("grDevices","colorRampPalette", "colors", "dev.cur", "dev.flush", "dev.hold", "dev.new", "dev.next", "heat.colors", "hsv", "terrain.colors") 4 | importFrom("stats", "coef", "residuals", "fitted", "approx", "approxfun", "cor", "cov", "cov.wt", "cov2cor", "dnorm", "ecdf", "embed", "fft", "integrate", "lm", "mahalanobis", "median", "na.omit", "nlminb", "optim", "pchisq", "pnorm", "qchisq", "qnorm", "rchisq", "resid", "rnorm", "runif", "stepfun") 5 | importFrom("utils", "combn", "head", "menu", "tail") 6 | importFrom(Matrix, Matrix, crossprod, t, as.matrix) 7 | importFrom(MASS, cov.rob, cov.trob) 8 | importFrom(xts, xts, as.xts, axTicksByTime) 9 | importFrom(zoo, coredata, index, zoo, as.zoo) 10 | importFrom(parallel, clusterEvalQ, clusterExport, parLapply, clusterMap, parSapply, makePSOCKcluster, makeForkCluster, stopCluster) 11 | importFrom(Bessel, BesselK) 12 | importFrom(spd, spdfit, qspd, pspd, rspd) 13 | importFrom(ff, ff) 14 | importFrom(Rsolnp, solnp, gosolnp, startpars) 15 | importFrom(pcaPP, cor.fk) 16 | importFrom(corpcor, is.positive.definite, make.positive.definite) 17 | import(rugarch) 18 | import(methods) 19 | importFrom(Rcpp, evalCpp) 20 | exportClasses("mGARCHspec", "mGARCHfit", "mGARCHfilter", "mGARCHforecast", "mGARCHsim", "mGARCHroll") 21 | exportClasses("goGARCHspec", "goGARCHfit", "goGARCHfilter", "goGARCHforecast", "goGARCHsim", "goGARCHroll") 22 | exportClasses("goGARCHfft") 23 | exportClasses("DCCspec", "DCCfit", "DCCfilter", "DCCforecast", "DCCsim", "DCCroll") 24 | exportClasses("cGARCHspec", "cGARCHfit", "cGARCHfilter", "cGARCHsim") 25 | exportClasses("fMoments", "fScenario") 26 | exportMethods("rcov", "rcor", "rcoskew", "rcokurt","convolution","as.matrix") 27 | exportMethods("gportmoments", "nportmoments", "nisurface") 28 | exportMethods("dfft", "pfft", "qfft") 29 | exportMethods("fmoments", "fscenario","goload","goget") 30 | exportMethods("betacovar", "betacokurt","betacoskew") 31 | export("gogarchspec", "gogarchfit", "gogarchfilter", "gogarchforecast", "gogarchsim", "gogarchroll") 32 | export("dccspec", "dccfit", "dccfilter", "dccforecast", "dccsim", "dccroll", "rshape", "rskew") 33 | export("cgarchspec", "cgarchfit", "cgarchfilter", "cgarchsim") 34 | export("first", "last", "cordist") 35 | export("fastica", "radical") 36 | export("varxfit", "varxfilter", "varxforecast", "varxsim", "wmargin", "DCCtest") 37 | -------------------------------------------------------------------------------- /R/copula-classes.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | # Copula GARCH 18 | setClass("cGARCHspec", 19 | representation(model = "vector", 20 | umodel = "vector"), 21 | contains = "mGARCHspec") 22 | 23 | setClass("cGARCHfit", 24 | representation(mfit = "vector", 25 | model = "vector"), 26 | contains = "mGARCHfit") 27 | 28 | 29 | setClass("cGARCHfilter", 30 | representation(mfilter = "vector", 31 | model = "vector"), 32 | contains = "mGARCHfilter") 33 | 34 | 35 | setClass("cGARCHsim", 36 | representation(msim = "vector", 37 | model = "vector"), 38 | contains = "mGARCHsim") 39 | -------------------------------------------------------------------------------- /R/copula-fn.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | ########################################################################################## 19 | # Some functions imported directly from QRMlib and mvtnorm and adjusted for use in this package 20 | ########################################################################################## 21 | 22 | #------------------------------------------------------------------------------------ 23 | # Copula densities take the form: 24 | # dMultivariate/Product(dUnivariate) 25 | # log(dMultivariate) - Sum(log(dUnivariate)) 26 | .Spearman = function(data) 27 | { 28 | Rho = cor(apply(data, 2, rank)) 29 | return( Rho ) 30 | } 31 | 32 | .Pconstruct <- function(theta){ 33 | n <- length(theta) 34 | d <- (1 + sqrt(1+8*n))/2 35 | A <- matrix(0,nrow=d,ncol=d) 36 | A[lower.tri(A)] <- theta 37 | diag(A) <- rep(1,d) 38 | Q <- A %*% t(A) 39 | P <- cov2cor(Q) 40 | P 41 | } 42 | 43 | .Pdeconstruct <- function(P){ 44 | A <- t(chol(P)) 45 | Adiag <- diag(diag(A)) 46 | Astar <- solve(Adiag) %*% A 47 | Astar[lower.tri(Astar)] 48 | } 49 | 50 | .vechR = function(Rho) 51 | { 52 | Rho[lower.tri(Rho)] 53 | } 54 | 55 | .ivechR = function(theta) 56 | { 57 | n = length(theta) 58 | n = (1 + sqrt(1+8*n))/2 59 | Rho = matrix(NA, n, n) 60 | Rho[lower.tri(Rho)] = theta 61 | Rho[upper.tri(Rho)] = theta 62 | diag(Rho) = 1 63 | Rho 64 | } 65 | 66 | 67 | .vech2 = function(Rho) 68 | { 69 | A = t(chol(Rho)) 70 | Adiag = diag(diag(A)) 71 | Astar = solve(Adiag) %*% A 72 | return( Astar[lower.tri(Astar)] ) 73 | } 74 | 75 | .ivech2 = function(theta) 76 | { 77 | n = length(theta) 78 | d = (1 + sqrt(1+8*n))/2 79 | A = matrix(0, d, d) 80 | A[lower.tri(A)] = theta 81 | diag(A) = rep(1,d) 82 | Q = A %*% t(A) 83 | Rho = cov2cor(Q) 84 | return( Rho ) 85 | } 86 | 87 | # about 3 times faster than "cor" function 88 | # NO LONGER USED...replaced by cor.fk of pcaPP package 89 | #.Kendall = function(data) 90 | #{ 91 | # n <- dim(data)[1] 92 | # d <- dim(data)[2] 93 | # Rho <- matrix(0, nrow = d, ncol = d) 94 | # gr = as.matrix(combn(1:d, 2)) 95 | # z = apply(gr, 2, FUN = function(x) Kendall(data[,x[1]], data[, x[2]])$tau) 96 | # Rho[lower.tri(Rho)] = z 97 | # Rho = Rho + t(Rho) 98 | # diag(Rho) = 1 99 | # nms <- dimnames(data)[[2]] 100 | # dimnames(Rho) <- list(nms, nms) 101 | # return( Rho ) 102 | #} 103 | 104 | #.fit.kendall = function(Udata) 105 | #{ 106 | # Rho = .Kendall(Udata) 107 | # Rbar = sin(pi * Rho/2) 108 | # n = dim(Udata)[2] 109 | # dimn = n * (n - 1) / 2 110 | # vRbar = Rbar[lower.tri(Rbar)] 111 | # X = diag(dimn) 112 | # estimate = lm(vRbar ~ X - 1)$coef 113 | # A = matrix(0, ncol = n, nrow = n) 114 | # A[lower.tri(A)] = as.numeric(estimate) 115 | # A = A + t(A) 116 | # diag(A) = 1 117 | # return( A ) 118 | #} 119 | 120 | ######################################################################## 121 | # From corpcor package: 122 | # Method by Higham 1988 123 | .makeposdef = function(m) 124 | { 125 | d = dim(m)[1] 126 | es = eigen(m) 127 | esv = es$values 128 | delta = 2*d*max(abs(esv))*.Machine$double.eps 129 | tau = pmax(0, delta - esv) 130 | dm = es$vectors %*% diag(tau, d) %*% t(es$vectors) 131 | return( m + dm ) 132 | } 133 | #------------------------------------------------------------------------------------ 134 | 135 | 136 | #------------------------------------------------------------------------------------ 137 | 138 | ####################################################################################### 139 | # copula likelihood functions (cpp coded) 140 | #------------------------------------------------------------------------------------ 141 | # .tvtcopulafn = function(pars, data, type = "LLH") 142 | # { 143 | # nu = pars[1] 144 | # alpha = pars[2] 145 | # beta = pars[3] 146 | # # this is the slowest part of the routine (student quantile) 147 | # # qt is vectorized but no discernable difference in using apply instead 148 | # Qdata = apply(data, 2, FUN = function(x) rugarch:::qstd(p = x, shape = nu)) 149 | # n = dim(data)[1] 150 | # m = dim(data)[2] 151 | # Qbar = cov(Qdata) 152 | # Rbar = cov2cor(Qbar) 153 | # ans = try(.Call("dccCopulaStudent", Qbar = Qbar, U = Qdata, Rbar = Rbar, dcca = alpha, 154 | # dccb = beta, tnu = nu, dccorder = c(1,1,1), dccsum = alpha + beta, 155 | # PACKAGE="rmgarch"), silent = TRUE) 156 | # if(inherits(ans, "try-error")){ 157 | # ret = Inf 158 | # } else { 159 | # ret = switch(type, LLH = -ans[[3]], ALL = ans) 160 | # } 161 | # return(ret) 162 | # } 163 | 164 | .tcopulafn = function(pars, data, Rbar, type = "LLH") 165 | { 166 | nu = pars[1] 167 | Qdata = apply(data, 2, FUN = function(x) qdist(distribution = "std", p = x ,shape = nu)) 168 | #ans = try(.Call("staticCopulaStudent", U = Qdata, Rbar = Rbar, tnu = nu), silent = TRUE) 169 | ans = dcopula.student(U = Qdata, Corr = Rbar, df = nu, logvalue = TRUE) 170 | 171 | ret = switch(type, 172 | LLH = -ans, 173 | ALL = list(LLH = ans, Rbar = Rbar)) 174 | return(ret) 175 | } 176 | 177 | # .tvgausscopulafn = function(pars, data, type = "LLH") 178 | # { 179 | # alpha = pars[2] 180 | # beta = pars[3] 181 | # Qdata = apply(data, 2, FUN = function(x) qnorm(p = x)) 182 | # n = dim(data)[1] 183 | # m = dim(data)[2] 184 | # Qbar = cov(Qdata) 185 | # Rbar = cov2cor(Qbar) 186 | # ans = try(.Call("dccCopulaNormal", Qbar = Qbar, U = Qdata, Rbar = Rbar, dcca = alpha, 187 | # dccb = beta, dccorder = c(1,1,1), dccsum = alpha + beta, 188 | # PACKAGE="rmgarch"), silent = TRUE) 189 | # if(inherits(ans, "try-error")){ 190 | # ret = Inf 191 | # } else { 192 | # ret = switch(type, LLH = -ans[[3]], ALL = ans) 193 | # } 194 | # return(ret) 195 | # } 196 | 197 | .gausscopulafn = function(pars, data, Rbar, type = "LLH") 198 | { 199 | Qdata = apply(data, 2, FUN = function(x) qnorm(p = x)) 200 | ans = dcopula.gauss(U = Qdata, Sigma = Rbar, logvalue = TRUE) 201 | ret = switch(type, 202 | LLH = -ans, 203 | ALL = list(LLH = ans, Rbar = Rbar)) 204 | return(ret) 205 | } 206 | #------------------------------------------------------------------------------------ 207 | 208 | 209 | 210 | ##################################################################################### 211 | # Auxiliary Functions 212 | #------------------------------------------------------------------------------------ 213 | 214 | .cor2cov = function(corr, sigmas) 215 | { 216 | V = (sigmas)%o%(sigmas)*corr 217 | V 218 | } 219 | -------------------------------------------------------------------------------- /R/copula-transformations.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | 19 | ##################################################################################### 20 | # Transformation Functions 21 | #------------------------------------------------------------------------------------ 22 | 23 | .pparametric = function(mfit, zres) 24 | { 25 | m = dim(zres)[2] 26 | n = dim(zres)[1] 27 | ures = matrix(NA, ncol = m, nrow = n) 28 | 29 | for(i in 1:m){ 30 | gdist = mfit@fit[[i]]@model$modeldesc$distribution 31 | lambda = ifelse(mfit@fit[[i]]@model$modelinc[18]>0, mfit@fit[[i]]@fit$ipars["ghlambda",1], 0) 32 | skew = ifelse(mfit@fit[[i]]@model$modelinc[16]>0, mfit@fit[[i]]@fit$ipars["skew",1], 0) 33 | shape = ifelse(mfit@fit[[i]]@model$modelinc[17]>0, mfit@fit[[i]]@fit$ipars["shape",1], 0) 34 | ures[,i] = pdist(gdist, zres[,i], mu = 0, sigma = 1, lambda = lambda, skew = skew, shape = shape) 35 | } 36 | return(ures) 37 | } 38 | 39 | .pparametric.filter = function(mflt, zres) 40 | { 41 | m = dim(zres)[2] 42 | n = dim(zres)[1] 43 | ures = matrix(NA, ncol = m, nrow = n) 44 | 45 | for(i in 1:m){ 46 | gdist = mflt@filter[[i]]@model$modeldesc$distribution 47 | lambda = ifelse(mflt@filter[[i]]@model$modelinc[18]>0, mflt@filter[[i]]@model$pars["ghlambda",1], 0) 48 | skew = ifelse(mflt@filter[[i]]@model$modelinc[16]>0, mflt@filter[[i]]@model$pars["skew",1], 0) 49 | shape = ifelse(mflt@filter[[i]]@model$modelinc[17]>0, mflt@filter[[i]]@model$pars["shape",1], 0) 50 | ures[,i] = pdist(gdist, zres[,i], mu = 0, sigma = 1, lambda = lambda, skew = skew, shape = shape) 51 | } 52 | return(ures) 53 | } 54 | 55 | .pempirical = function(zres) 56 | { 57 | m = dim(zres)[2] 58 | n = dim(zres)[1] 59 | ures = matrix(NA, ncol = m, nrow = n) 60 | for(i in 1:m){ 61 | fn = ecdf(sort(zres[,i])) 62 | ures[,i] = fn(zres[,i]) 63 | } 64 | return(ures) 65 | } 66 | 67 | 68 | .pempirical.filter = function(zres, dcc.old) 69 | { 70 | m = dim(zres)[2] 71 | n = dim(zres)[1] 72 | ures = matrix(NA, ncol = m, nrow = n) 73 | for(i in 1:m){ 74 | fn = ecdf(sort(zres[1:dcc.old,i])) 75 | ures[,i] = fn(zres[,i]) 76 | } 77 | return(ures) 78 | } 79 | 80 | 81 | .pspd = function(zres, spd.control) 82 | { 83 | m = dim(zres)[2] 84 | n = dim(zres)[1] 85 | ures = matrix(NA, ncol = m, nrow = n) 86 | sfit = vector(mode = "list", length = m) 87 | sfit = lapply(as.list(1:m), function(i) spdfit(zres[,i], upper = spd.control$upper, lower = spd.control$lower, 88 | tailfit = "GPD", type = spd.control$type, kernelfit = spd.control$kernel, information = "observed")) 89 | for(i in 1:m){ 90 | ures[,i] = pspd(zres[,i], sfit[[i]]) 91 | } 92 | return(list(ures = ures, sfit = sfit)) 93 | } 94 | 95 | .pspd.filter = function(zres, spd.control, dcc.old) 96 | { 97 | m = dim(zres)[2] 98 | n = dim(zres)[1] 99 | ures = matrix(NA, ncol = m, nrow = n) 100 | sfit = vector(mode = "list", length = m) 101 | sfit = lapply(as.list(1:m), function(i) spdfit(zres[1:dcc.old,i], upper = spd.control$upper, lower = spd.control$lower, 102 | tailfit = "GPD", type = spd.control$type, kernelfit = spd.control$kernel, information = "observed")) 103 | # temporarary workaround for problem with spd 104 | for(i in 1:m){ 105 | ures[,i] = pspd(zres[,i], sfit[[i]]) 106 | } 107 | 108 | return(list(ures = ures, sfit = sfit)) 109 | } 110 | 111 | 112 | #------------------------------------------------------------------------------------ 113 | .qparametric = function(ures, modelinc, pars) 114 | { 115 | m = dim(ures)[2] 116 | zres = matrix(NA, ncol = m, nrow = dim(ures)[1]) 117 | distn = c("norm", "snorm", "std", "sstd","ged", "sged", "nig", "ghyp", "jsu") 118 | for(i in 1:m){ 119 | gdist = distn[modelinc[21,i]] 120 | lambda = ifelse(modelinc[18,i]>0, pars["ghlambda",i], 0) 121 | skew = ifelse(modelinc[16,i]>0, pars["skew",i], 0) 122 | shape = ifelse(modelinc[17,i]>0, pars["shape",i], 0) 123 | zres[,i] = qdist(gdist, ures[,i], mu = 0, sigma = 1, lambda = lambda, skew = skew, shape = shape) 124 | } 125 | return(zres) 126 | } 127 | 128 | .qempirical = function(ures, oldz) 129 | { 130 | zres = matrix(NA, ncol = dim(ures)[2], nrow = dim(ures)[1]) 131 | for(i in 1:dim(ures)[2]){ 132 | zres[,i] = quantile(oldz[,i], ures[,i], type = 1) 133 | } 134 | return(zres) 135 | } 136 | 137 | .qspd = function(ures, sfit) 138 | { 139 | zres = matrix(NA, ncol = dim(ures)[2], nrow = dim(ures)[1]) 140 | for(i in 1:dim(ures)[2]){ 141 | zres[,i] = qspd(ures[,i], sfit[[i]]) 142 | } 143 | return(zres) 144 | } 145 | #------------------------------------------------------------------------------------ 146 | -------------------------------------------------------------------------------- /R/gogarch-classes.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | # GO-GARCH Model (Factor/BEKK Family) 19 | setClass("goGARCHspec", 20 | representation(model = "vector", 21 | umodel = "vector"), 22 | contains = "mGARCHspec") 23 | 24 | setClass("goGARCHfit", 25 | representation(mfit = "vector", 26 | model = "vector"), 27 | contains = "mGARCHfit") 28 | 29 | setClass("goGARCHfilter", 30 | representation(mfilter = "vector", 31 | model = "vector"), 32 | contains = "mGARCHfilter") 33 | 34 | setClass("goGARCHforecast", 35 | representation(mforecast = "vector", 36 | model = "vector"), 37 | contains = "mGARCHforecast") 38 | 39 | setClass("goGARCHsim", 40 | representation(msim = "vector", 41 | model = "vector"), 42 | contains = "mGARCHsim") 43 | 44 | setClass("goGARCHroll", 45 | representation(forecast = "vector", 46 | model = "vector"), 47 | contains = "mGARCHroll") 48 | 49 | setClass("goGARCHfft", 50 | representation(dist = "vector", model = "vector")) 51 | -------------------------------------------------------------------------------- /R/rdcc-classes.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | # Package Highest Level Virtual Class 19 | setClass("DCCspec", 20 | representation(model = "vector", umodel = "vector"), 21 | contains = "mGARCHspec") 22 | 23 | setClass("DCCfit", 24 | representation(mfit = "vector", 25 | model = "vector"), 26 | contains = "mGARCHfit") 27 | 28 | 29 | setClass("DCCfilter", 30 | representation(mfilter = "vector", 31 | model = "vector"), 32 | contains = "mGARCHfilter") 33 | 34 | setClass("DCCforecast", 35 | representation(mforecast = "vector", 36 | model = "vector"), 37 | contains = "mGARCHforecast") 38 | 39 | setClass("DCCsim", 40 | representation(msim = "vector", 41 | model = "vector"), 42 | contains = "mGARCHsim") 43 | 44 | setClass("DCCroll", 45 | representation(mforecast = "vector", 46 | model = "vector"), 47 | contains = "mGARCHroll") 48 | -------------------------------------------------------------------------------- /R/rdcc-mdistributions.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | 19 | .mDistributionBounds = function(distribution) 20 | { 21 | if (distribution == "mvnorm"){ 22 | skew = 0 23 | skew.LB = 0 24 | skew.UB = 0 25 | shape = 0 26 | shape.LB = 0 27 | shape.UB = 0} 28 | if (distribution == "mvt"){ 29 | skew = 0 30 | skew.LB = 0 31 | skew.UB = 10 32 | shape = 5 33 | shape.LB = 2.01 34 | shape.UB = 50} 35 | if (distribution == "mvlaplace"){ 36 | skew = 0 37 | skew.LB = 0 38 | skew.UB = 0 39 | shape = 1 40 | shape.LB = 0 41 | shape.UB = 100} 42 | 43 | skewed.dists = NULL 44 | shaped.dists = c("mvt", "mvlaplace") 45 | if(any(skewed.dists == distribution)) include.skew = TRUE else include.skew = FALSE 46 | if(any(shaped.dists == distribution)) include.shape = TRUE else include.shape = FALSE 47 | return(list(shape = shape, shape.LB = shape.LB, shape.UB = shape.UB, skew = skew, 48 | skew.LB = skew.LB, skew.UB = skew.UB, include.skew = include.skew, 49 | include.shape = include.shape)) 50 | } 51 | 52 | wmargin = function(distribution = "mvnorm", weights, mean, Sigma, shape = NA, skew = NA){ 53 | ans = switch(distribution, 54 | mvnorm = wmargin.mvn(weights, Sigma, mean), 55 | mvlaplace = wmargin.mvlaplace(weights, Sigma, mean), 56 | mvt = wmargin.mvt(weights, Sigma, mean, shape)) 57 | return( ans ) 58 | } 59 | wmargin.mvn = function(weights, cov, mu) 60 | { 61 | if( !is.array(cov) ) stop("\ncov must be an array") 62 | n = dim(cov)[3] 63 | m = dim(cov)[1] 64 | if( is.matrix( weights ) ){ 65 | mw = dim(weights)[2] 66 | if( mw != m ) stop("\nInconsistent weights and cov asset dimensions.") 67 | nw = dim(weights)[1] 68 | if( nw == 1 ) weights = matrix(weights, ncol = m, nrow = n, byrow = TRUE) 69 | if( nw != n ) stop("\nInconsistent weights and cov length.") 70 | } else{ 71 | mw = length(as.numeric(weights)) 72 | if( mw != m ) stop("\nInconsistent weights and cov asset dimensions.") 73 | weights = matrix( as.numeric(weights), nrow = n, ncol = m, byrow = TRUE) 74 | } 75 | 76 | if( is.matrix( mu ) ){ 77 | mw = dim(mu)[2] 78 | if( mw != m ) stop("\nInconsistent mu and cov asset dimensions.") 79 | nw = dim(mu)[1] 80 | if( nw == 1 ) mu = matrix(mu, ncol = m, nrow = n, byrow = TRUE) 81 | if( nw != n ) stop("\nInconsistent mu and cov length.") 82 | } else{ 83 | mw = length(as.numeric(mu)) 84 | if( mw != m ) stop("\nInconsistent mu and cov asset dimensions.") 85 | mu = matrix( as.numeric(mu), nrow = n, ncol = m, byrow = TRUE) 86 | } 87 | psigma = sqrt( apply(as.data.frame(1:n), 1, FUN = function(i) weights[i,] %*% cov[,,i] %*% weights[i,] ) ) 88 | pmu = rowSums(weights * mu) 89 | port = cbind(pmu, psigma, rep(0, n), rep(0, n)) 90 | colnames(port) = c("mu", "sigma", "skew", "shape") 91 | return( port ) 92 | } 93 | 94 | wmargin.mvlaplace = function(weights, cov, mu) 95 | { 96 | if( !is.array(cov) ) stop("\ncov must be an array") 97 | n = dim(cov)[3] 98 | m = dim(cov)[1] 99 | if( is.matrix( weights ) ){ 100 | mw = dim(weights)[2] 101 | if( mw != m ) stop("\nInconsistent weights and cov asset dimensions.") 102 | nw = dim(weights)[1] 103 | if( nw == 1 ) weights = matrix(weights, ncol = m, nrow = n, byrow = TRUE) 104 | if( nw != n ) stop("\nInconsistent weights and cov length.") 105 | } else{ 106 | mw = length(as.numeric(weights)) 107 | if( mw != m ) stop("\nInconsistent weights and cov asset dimensions.") 108 | weights = matrix( as.numeric(weights), nrow = n, ncol = m, byrow = TRUE) 109 | } 110 | 111 | if( is.matrix( mu ) ){ 112 | mw = dim(mu)[2] 113 | if( mw != m ) stop("\nInconsistent mu and cov asset dimensions.") 114 | nw = dim(mu)[1] 115 | if( nw == 1 ) mu = matrix(mu, ncol = m, nrow = n, byrow = TRUE) 116 | if( nw != n ) stop("\nInconsistent mu and cov length.") 117 | } else{ 118 | mw = length(as.numeric(mu)) 119 | if( mw != m ) stop("\nInconsistent mu and cov asset dimensions.") 120 | mu = matrix( as.numeric(mu), nrow = n, ncol = m, byrow = TRUE) 121 | } 122 | psigma = sqrt( apply(as.data.frame(1:n), 1, FUN = function(i) weights[i,] %*% cov[,,i] %*% weights[i,] ) ) 123 | pmu = rowSums(weights * mu) 124 | port = cbind(pmu, psigma, rep(0, n), rep(1, n)) 125 | colnames(port) = c("mu", "sigma", "skew", "shape") 126 | 127 | return( port ) 128 | } 129 | 130 | wmargin.mvt = function(weights, cov, mu, dof) 131 | { 132 | if( !is.array(cov) ) stop("\ncov must be an array") 133 | n = dim(cov)[3] 134 | m = dim(cov)[1] 135 | if( is.matrix( weights ) ){ 136 | mw = dim(weights)[2] 137 | if( mw != m ) stop("\nInconsistent weights and cov asset dimensions.") 138 | nw = dim(weights)[1] 139 | if( nw == 1 ) weights = matrix(weights, ncol = m, nrow = n, byrow = TRUE) 140 | if( nw != n ) stop("\nInconsistent weights and cov length.") 141 | } else{ 142 | mw = length(as.numeric(weights)) 143 | if( mw != m ) stop("\nInconsistent weights and cov asset dimensions.") 144 | weights = matrix( as.numeric(weights), nrow = n, ncol = m, byrow = TRUE) 145 | } 146 | 147 | if( is.matrix( mu ) ){ 148 | mw = dim(mu)[2] 149 | if( mw != m ) stop("\nInconsistent mu and cov asset dimensions.") 150 | nw = dim(mu)[1] 151 | if( nw == 1 ) mu = matrix(mu, ncol = m, nrow = n, byrow = TRUE) 152 | if( nw != n ) stop("\nInconsistent mu and cov length.") 153 | } else{ 154 | mw = length(as.numeric(mu)) 155 | if( mw != m ) stop("\nInconsistent mu and cov asset dimensions.") 156 | mu = matrix( as.numeric(mu), nrow = n, ncol = m, byrow = TRUE) 157 | } 158 | psigma = sqrt( apply(as.data.frame(1:n), 1, FUN = function(i) weights[i,] %*% cov[,,i] %*% weights[i,] ) ) 159 | pmu = rowSums(weights * mu) 160 | port = cbind(pmu, psigma, rep(0, n), rep(dof, n) ) 161 | colnames(port) = c("mu", "sigma", "skew", "shape") 162 | return( port ) 163 | } 164 | # use: mnormt 165 | # 166 | dmdist = function(distribution = "mvnorm", y, mu, sigma, lambda = -0.5, skew, shape) 167 | { 168 | valid.distributions = c("mvnorm", "mvt", "mvlaplace", "mvnig", "mvghyp") 169 | if (!any(valid.distributions == distribution)) stop("\nnot a valid distributions\n", call. = FALSE) 170 | 171 | } 172 | 173 | pmdist = function(distribution = "mvnorm", y, mu, sigma, lambda = -0.5, skew, shape) 174 | { 175 | valid.distributions = c("mvnorm", "mvt", "mvlaplace", "mvnig", "mvghyp") 176 | if (!any(valid.distributions == distribution)) stop("\nnot a valid distributions\n", call. = FALSE) 177 | 178 | } 179 | 180 | qmdist = function(distribution = "mvnorm", y, mu, sigma, lambda = -0.5, skew, shape) 181 | { 182 | valid.distributions = c("mvnorm", "mvt", "mvlaplace", "mvnig", "mvghyp") 183 | if (!any(valid.distributions == distribution)) stop("\nnot a valid distributions\n", call. = FALSE) 184 | 185 | } 186 | 187 | rmdist = function(distribution = "mvnorm", y, mu, sigma, lambda = -0.5, skew, shape) 188 | { 189 | valid.distributions = c("mvnorm", "mvt", "mvlaplace", "mvnig", "mvghyp") 190 | if (!any(valid.distributions == distribution)) stop("\nnot a valid distributions\n", call. = FALSE) 191 | 192 | } 193 | -------------------------------------------------------------------------------- /R/rmgarch-classes.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | 19 | ################################################################################### 20 | #---------------------------------------------------------------------------------- 21 | # Multivariate Class Models 22 | #---------------------------------------------------------------------------------- 23 | setClass("mGARCHspec", contains = c("GARCHspec")) 24 | setClass("mGARCHfit", contains = c("GARCHfit")) 25 | setClass("mGARCHfilter", contains = c("GARCHfilter")) 26 | setClass("mGARCHforecast", contains = c("GARCHforecast")) 27 | setClass("mGARCHsim", contains = c("GARCHsim")) 28 | setClass("mGARCHroll", contains = c("GARCHroll")) 29 | #---------------------------------------------------------------------------------- 30 | 31 | fScenario.default = function(){ 32 | xmodel = list(asset.names = "", 33 | assets = 0, 34 | model = "dcc", 35 | sim = 1, 36 | roll = 0, 37 | save.output = TRUE, 38 | save.dir = "", 39 | save.name = "") 40 | return(list(scenario = list(), model = xmodel)) 41 | } 42 | 43 | fMoments.default = function(){ 44 | xmodel = list(asset.names = "", 45 | assets = 0, 46 | model = "dcc", 47 | n.ahead = 1, 48 | roll = 0, 49 | save.output = TRUE, 50 | save.dir = "", 51 | save.name = "") 52 | return(list(moments = list(), model = xmodel)) 53 | } 54 | 55 | 56 | setClass("fScenario", 57 | representation( 58 | scenario = "vector", 59 | model = "vector"), 60 | prototype = fScenario.default()) 61 | 62 | setClass("fMoments", 63 | representation( 64 | moments = "vector", 65 | model = "vector"), 66 | prototype = fMoments.default()) 67 | -------------------------------------------------------------------------------- /R/rmgarch-extrafun.R: -------------------------------------------------------------------------------- 1 | .information.test <- function(LLH, nObs, nPars) 2 | { 3 | AIC = (-2 * LLH)/nObs + 2 * nPars/nObs 4 | BIC = (-2 * LLH)/nObs + nPars * log(nObs)/nObs 5 | SIC = (-2 * LLH)/nObs + log((nObs + 2 * nPars)/nObs) 6 | HQIC = (-2 * LLH)/nObs + (2 * nPars * log(log(nObs)))/nObs 7 | informationTests = list(AIC = AIC, BIC = BIC, SIC = SIC, 8 | HQIC = HQIC) 9 | return(informationTests) 10 | } -------------------------------------------------------------------------------- /R/rmgarch-functions.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | #--------------------------------------------------------------------------------- 18 | # Locally imported copy of "klin.eval" from the klin package 19 | incseq = function (a, b) 20 | { 21 | seq(a, b, length = max(0, b - a + 1)) 22 | } 23 | 24 | .klin.eval = function (A, x, transpose = FALSE) 25 | { 26 | m <- sapply(A, nrow) 27 | n <- sapply(A, ncol) 28 | K <- length(A) 29 | if (K == 0) return(x) 30 | if(transpose) { 31 | tmp <- m 32 | m <- n 33 | n <- tmp 34 | } 35 | X <- x 36 | for(k in K:1) { 37 | X <- Matrix(as.vector(X), n[k], prod(c(n[incseq(1, k - 1)], m[incseq(k + 1, K)]))) 38 | if(transpose) Y <- Matrix::crossprod(A[[k]], X) else Y <- A[[k]] %*% X 39 | X <- Matrix::t(Y) 40 | } 41 | return(as.vector(X)) 42 | } 43 | #--------------------------------------------------------------------------------- 44 | fast_kron_M = function(rhs, lhs, n, p=3) 45 | { 46 | Y = lapply(1:n, function(i){.klin.eval(rhs, lhs[i,], transpose = TRUE)}) 47 | M = matrix(unlist(Y), nrow = n, ncol = n^p, byrow=TRUE) 48 | return(M) 49 | } 50 | 51 | .kappaGH <-function(x, lambda = 1) 52 | { 53 | stopifnot(x >= 0) 54 | stopifnot(length(lambda) == 1) 55 | if (lambda == -0.5) { 56 | # NIG: 57 | kappa = 1/x 58 | } else { 59 | # GH: 60 | kappa = ( 61 | besselK(x, lambda+1, expon.scaled = TRUE) / 62 | besselK(x, lambda, expon.scaled = TRUE) ) / x 63 | } 64 | return(kappa) 65 | } 66 | # ------------------------------------------------------------------------------ 67 | .deltaKappaGH<-function(x, lambda = 1) 68 | { 69 | if (lambda == -0.5) { 70 | deltaKappa = .kappaGH(x, lambda+1) - .kappaGH(x, lambda) 71 | } else { 72 | deltaKappa = .kappaGH(x, lambda+1) - .kappaGH(x, lambda) 73 | } 74 | return(deltaKappa) 75 | } 76 | # ------------------------------------------------------------------------------ 77 | .paramGH = function(rho = 0 , zeta = 1, lambda = 1) 78 | { 79 | # A function implemented by Diethelm Wuertz 80 | # Change parameterizations to alpha(zeta, rho, lambda) 81 | Rho2 = 1 - rho^2 82 | alpha = zeta^2 * .kappaGH(zeta, lambda) / Rho2 83 | alpha = alpha * ( 1 + rho^2 * zeta^2 * .deltaKappaGH(zeta, lambda) / Rho2) 84 | alpha = sqrt(alpha) 85 | beta = alpha * rho 86 | delta = zeta / ( alpha * sqrt(Rho2) ) 87 | mu = -beta * delta^2 * .kappaGH(zeta, lambda) 88 | c(alpha = alpha, beta = beta, delta = delta, mu = mu) 89 | } 90 | .nigtransform = function(zeta, rho) 91 | { 92 | nigpars = t(apply(cbind(rho, zeta), 1, FUN = function(x) .paramGH(rho = x[1], zeta = x[2], lambda = -0.5))) 93 | colnames(nigpars) = c("alpha", "beta", "delta", "mu") 94 | return(nigpars) 95 | } 96 | 97 | .ghyptransform = function(zeta, rho, lambda) 98 | { 99 | n = length(zeta) 100 | ghyppars = t(apply(cbind(rho, zeta), 1, FUN = function(x) .paramGH(rho = x[1], zeta = x[2], lambda = lambda))) 101 | ghyppars = cbind(ghyppars, rep(lambda, n)) 102 | colnames(ghyppars) = c("alpha", "beta", "delta", "mu", "lambda") 103 | return(ghyppars) 104 | } 105 | .nigscale2 = function(mu, sigma, nigalpha, nigbeta, nigdelta, nigmu) 106 | { 107 | xdensity = matrix(0, ncol = 4, nrow = length(sigma)) 108 | # alpha, beta, delta, mu [alpha = shape, beta = skew] 109 | xdensity[,1] = nigalpha/sigma 110 | xdensity[,2] = nigbeta/sigma 111 | xdensity[,3] = nigdelta*sigma 112 | xdensity[,4] = nigmu*sigma + mu 113 | colnames(xdensity) = c("alpha", "beta", "delta", "mu") 114 | return(xdensity) 115 | } 116 | .nigscale = function(mu, sigma, skew, shape) 117 | { 118 | nigpars = t(apply(cbind(skew, shape), 1, FUN=function(x) .paramGH(rho = x[1], zeta = x[2], lambda = -0.5))) 119 | xdensity = matrix(0, ncol = 4, nrow = length(sigma)) 120 | # alpha, beta, delta, mu 121 | xdensity[,4] = nigpars[,1]/sigma 122 | xdensity[,3] = nigpars[,2]/sigma 123 | xdensity[,2] = nigpars[,3]*sigma 124 | xdensity[,1] = nigpars[,4]*sigma + mu 125 | colnames(xdensity) = c("mu", "sigma", "skew", "shape") 126 | return(xdensity) 127 | } 128 | 129 | .ghypscale = function(mu, sigma, skew, shape, lambda) 130 | { 131 | ghpars = t(apply(cbind(skew, shape), 1, FUN=function(x) .paramGH(rho = x[1], zeta = x[2], lambda = lambda))) 132 | xdensity = matrix(0, ncol = 4, nrow = length(sigma)) 133 | # alpha, beta, delta, mu 134 | xdensity[,4] = ghpars[,1]/sigma 135 | xdensity[,3] = ghpars[,2]/sigma 136 | xdensity[,2] = ghpars[,3]*sigma 137 | xdensity[,1] = ghpars[,4]*sigma + mu 138 | colnames(xdensity) =c("mu", "sigma", "skew", "shape") 139 | return(xdensity) 140 | } 141 | 142 | .ghypscale2 = function(mu, sigma, ghalpha, ghbeta, ghdelta, ghmu) 143 | { 144 | xdensity = matrix(0, ncol = 4, nrow = length(sigma)) 145 | # alpha, beta, delta, mu 146 | xdensity[,1] = ghalpha/sigma 147 | xdensity[,2] = ghbeta/sigma 148 | xdensity[,3] = ghdelta*sigma 149 | xdensity[,4] = ghmu*sigma + mu 150 | colnames(xdensity) = c("alpha", "beta", "delta", "mu") 151 | return(xdensity) 152 | } 153 | 154 | 155 | .normscale = function(mu, sigma) 156 | { 157 | xdensity = matrix(0, ncol = 4, nrow = length(sigma)) 158 | xdensity[,1] = mu 159 | xdensity[,2] = sigma 160 | xdensity[,3] = 0 161 | xdensity[,4] = 0 162 | 163 | colnames(xdensity) = c("mu", "sigma", "skew", "shape") 164 | return(xdensity) 165 | } 166 | 167 | # ------------------------------------------------------------------------------ 168 | # New functions to convert rcor and rvov into matrices 169 | sm2vec<-function(m, diag = FALSE) 170 | { 171 | return(as.vector(m[lower.tri(m, diag)])) 172 | } 173 | make.cov.names = function(xnames) 174 | { 175 | n = length(xnames) 176 | x = matrix(NA, n,n) 177 | diag(x)=xnames 178 | colnames(x)=xnames 179 | rownames(x)=xnames 180 | for(i in 1:n){ 181 | for(j in 1:n){ 182 | if(i==j) next() 183 | x[i,j] = paste0(xnames[i],":",xnames[j]) 184 | } 185 | } 186 | return(x) 187 | } 188 | array2matrix = function(x, date=NULL, var.names=NULL, diag=FALSE) 189 | { 190 | R = do.call(rbind, lapply(1:dim(x)[3], function(i){ 191 | sm2vec(x[,,i], diag = diag ) 192 | }),quote=TRUE) 193 | if(!is.null(date) & is(date[1],"Date")){ 194 | R = xts(R, as.Date(date)) 195 | } else if(!is.null(date) & is.character(date[1])){ 196 | rownames(R) = as.character(date) 197 | } 198 | if(!is.null(var.names)){ 199 | vech.names=sm2vec(make.cov.names(var.names), diag = diag) 200 | colnames(R) = vech.names 201 | } 202 | return(R) 203 | } 204 | -------------------------------------------------------------------------------- /R/rmgarch-tests.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022. 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | # DCC Test of Engle and Sheppard (using a CCC-Normal Copula rather than a CCC-Normal) 19 | ################################################################################ 20 | DCCtest = function(Data, garchOrder = c(1,1), n.lags = 1, solver = "solnp", 21 | solver.control = list(), cluster = NULL, Z = NULL) 22 | { 23 | if(is.null(Z)){ 24 | Data = as.matrix(Data) 25 | n = dim(Data)[1] 26 | m = dim(Data)[2] 27 | uspec = ugarchspec(mean.model = list(armaOrder=c(0,0), include.mean = TRUE)) 28 | mspec = multispec(replicate(m, uspec)) 29 | cspec = cgarchspec(mspec, distribution.model = list(copula = "mvnorm", 30 | transformation = "parametric", method = "Kendall")) 31 | cfit = cgarchfit(cspec, Data, fit.control = list(eval.se = FALSE, trace = FALSE), 32 | cluster = cluster, solver = solver, solver.control = solver.control) 33 | Z = cfit@mfit$stdresid 34 | } else{ 35 | n = dim(Z)[1] 36 | m = dim(Z)[2] 37 | } 38 | OP = NULL 39 | for(i in 1:m){ 40 | if(i= 2.8.0 passes package metadata to citation(). 4 | if(!exists("meta") || is.null(meta)) meta <- packageDescription("rmgarch") 5 | 6 | year <- sub("-.*", "", meta$Date) 7 | note <- sprintf("R package version %s.", meta$Version) 8 | 9 | citEntry(entry="Manual", 10 | title = "rmgarch: Multivariate GARCH models.", 11 | author = personList(as.person("Alexios Galanos")), 12 | year = year, 13 | note = note, 14 | textVersion = 15 | paste("Alexios Galanos", 16 | sprintf("(%s).", year), 17 | "rmgarch: Multivariate GARCH models.", 18 | note), 19 | header = "To cite the rmgarch package, please use:" 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /inst/COPYRIGHTS: -------------------------------------------------------------------------------- 1 | COPYRIGHT STATUS 2 | ---------------- 3 | 4 | This code is 5 | 6 | Copyright (C) 2008-2021 by Alexios Galanos. 7 | 8 | All code is subject to the GNU General Public License, Version 3. See 9 | the file COPYING for the exact conditions under which you may 10 | redistribute it. 11 | -------------------------------------------------------------------------------- /inst/doc/The_rmgarch_models.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/rmgarch/2699f032d3811d4f539deb90aac589f5823ebdb4/inst/doc/The_rmgarch_models.pdf -------------------------------------------------------------------------------- /inst/rmgarch.tests/rmgarch.test6.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Ghalanos Copyright (C) 2008-2022 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | 18 | # DCC Beta Model 19 | 20 | rmgarch.test6a = function(cluster = NULL) 21 | { 22 | # DCC under different specifications 23 | tic = Sys.time() 24 | require(xts) 25 | data(dji30retw) 26 | dji30retw = xts(coredata(dji30retw), as.Date(rownames(dji30retw))) 27 | benchmark = xts(rowMeans(dji30retw), index(dji30retw)) 28 | Z = na.omit(cbind(benchmark, lag(dji30retw[, 1:15]))) 29 | uspec = replicate(16, ugarchspec(mean.model=list(armaOrder=c(0,0)), variance.model=list(model = "gjrGARCH",variance.targeting=FALSE))) 30 | B1<-betaDCCFilter(y=Z[,1], x=Z[,-1], uspec, use.n = 1, fit=NULL, only.betas=FALSE) 31 | gspec<- gogarchspec( 32 | mean.model = list(model = c("constant", "AR", "VAR")[1]), 33 | variance.model = list(model = "gjrGARCH", garchOrder = c(1,1), submodel = NULL, variance.targeting = FALSE), 34 | distribution.model = c("mvnorm", "manig", "magh")[1], ica = c("fastica", "radical")[2]) 35 | B2<-betaGOGARCHFilter(y=Z[,1], x=Z[,-1], gspec, use.n = 1, fit=NULL, only.betas=FALSE, maxiter1=15000) 36 | 37 | plot(B1$betas[,1]) 38 | lines(B2$betas[,1], col=2) 39 | 40 | plot(B1$betas[,2]) 41 | lines(B2$betas[,2], col=2) 42 | 43 | plot(B1$betas[,3]) 44 | lines(B2$betas[,3], col=2) 45 | 46 | plot(B1$betas[,4]) 47 | lines(B2$betas[,4], col=2) 48 | 49 | caret:::RMSE(B1$fitted, Z[,1]) 50 | caret:::RMSE(B2$fitted, Z[,1]) 51 | 52 | toc = Sys.time()-tic 53 | cat("Elapsed:", toc, "\n") 54 | return(toc) 55 | } 56 | -------------------------------------------------------------------------------- /inst/rmgarch.tests/runtests.R: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2008-2022 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ################################################################################# 17 | .testattr = function(test = 1, subtest = "a"){ 18 | 19 | if(is.na(match(test, 1:9))) stop("\nInvalid test number (valid range is 1:9)") 20 | alp = c("a", "b", "c", "d", "e", "f", "g", "h", "i") 21 | zt = match(subtest, alp) 22 | if(is.na(zt)) stop("\nInvalid subtest number (valid range is a:i)") 23 | 24 | testdesc = vector(mode = "list", length = 3) 25 | 26 | testdesc[[1]][1] = "GOGARCH: Fit Tests" 27 | testdesc[[1]][2] = "GOGARCH: Mean Spec Tests" 28 | testdesc[[1]][3] = "GOGARCH: ICA Tests" 29 | testdesc[[1]][4] = "GOGARCH: Filter Tests" 30 | testdesc[[1]][5] = "GOGARCH: Methods Tests I" 31 | testdesc[[1]][6] = "GOGARCH: Methods Tests II" 32 | testdesc[[1]][7] = "GOGARCH: Forecast Tests" 33 | testdesc[[1]][8] = "GOGARCH: Rolling Forecast Tests" 34 | testdesc[[1]][9] = "GOGARCH: Moment Tests" 35 | 36 | testdesc[[2]][1] = "DCC: Fit Tests" 37 | testdesc[[2]][2] = "DCC: Alternative Distribution Tests" 38 | testdesc[[2]][3] = "DCC: VAR-DCC Test" 39 | testdesc[[2]][4] = "DCC: Filter Tests" 40 | testdesc[[2]][5] = "DCC: Simulation Tests" 41 | testdesc[[2]][6] = "DCC: Forecast Tests" 42 | testdesc[[2]][7] = "DCC: Rolling Forecast Tests" 43 | 44 | testdesc[[3]][1] = "CGARCH: Fit and Filtering Tests" 45 | testdesc[[3]][2] = "CGARCH: Static Copula" 46 | testdesc[[3]][3] = "CGARCH: Filtering and Out-of-Sample Tests" 47 | testdesc[[3]][4] = "CGARCH: Static Copula Simulation Tests" 48 | testdesc[[3]][5] = "CGARCH: Dynamic Copula Simulation (Parametric) Tests" 49 | testdesc[[3]][6] = "CGARCH: Dynamic Copula Simulation (SPD) Tests" 50 | testdesc[[3]][7] = "CGARCH: Dynamic Copula Simulation (Empirical) Tests" 51 | 52 | 53 | if(is.na(testdesc[[test]][zt])) stop(paste("\nInvalid subtest number (valid range is a:", alp[length(testdesc[[test]])], ")", sep="")) 54 | ans = paste(testdesc[[test]][zt], sep = "") 55 | return(ans) 56 | } 57 | 58 | rmgarch.runtests = function(test = 1, subtest = "a", wdir = getwd(), parallel = FALSE, 59 | parallel.control = list(pkg = c("snowfall", "multicore"), cores = 2)) 60 | { 61 | tmp = try(setwd(wdir), silent = TRUE) 62 | if(inherits(tmp, "try-error")) stop("\nInvalid wdir...") 63 | tat = .testattr(test, subtest) 64 | cat("\n") 65 | cat(tat) 66 | cat("\n") 67 | tstname = paste("rmgarch.test", test, subtest,"(parallel =", parallel,", parallel.control=list(pkg='", parallel.control$pkg,"', cores = ", 68 | parallel.control$cores,"))", sep="") 69 | ans = eval(parse(text=tstname)) 70 | return(ans) 71 | } 72 | -------------------------------------------------------------------------------- /man/DCCfilter-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCfilter-class} 2 | \docType{class} 3 | \alias{DCCfilter-class} 4 | \alias{coef,DCCfilter-method} 5 | \alias{fitted,DCCfilter-method} 6 | \alias{sigma,DCCfilter-method} 7 | \alias{likelihood,DCCfilter-method} 8 | \alias{nisurface,DCCfilter-method} 9 | \alias{plot,DCCfilter,missing-method} 10 | \alias{rcor,DCCfilter-method} 11 | \alias{rcov,DCCfilter-method} 12 | \alias{residuals,DCCfilter-method} 13 | \alias{rshape,DCCfilter-method} 14 | \alias{rskew,DCCfilter-method} 15 | \alias{show,DCCfilter-method} 16 | \title{class: DCC Filter Class} 17 | \description{ 18 | The class is returned by calling the function \code{\link{dccfilter}}. 19 | } 20 | \section{Slots}{ 21 | \describe{ 22 | \item{\code{mfilter}:}{Object of class \code{"vector"}. Multivariate filter 23 | list.} 24 | \item{\code{model}:}{Object of class \code{"vector"}. Model specification 25 | list.} 26 | } 27 | } 28 | \section{Extends}{ 29 | Class \code{"\linkS4class{mGARCHfilter}"}, directly. 30 | Class \code{"\linkS4class{GARCHfilter}"}, by class "mGARCHfilter", distance 2. 31 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHfilter", distance 3. 32 | } 33 | \section{Methods}{ 34 | \describe{ 35 | \item{coef}{\code{signature(object = "DCCfilter")} 36 | The coefficient vector (see note). } 37 | \item{likelihood}{\code{signature(object = "DCCfilter")}: 38 | The joint likelihood. } 39 | \item{rshape}{\code{signature(object = "DCCfilter")}: 40 | The multivariate distribution shape parameter(s).} 41 | \item{rskew}{\code{signature(object = "DCCfilter")}: 42 | The multivariate distribution skew parameter(s). } 43 | \item{fitted}{\code{signature(object = "DCCfilter")}: 44 | The filtered conditional mean xts object. } 45 | \item{sigma}{\code{signature(object = "DCCfilter")}: 46 | The filtered conditional sigma xts object. } 47 | \item{residuals}{\code{signature(object = "DCCfilter")}: 48 | The filtered conditional mean residuals xts object. } 49 | \item{plot}{\code{signature(x = "DCCfilter", y = "missing")}: 50 | Plot method, given additional arguments \sQuote{series} and \sQuote{which}.} 51 | \item{infocriteria}{\code{signature(object = "DCCfilter")}: 52 | Information criteria. } 53 | \item{rcor}{\code{signature(object = "DCCfilter")}: 54 | The filtered dynamic conditional correlation array given additional 55 | argument \sQuote{type} (either \dQuote{R} for the 56 | correlation else will return the \dQuote{Q} matrix). The third dimension 57 | label of the array gives the time index (from which it is then possible to 58 | construct pairwise xts objects for example). A further argument \sQuote{output} 59 | allows to switch between \dQuote{array} and \dQuote{matrix} returned object.} 60 | \item{rcov}{\code{signature(object = "DCCfilter")}: 61 | The filtered dynamic conditional covariance array. The third dimension 62 | label of the array gives the time index (from which it is then possible to 63 | construct pairwise xts objects for example). A further argument \sQuote{output} 64 | allows to switch between \dQuote{array} and \dQuote{matrix} returned object.} 65 | \item{show}{\code{signature(object = "DCCfilter")}: 66 | Summary. } 67 | \item{nisurface}{\code{signature(object = "DCCfilter")}: 68 | The news impact surface plot given additional arguments \sQuote{type} with 69 | either \dQuote{cov} or \dQuote{cor} (for the covariance and correlation news 70 | impact respectively), \sQuote{pair} denoting the asset pair (defaults to 71 | c(1,2)), \sQuote{plot} (logical) and \sQuote{plot.type} with a choice of 72 | either \dQuote{surface} or \dQuote{contour}. } 73 | } 74 | } 75 | \references{ 76 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 77 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 78 | } 79 | \note{ 80 | The \sQuote{coef} method takes additional argument \sQuote{type} with valid 81 | values \sQuote{garch} for the univariate garch parameters, \sQuote{dcc} for the 82 | second stage dcc parameters and by default returns all the parameters in a named 83 | vector. 84 | } 85 | \author{Alexios Galanos} 86 | \keyword{classes} 87 | -------------------------------------------------------------------------------- /man/DCCfit-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCfit-class} 2 | \docType{class} 3 | \alias{DCCfit-class} 4 | \alias{coef,DCCfit-method} 5 | \alias{fitted,DCCfit-method} 6 | \alias{sigma,DCCfit-method} 7 | \alias{infocriteria,DCCfit-method} 8 | \alias{likelihood,DCCfit-method} 9 | \alias{nisurface,DCCfit-method} 10 | \alias{plot,DCCfit,missing-method} 11 | \alias{rcor,DCCfit-method} 12 | \alias{rcov,DCCfit-method} 13 | \alias{residuals,DCCfit-method} 14 | \alias{rshape,DCCfit-method} 15 | \alias{rshape} 16 | \alias{rskew,DCCfit-method} 17 | \alias{rskew} 18 | \alias{show,DCCfit-method} 19 | \title{class: DCC Fit Class} 20 | \description{ 21 | The class is returned by calling the function \code{\link{dccfit}}. 22 | } 23 | \section{Slots}{ 24 | \describe{ 25 | \item{\code{mfit}:}{Object of class \code{"vector"} Multivariate filter 26 | list.} 27 | \item{\code{model}:}{Object of class \code{"vector"} Model specification 28 | list. } 29 | } 30 | } 31 | \section{Extends}{ 32 | Class \code{"\linkS4class{mGARCHfit}"}, directly. 33 | Class \code{"\linkS4class{GARCHfit}"}, by class "mGARCHfit", distance 2. 34 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHfit", distance 3. 35 | } 36 | \section{Methods}{ 37 | \describe{ 38 | \item{coef}{\code{signature(object = "DCCfit")} 39 | The coefficient vector (see note). } 40 | \item{likelihood}{\code{signature(object = "DCCfit")}: 41 | The joint likelihood. } 42 | \item{rshape}{\code{signature(object = "DCCfit")}: 43 | The multivariate distribution shape parameter(s).} 44 | \item{rskew}{\code{signature(object = "DCCfit")}: 45 | The multivariate distribution skew parameter(s). } 46 | \item{fitted}{\code{signature(object = "DCCfit")}: 47 | The fitted conditional mean xts object. } 48 | \item{sigma}{\code{signature(object = "DCCfit")}: 49 | The fitted conditional GARCH sigma xts object. } 50 | \item{residuals}{\code{signature(object = "DCCfit")}: 51 | The fitted conditional mean residuals xts object. } 52 | \item{plot}{\code{signature(x = "DCCfit", y = "missing")}: 53 | Plot method, given additional arguments \sQuote{series} and \sQuote{which}.} 54 | \item{infocriteria}{\code{signature(object = "DCCfit")}: 55 | Information criteria. } 56 | \item{rcor}{\code{signature(object = "DCCfit")}: 57 | The fitted dynamic conditional correlation array given additional 58 | arguments \sQuote{type} (either \dQuote{R} for the 59 | correlation else will return the Q matrix). The third dimension label of the 60 | array gives the time index (from which it is then possible to construct 61 | pairwise xts objects for example). The argument \sQuote{output} can be either 62 | \dQuote{array} (default) or \dQuote{matrix} in which case the array is flattened 63 | and the lower diagonal time varying values are returned (and if a date exists, 64 | then the returned object is of class xts). 65 | } 66 | \item{rcov}{\code{signature(object = "DCCfit")}: 67 | The fitted dynamic conditional covariance array. The third dimension label 68 | of the array gives the time index (from which it is then possible to 69 | construct pairwise xts objects for example). The argument \sQuote{output} can be either 70 | \dQuote{array} (default) or \dQuote{matrix} in which case the array is flattened 71 | and the lower and main diagonal time varying values are returned (and if a date exists, 72 | then the returned object is of class xts). 73 | } 74 | \item{show}{\code{signature(object = "DCCfit")}: 75 | Summary. } 76 | \item{nisurface}{\code{signature(object = "DCCfit")}: 77 | The news impact surface plot given additional arguments \sQuote{type} with 78 | either \dQuote{cov} or \dQuote{cor} (for the covariance and correlation news 79 | impact respectively), \sQuote{pair} (defaults to c(1,2)), \sQuote{plot} 80 | (logical) and \sQuote{plot.type} with a choice of either \dQuote{surface} or 81 | \dQuote{contour}. } 82 | } 83 | } 84 | \references{ 85 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 86 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 87 | } 88 | \author{Alexios Galanos} 89 | \note{ 90 | The \sQuote{coef} method takes additional argument \sQuote{type} with valid 91 | values \sQuote{garch} for the univariate garch parameters, \sQuote{dcc} for the 92 | second stage dcc parameters and by default returns all the parameters in a named 93 | vector. 94 | } 95 | \keyword{classes} 96 | -------------------------------------------------------------------------------- /man/DCCforecast-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCforecast-class} 2 | \docType{class} 3 | \alias{DCCforecast-class} 4 | \alias{fitted,DCCforecast-method} 5 | \alias{sigma,DCCforecast-method} 6 | \alias{rcor,DCCforecast-method} 7 | \alias{rcov,DCCforecast-method} 8 | \alias{rshape,DCCforecast-method} 9 | \alias{rskew,DCCforecast-method} 10 | \alias{show,DCCforecast-method} 11 | \alias{plot,DCCforecast,missing-method} 12 | \title{class: DCC Forecast Class} 13 | \description{ 14 | The class is returned by calling the function \code{\link{dccforecast}}. 15 | } 16 | \section{Slots}{ 17 | \describe{ 18 | \item{\code{mforecast}:}{Object of class \code{"vector"} Multivariate 19 | forecast list.} 20 | \item{\code{model}:}{Object of class \code{"vector"} Model specification 21 | list.} 22 | } 23 | } 24 | \section{Extends}{ 25 | Class \code{"\linkS4class{mGARCHforecast}"}, directly. 26 | Class \code{"\linkS4class{GARCHforecast}"}, by class "mGARCHforecast", distance 2. 27 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHforecast", distance 3. 28 | } 29 | 30 | \section{Methods}{ 31 | \describe{ 32 | \item{rshape}{\code{signature(object = "DCCforecast")}: 33 | The multivariate distribution shape parameter(s).} 34 | \item{rskew}{\code{signature(object = "DCCforecast")}: 35 | The multivariate distribution skew parameter(s). } 36 | \item{fitted}{\code{signature(object = "DCCforecast")}: 37 | The conditional mean forecast array of dimensions n.ahead x n.assets 38 | by (n.roll+1). The thirds dimension of the array has the T+0 index label.} 39 | \item{sigma}{\code{signature(object = "DCCforecast")}: 40 | The conditional sigma forecast array of dimensions n.ahead x n.assets 41 | by (n.roll+1). The thirds dimension of the array has the T+0 index label.} 42 | \item{plot}{\code{signature(x = "DCCforecast", y = "missing")}: 43 | Plot method, given additional arguments \sQuote{series} and \sQuote{which}.} 44 | \item{rcor}{\code{signature(object = "DCCforecast")}: 45 | The forecast dynamic conditional correlation list of arrays of length 46 | (n.roll+1), with each array of dimensions n.assets x n.assets x n.ahead. 47 | The method takes on one additional argument \sQuote{type} (either \dQuote{R} 48 | for the correlation else will return the DCC Q matrix). A further argument 49 | \sQuote{output} allows to switch between \dQuote{array} 50 | and \dQuote{matrix} returned object. 51 | } 52 | \item{rcov}{\code{signature(object = "DCCforecast")}: 53 | The forecast dynamic conditional correlation list of arrays of length 54 | (n.roll+1), with each array of dimensions n.assets x n.assets x n.ahead. 55 | A further argument \sQuote{output} allows to switch between \dQuote{array} 56 | and \dQuote{matrix} returned object. 57 | } 58 | \item{show}{\code{signature(object = "DCCforecast")}: 59 | Summary. } 60 | } 61 | } 62 | \references{ 63 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 64 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 65 | } 66 | \author{Alexios Galanos} 67 | \keyword{classes} 68 | -------------------------------------------------------------------------------- /man/DCCroll-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCroll-class} 2 | \docType{class} 3 | \alias{DCCroll-class} 4 | \alias{coef,DCCroll-method} 5 | \alias{fitted,DCCroll-method} 6 | \alias{likelihood,DCCroll-method} 7 | \alias{plot,DCCroll,missing-method} 8 | \alias{rcor,DCCroll-method} 9 | \alias{rcov,DCCroll-method} 10 | \alias{rshape,DCCroll-method} 11 | \alias{rskew,DCCroll-method} 12 | \alias{show,DCCroll-method} 13 | \alias{sigma,DCCroll-method} 14 | 15 | \title{class: DCC Roll Class} 16 | \description{ 17 | The class is returned by calling the function \code{\link{dccroll}}. 18 | } 19 | \section{Slots}{ 20 | \describe{ 21 | \item{\code{mforecast}:}{Object of class \code{"vector"} Multivariate 22 | forecast list.} 23 | \item{\code{model}:}{Object of class \code{"vector"} Model specification 24 | list.} 25 | } 26 | } 27 | \section{Extends}{ 28 | Class \code{"\linkS4class{mGARCHroll}"}, directly. 29 | Class \code{"\linkS4class{GARCHroll}"}, by class "mGARCHroll", distance 2. 30 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHroll", distance 3. 31 | } 32 | \section{Methods}{ 33 | \describe{ 34 | \item{coef}{\code{signature(object = "DCCroll")}: 35 | The coefficient array across the rolling estimations with a T+0 36 | 3rd dimension index label.} 37 | \item{fitted}{\code{signature(object = "DCCroll")}: 38 | The conditional mean forecast xts object (with the actual T+i forecast 39 | dates as index).} 40 | \item{likelihood}{\code{signature(object = "DCCroll")}: 41 | The log-likelihood across rolling estimations.} 42 | \item{plot}{\code{signature(x = "DCCroll", y = "missing")}: 43 | Plot method, given additional arguments \sQuote{series} and \sQuote{which}.} 44 | \item{rcor}{\code{signature(object = "DCCroll")}: 45 | The forecast dynamic conditional correlation array, with the T+i forecast 46 | index in the 3rd dimension label. Optional argument \sQuote{type} 47 | determines whether to return \dQuote{R} for the correlation else will 48 | the DCC Q matrix. A further argument \sQuote{output} allows to switch 49 | between \dQuote{array} and \dQuote{matrix} returned object.} 50 | \item{rcov}{\code{signature(object = "DCCroll")}: 51 | The forecast dynamic conditional covariance array, with the T+i forecast 52 | index in the 3rd dimension label. A further argument 53 | \sQuote{output} allows to switch between \dQuote{array} 54 | and \dQuote{matrix} returned object.} 55 | \item{rshape}{\code{signature(object = "DCCroll")}: 56 | The multivariate distribution shape parameter(s).} 57 | \item{rskew}{\code{signature(object = "DCCroll")}: 58 | The multivariate distribution skew parameter(s). } 59 | \item{show}{\code{signature(object = "DCCroll")}: 60 | Summary. } 61 | \item{sigma}{\code{signature(object = "DCCroll")}: 62 | The conditional sigma forecast xts object (with the actual T+i forecast 63 | dates as index).} 64 | } 65 | } 66 | \references{ 67 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 68 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 69 | } 70 | \author{Alexios Galanos} 71 | \keyword{classes} 72 | -------------------------------------------------------------------------------- /man/DCCsim-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCsim-class} 2 | \docType{class} 3 | \alias{DCCsim-class} 4 | \alias{fitted,DCCsim-method} 5 | \alias{rcor,DCCsim-method} 6 | \alias{rcov,DCCsim-method} 7 | \alias{sigma,DCCsim-method} 8 | \alias{show,DCCsim-method} 9 | \title{class: DCC Forecast Class} 10 | \description{ 11 | The class is returned by calling the function \code{\link{dccsim}}. 12 | } 13 | \section{Slots}{ 14 | \describe{ 15 | \item{\code{msim}:}{Object of class \code{"vector"} Multivariate 16 | simulation list.} 17 | \item{\code{model}:}{Object of class \code{"vector"} Model specification 18 | list.} 19 | } 20 | } 21 | \section{Extends}{ 22 | Class \code{"\linkS4class{mGARCHsim}"}, directly. 23 | Class \code{"\linkS4class{GARCHsim}"}, by class "mGARCHsim", distance 2. 24 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHsim", distance 3. 25 | } 26 | 27 | \section{Methods}{ 28 | \describe{ 29 | \item{fitted}{\code{signature(object = "DCCsim")}: 30 | The conditional mean simulated data matrix given additional argument 31 | \sQuote{sim} denoting the simulation run (\code{m.sim}) to return values 32 | for.} 33 | \item{rcor}{\code{signature(object = "DCCsim")}: 34 | The simulated dynamic conditional correlation array given additional 35 | arguments \sQuote{sim} denoting the simulation run (\code{m.sim}) to 36 | return values for, and \sQuote{type} (either \dQuote{R} for the correlation 37 | else will return the Q matrix). A further argument \sQuote{output} allows to 38 | switch between \dQuote{array} and \dQuote{matrix} returned object.} 39 | \item{rcov}{\code{signature(object = "DCCsim")}: 40 | The simulated dynamic conditional covariance array given additional argument 41 | \sQuote{sim} denoting the simulation run (\code{m.sim}) to return values 42 | for. A further argument \sQuote{output} allows to switch between \dQuote{array} 43 | and \dQuote{matrix} returned object.} 44 | \item{sigma}{\code{signature(object = "DCCsim")}: 45 | The univariate simulated conditional sigma matrix given additional argument 46 | \sQuote{sim} (\code{m.sim}) denoting the simulation run to return values 47 | for.} 48 | \item{show}{\code{signature(object = "DCCsim")}: 49 | Summary. } 50 | } 51 | } 52 | \references{ 53 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 54 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 55 | } 56 | \author{Alexios Galanos} 57 | \keyword{classes} 58 | -------------------------------------------------------------------------------- /man/DCCspec-class.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCspec-class} 2 | \docType{class} 3 | \alias{DCCspec-class} 4 | \alias{show,DCCspec-method} 5 | \alias{setfixed<-,DCCspec,vector-method} 6 | \alias{setstart<-,DCCspec,vector-method} 7 | \title{class: DCC Specification Class} 8 | \description{ 9 | The class is returned by calling the function \code{\link{dccspec}}. 10 | } 11 | \section{Slots}{ 12 | \describe{ 13 | \item{\code{model}:}{Object of class \code{"vector"} The multivariate model 14 | specification list. } 15 | \item{\code{umodel}:}{Object of class \code{"vector"} The univariate model 16 | specification list.} 17 | } 18 | } 19 | \section{Extends}{ 20 | Class \code{"\linkS4class{mGARCHspec}"}, directly. 21 | Class \code{"\linkS4class{GARCHspec}"}, by class "mGARCHspec", distance 2. 22 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHspec", distance 3. 23 | } 24 | \section{Methods}{ 25 | \describe{ 26 | \item{setfixed<-}{\code{signature(object = "DCCspec", value = "vector")}: 27 | Set fixed second stage parameters.} 28 | \item{setstart<-}{\code{signature(object = "DCCspec", value = "vector")}: 29 | Set starting second stage parameters.} 30 | \item{show}{\code{signature(object = "DCCspec")}: 31 | Summary.} 32 | } 33 | } 34 | \references{ 35 | Croux, C. and Joossens, K. 2008, Robust estimation of the vector autoregressive 36 | model by a least trimmed squares procedure, \emph{COMPSTAT}, 489--501.\cr 37 | Cappiello, L., Engle, R.F. and Sheppard, K. 2006, Asymmetric dynamics in the 38 | correlations of global equity and bond returns, \emph{Journal of Financial 39 | Econometrics} \bold{4}, 537--572.\cr 40 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 41 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 42 | } 43 | \note{ 44 | The \sQuote{umodel} list is absorbed into the \sQuote{model} list in all other 45 | DCC classes. 46 | } 47 | \author{Alexios Galanos} 48 | \keyword{classes} 49 | -------------------------------------------------------------------------------- /man/DCCtest.Rd: -------------------------------------------------------------------------------- 1 | \name{DCCtest} 2 | \alias{DCCtest} 3 | \title{ 4 | Engle and Sheppard Test of Dynamic Correlation 5 | } 6 | \description{ 7 | A test of non-constant correlation based on Engle and Sheppard (2001). 8 | } 9 | \usage{ 10 | DCCtest(Data, garchOrder = c(1,1), n.lags = 1, solver = "solnp", 11 | solver.control = list(), cluster = NULL, Z = NULL) 12 | } 13 | \arguments{ 14 | \item{Data}{ 15 | A multivariate data matrix. 16 | } 17 | \item{garchOrder}{ 18 | The first stage common GARCH order. 19 | } 20 | \item{n.lags}{ 21 | The number of lags to test for the presence of non-constant correlation. 22 | } 23 | \item{solver}{ Either \dQuote{solnp} or \dQuote{nlminb} .} 24 | \item{solver.control}{Control arguments list passed to optimizer.} 25 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 26 | the parallel package. If it is not NULL, then this will be used for parallel 27 | estimation (remember to stop the cluster on completion).} 28 | \item{Z}{ 29 | (Optional) The standardized residuals from a constant correlation model. If 30 | supplied the model is not estimated since this is the only input the test 31 | requires. 32 | } 33 | } 34 | \details{ 35 | The test effectively equates to estimating a multivariate dataset using the 36 | Constant Conditional Correlation (CCC) model of Bollerslev (1990) and after 37 | which the standardized residuals (standardized by the symmetric square root 38 | decomposition of the estimated constant correlation matrix) should be i.i.d. 39 | with covariance the identity matrix. Testing for this can be done using a 40 | series of artificial regressions on the outer and lagged product of these 41 | residuals and a constant. In the rmgarch package, the CCC model is calculated 42 | using a static GARCH copula (Normal) model. 43 | } 44 | \value{ 45 | A list with the proposed Null hypothesis (H0), the test statistic and its 46 | p-value. 47 | } 48 | \author{Alexios Galanos} 49 | \references{ 50 | Bollerslev, T. 1990, Modelling the coherence in short-run nominal exchange 51 | rates: a multivariate generalized ARCH model, \emph{The Review of Economics and 52 | Statistics}, \bold{72(3)}, 498--505.\cr 53 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 54 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 55 | } 56 | -------------------------------------------------------------------------------- /man/cGARCHfilter-class.Rd: -------------------------------------------------------------------------------- 1 | \name{cGARCHfilter-class} 2 | \docType{class} 3 | \alias{cGARCHfilter-class} 4 | \alias{coef,cGARCHfilter-method} 5 | \alias{fitted,cGARCHfilter-method} 6 | \alias{likelihood,cGARCHfilter-method} 7 | \alias{rcor,cGARCHfilter-method} 8 | \alias{rcov,cGARCHfilter-method} 9 | \alias{rskew,cGARCHfilter-method} 10 | \alias{rshape,cGARCHfilter-method} 11 | \alias{residuals,cGARCHfilter-method} 12 | \alias{show,cGARCHfilter-method} 13 | \alias{sigma,cGARCHfilter-method} 14 | \title{class: Copula Filter Class} 15 | \description{ 16 | The class is returned by calling the function \code{\link{cgarchfilter}}. 17 | } 18 | \section{Slots}{ 19 | \describe{ 20 | \item{\code{mfilter}:}{Object of class \code{"vector"} Multivariate 21 | filter list. } 22 | \item{\code{model}:}{Object of class \code{"vector"} Model specification 23 | list. } 24 | } 25 | } 26 | \section{Extends}{ 27 | Class \code{"\linkS4class{mGARCHfilter}"}, directly. 28 | Class \code{"\linkS4class{GARCHfilter}"}, by class "mGARCHfilter", distance 2. 29 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHfilter", distance 3. 30 | } 31 | \section{Methods}{ 32 | \describe{ 33 | \item{coef}{\code{signature(object = "cGARCHfilter")}: 34 | The coefficient vector (see note). } 35 | \item{fitted}{\code{signature(object = "cGARCHfilter")}: 36 | The conditional mean filtered data (xts object). } 37 | \item{likelihood}{\code{signature(object = "cGARCHfilter")}: 38 | The joint likelihood. } 39 | \item{rcor}{\code{signature(object = "cGARCHfilter")}: 40 | The conditional correlation array with third dimension labels the time index.} 41 | \item{rcov}{\code{signature(object = "cGARCHfilter")}: 42 | The conditional covariance array with third dimension labels the time index.} 43 | \item{residuals}{\code{signature(object = "cGARCHfilter")}: 44 | The model residuals (xts object).} 45 | \item{show}{\code{signature(object = "cGARCHfilter")}: 46 | Summary. } 47 | \item{sigma}{\code{signature(object = "cGARCHfilter")}: 48 | The model conditional sigma (xts object). } 49 | \item{rshape}{\code{signature(object = "cGARCHfilter")}: 50 | The multivariate distribution shape parameter(s).} 51 | \item{rskew}{\code{signature(object = "cGARCHfilter")}: 52 | The multivariate distribution skew parameter(s). } 53 | } 54 | } 55 | \references{ 56 | Joe, H. \emph{Multivariate Models and Dependence Concepts}, 1997, 57 | Chapman \& Hall, London.\cr 58 | Genest, C., Ghoudi, K. and Rivest, L. \emph{A semiparametric estimation 59 | procedure of dependence parameters in multivariate families of distributions}, 60 | 1995, Biometrika, 82, 543-552.\cr 61 | } 62 | \author{Alexios Galanos} 63 | \note{ 64 | The \sQuote{coef} method takes additional argument \sQuote{type} with valid 65 | values \sQuote{garch} for the garch parameters, \sQuote{dcc} for the second 66 | stage parameters and by default returns all the parameters in a named vector. 67 | } 68 | \keyword{classes} 69 | -------------------------------------------------------------------------------- /man/cGARCHfit-class.Rd: -------------------------------------------------------------------------------- 1 | \name{cGARCHfit-class} 2 | \docType{class} 3 | \alias{cGARCHfit-class} 4 | \alias{coef,cGARCHfit-method} 5 | \alias{fitted,cGARCHfit-method} 6 | \alias{likelihood,cGARCHfit-method} 7 | \alias{rcor,cGARCHfit-method} 8 | \alias{rcov,cGARCHfit-method} 9 | \alias{rskew,cGARCHfit-method} 10 | \alias{rshape,cGARCHfit-method} 11 | \alias{residuals,cGARCHfit-method} 12 | \alias{show,cGARCHfit-method} 13 | \alias{sigma,cGARCHfit-method} 14 | \title{class: Copula Fit Class} 15 | \description{ 16 | The class is returned by calling the function \code{\link{cgarchfit}}. 17 | } 18 | \section{Slots}{ 19 | \describe{ 20 | \item{\code{mfit}:}{Object of class \code{"vector"} Multivariate fit list. } 21 | \item{\code{model}:}{Object of class \code{"vector"} Model specification list. } 22 | } 23 | } 24 | \section{Extends}{ 25 | Class \code{"\linkS4class{mGARCHfit}"}, directly. 26 | Class \code{"\linkS4class{GARCHfit}"}, by class "mGARCHfit", distance 2. 27 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHfit", distance 3. 28 | } 29 | \section{Methods}{ 30 | \describe{ 31 | \item{coef}{\code{signature(object = "cGARCHfit")}: 32 | The coefficient vector (see note). } 33 | \item{fitted}{\code{signature(object = "cGARCHfit")}: 34 | The conditional mean fitted data (xts object). } 35 | \item{likelihood}{\code{signature(object = "cGARCHfit")}: 36 | The joint likelihood. } 37 | \item{rcor}{\code{signature(object = "cGARCHfit")}: 38 | The conditional correlation array with third dimension labels the time index. 39 | A further argument \sQuote{output} allows to switch between \dQuote{array} 40 | and \dQuote{matrix} returned object.} 41 | \item{rcov}{\code{signature(object = "cGARCHfit")}: 42 | The conditional covariance array with third dimension labels the time index. 43 | A further argument \sQuote{output} allows to switch between \dQuote{array} 44 | and \dQuote{matrix} returned object.} 45 | \item{rshape}{\code{signature(object = "cGARCHfit")}: 46 | The multivariate distribution shape parameter(s).} 47 | \item{rskew}{\code{signature(object = "cGARCHfit")}: 48 | The multivariate distribution skew parameter(s). } 49 | \item{residuals}{\code{signature(object = "cGARCHfit")}: 50 | The model residuals (xts object).} 51 | \item{show}{\code{signature(object = "cGARCHfit")}: 52 | Summary.} 53 | \item{sigma}{\code{signature(object = "cGARCHfit")}: 54 | The model conditional sigma (xts object). } 55 | } 56 | } 57 | \references{ 58 | Joe, H. \emph{Multivariate Models and Dependence Concepts}, 1997, 59 | Chapman \& Hall, London.\cr 60 | Genest, C., Ghoudi, K. and Rivest, L. \emph{A semiparametric estimation 61 | procedure of dependence parameters in multivariate families of distributions}, 62 | 1995, Biometrika, 82, 543-552.\cr 63 | } 64 | \author{Alexios Galanos} 65 | \note{ 66 | The \sQuote{coef} method takes additional argument \sQuote{type} with valid 67 | values \sQuote{garch} for the garch parameters, \sQuote{dcc} for the second 68 | stage parameters and by default returns all the parameters in a named vector. 69 | } 70 | \keyword{classes} 71 | -------------------------------------------------------------------------------- /man/cGARCHsim-class.Rd: -------------------------------------------------------------------------------- 1 | \name{cGARCHsim-class} 2 | \docType{class} 3 | \alias{cGARCHsim-class} 4 | \alias{fitted,cGARCHsim-method} 5 | \alias{sigma,cGARCHsim-method} 6 | \alias{rcor,cGARCHsim-method} 7 | \alias{rcov,cGARCHsim-method} 8 | \alias{show,cGARCHsim-method} 9 | \title{class: Copula Simulation Class} 10 | \description{ 11 | The class is returned by calling the function \code{\link{cgarchsim}}. 12 | } 13 | \section{Slots}{ 14 | \describe{ 15 | \item{\code{msim}:}{Object of class \code{"vector"} Multivariate simulation list.} 16 | \item{\code{model}:}{Object of class \code{"vector"} Model specification list. } 17 | } 18 | } 19 | \section{Extends}{ 20 | Class \code{"\linkS4class{mGARCHsim}"}, directly. 21 | Class \code{"\linkS4class{GARCHsim}"}, by class "mGARCHsim", distance 2. 22 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHsim", distance 3. 23 | } 24 | \section{Methods}{ 25 | \describe{ 26 | \item{fitted}{\code{signature(object = "cGARCHsim")}: 27 | The simulated conditional returns matrix given. Takes optional argument 28 | \dQuote{sim} indicating the simulation run to return (from the m.sim option 29 | of the \code{\link{cgarchsim}} method.} 30 | \item{sigma}{\code{signature(object = "cGARCHfit")}: 31 | The simulated conditional sigma matrix given. Takes optional argument 32 | \dQuote{sim} indicating the simulation run to return (from the m.sim option 33 | of the \code{\link{cgarchsim}} method.} 34 | \item{rcor}{\code{signature(object = "cGARCHsim")}: 35 | The simulated conditional correlation array (for DCC type). Takes optional 36 | argument \dQuote{sim} indicating the simulation run to return (from the 37 | m.sim option of the \code{\link{cgarchsim}} method. A further argument 38 | \sQuote{output} allows to switch between \dQuote{array} 39 | and \dQuote{matrix} returned object.} 40 | \item{rcov}{\code{signature(object = "cGARCHsim")}: 41 | The simulated conditional covariance array. Takes optional argument 42 | \dQuote{sim} indicating the simulation run to return 43 | (from the m.sim option of the \code{\link{cgarchsim}} method. 44 | A further argument \sQuote{output} allows to switch between \dQuote{array} 45 | and \dQuote{matrix} returned object.} 46 | \item{show}{\code{signature(object = "cGARCHsim")}: 47 | Summary. } 48 | } 49 | } 50 | \references{ 51 | Joe, H. \emph{Multivariate Models and Dependence Concepts}, 1997, 52 | Chapman \& Hall, London.\cr 53 | Genest, C., Ghoudi, K. and Rivest, L. \emph{A semiparametric estimation 54 | procedure of dependence parameters in multivariate families of distributions}, 55 | 1995, Biometrika, 82, 543-552.\cr 56 | } 57 | \author{Alexios Galanos} 58 | \keyword{classes} 59 | -------------------------------------------------------------------------------- /man/cGARCHspec-class.Rd: -------------------------------------------------------------------------------- 1 | \name{cGARCHspec-class} 2 | \docType{class} 3 | \alias{cGARCHspec-class} 4 | \alias{show,cGARCHspec-method} 5 | \alias{setfixed<-,cGARCHspec,vector-method} 6 | \alias{setstart<-,cGARCHspec,vector-method} 7 | \title{class: Copula Specification Class} 8 | \description{ 9 | The class is returned by calling the function \code{\link{cgarchspec}}. 10 | } 11 | \section{Slots}{ 12 | \describe{ 13 | \item{\code{model}:}{Object of class \code{"vector"} 14 | The multivariate model specification } 15 | \item{\code{umodel}:}{Object of class \code{"uGARCHmultispec"} 16 | The univariate model specification.} 17 | } 18 | } 19 | \section{Extends}{ 20 | Class \code{"\linkS4class{mGARCHspec}"}, directly. 21 | Class \code{"\linkS4class{GARCHspec}"}, by class "mGARCHspec", distance 2. 22 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHspec", distance 3. 23 | } 24 | \section{Methods}{ 25 | \describe{ 26 | \item{show}{\code{signature(object = "cGARCHspec")}: 27 | Summary.} 28 | \item{setfixed<-}{\code{signature(object = "cGARCHspec", value = "vector")}: 29 | Set fixed second stage parameters.} 30 | \item{setstart<-}{\code{signature(object = "cGARCHspec", value = "vector")}: 31 | Set starting second stage parameters.} 32 | } 33 | } 34 | \references{ 35 | Joe, H. \emph{Multivariate Models and Dependence Concepts}, 1997, 36 | Chapman \& Hall, London.\cr 37 | Genest, C., Ghoudi, K. and Rivest, L. \emph{A semiparametric estimation 38 | procedure of dependence parameters in multivariate families of distributions}, 39 | 1995, Biometrika, 82, 543-552.\cr 40 | } 41 | \author{Alexios Galanos} 42 | \keyword{classes} 43 | -------------------------------------------------------------------------------- /man/cgarchfilter-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{cgarchfilter-methods} 2 | \docType{methods} 3 | \alias{cgarchfilter} 4 | \alias{cgarchfilter,ANY-method} 5 | \alias{cgarchfilter,cGARCHspec-method} 6 | \title{function: Copula-GARCH Filter} 7 | \description{ 8 | Method for creating a Copula-GARCH filter object. 9 | } 10 | \usage{ 11 | cgarchfilter(spec, data, out.sample = 0, filter.control = list(n.old = NULL), 12 | spd.control = list(lower = 0.1, upper = 0.9, type = "pwm", kernel = "epanech"), 13 | cluster = NULL, varcoef = NULL, realizedVol = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{spec}{ A \code{\linkS4class{cGARCHspec}} object created by 17 | calling \code{\link{cgarchspec}} with fixed parameters for the coeffficients.} 18 | \item{data}{ A multivariate xts data object or one which can be coerced to 19 | such.} 20 | \item{out.sample}{ A positive integer indicating the number of periods 21 | before the last to keep for out of sample forecasting.} 22 | \item{filter.control}{Control arguments passed to the filtering routine (see 23 | note below).} 24 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 25 | the parallel package. If it is not NULL, then this will be used for parallel 26 | estimation (remember to stop the cluster on completion).} 27 | \item{spd.control}{ If the spd transformation was chosen in the 28 | specification, the spd.control passes its arguments to the 29 | \code{spdfit} routine of the \code{spd} package.} 30 | \item{varcoef}{ If a VAR model was chosen, then this is the VAR coefficient 31 | matrix which must be supplied. No checks are done on its dimension or 32 | correctness so it is up to the user to perform the appropriate checks.} 33 | \item{realizedVol}{ Required xts matrix for the realGARCH model.} 34 | \item{...}{ . } 35 | } 36 | \value{ 37 | A \code{\linkS4class{cGARCHfilter}} object containing details of the 38 | Copula-GARCH filter and sharing most of the methods of the 39 | \code{\linkS4class{cGARCHfit}} class. 40 | } 41 | \note{ 42 | The \sQuote{n.old} option in the \code{filter.control} argument is key in 43 | replicating conditions of the original fit. That is, if you want to filter a 44 | dataset consisting of an expanded dataset (versus the original used in fitting), 45 | but want to use the same assumptions as the original dataset then the \sQuote{n.old} 46 | argument denoting the original number of data points passed to the 47 | \code{\link{cgarchfit}} function must be provided. This is then used to ensure 48 | that some calculations which make use of the full dataset (unconditional 49 | starting values for the garch filtering, the dcc model and the copula 50 | transformation methods) only use the first \sQuote{n.old} points thus 51 | replicating the original conditions making filtering appropriate for rolling 52 | 1-ahead forecasting.\cr 53 | For extensive examples look in the \sQuote{rmgarch.tests} folder. 54 | } 55 | \author{Alexios Galanos} 56 | \keyword{methods} 57 | -------------------------------------------------------------------------------- /man/cgarchfit-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{cgarchfit-methods} 2 | \docType{methods} 3 | \alias{cgarchfit} 4 | \alias{cgarchfit,ANY-method} 5 | \alias{cgarchfit,cGARCHspec-method} 6 | \title{function: Copula-GARCH Fit} 7 | \description{ 8 | Method for creating a Copula-GARCH fit object. 9 | } 10 | \usage{ 11 | cgarchfit(spec, data, spd.control = list(lower = 0.1, upper = 0.9, type = "pwm", 12 | kernel = "epanech"), fit.control = list(eval.se = TRUE, stationarity = TRUE, 13 | scale = FALSE), solver = "solnp", solver.control = list(), out.sample = 0, 14 | cluster = NULL, fit = NULL, VAR.fit = NULL, realizedVol = NULL,...) 15 | } 16 | \arguments{ 17 | \item{spec}{ A \code{\linkS4class{cGARCHspec}} A \code{\linkS4class{cGARCHspec}} 18 | object created by calling \code{\link{cgarchspec}}.} 19 | \item{data}{ A multivariate xts data object or one which can be coerced to 20 | such.} 21 | \item{out.sample}{ A positive integer indicating the number of periods before 22 | the last to keep for out of sample forecasting.} 23 | \item{solver}{ Either \dQuote{nlminb}, \dQuote{solnp}, \dQuote{gosolnp} or 24 | \dQuote{lbfgs}. It can also optionally be a vector of length 2 with the first 25 | solver being used for the first stage univariate GARCH estimation (in which 26 | case the option of \dQuote{hybrid} is also available).} 27 | \item{solver.control}{Control arguments list passed to optimizer.} 28 | \item{fit.control}{Control arguments passed to the fitting routine. 29 | The \sQuote{eval.se} option determines whether standard errors are calculated 30 | (see details below). The \sQuote{scale} option is for the first stage 31 | univariate GARCH fitting routine.} 32 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 33 | the parallel package. If it is not NULL, then this will be used for parallel 34 | estimation (remember to stop the cluster on completion).} 35 | \item{fit}{ (optional) A previously estimated univariate 36 | \code{\linkS4class{uGARCHmultifit}} object (see details).} 37 | \item{VAR.fit}{ (optional) A previously estimated VAR list returned from 38 | calling the \code{\link{varxfit}} function.} 39 | \item{spd.control}{ If the spd transformation was chosen in the 40 | specification, the spd.control passes its arguments to the 41 | \code{spdfit} routine of the \code{spd} package.} 42 | \item{realizedVol}{ Required xts matrix for the realGARCH model.} 43 | \item{...}{ . } 44 | } 45 | \value{ 46 | A \code{\linkS4class{cGARCHfit}} Object containing details of the Copula-GARCH 47 | fit. 48 | } 49 | \author{Alexios Galanos} 50 | \details{ 51 | The Copula-GARCH models implemented can either be time-varying of DCC variety 52 | else static. The multivariate Normal and Student distributions are used in the 53 | construction of the copulas, and 3 transformation methods are available 54 | (parametric, semi-parametric, and empirical). For the semi-parametric case the 55 | \sQuote{spd} package of the author is available to download from CRAN and fits a 56 | Gaussian kernel in the interior and gpd distribution for the tails (see that 57 | package for more details).\cr 58 | The static copula allows for the estimation of the correlation matrix either by 59 | Maximum Likelihood or the Kendall method for the multivariate Student.\cr 60 | Note that the \sQuote{cgarchfit} method will assign to the global environment 61 | the \code{\linkS4class{uGARCHmultifit}} once that is estimated in order to allow 62 | the routine to be restarted should something go wrong (it should show up as 63 | \sQuote{.fitlist}). 64 | } 65 | \note{ 66 | There is no check on the VAR.fit list passed to the method so particular care 67 | should be exercised so that the same data used in the fitting routine is also 68 | used in the VAR fit routine. This must have been called with the option 69 | \code{postpad} \sQuote{constant}. The ability to pass this list of the 70 | pre-calculated VAR model is particularly useful when comparing different models 71 | (such as DCC GARCH, GO GARCH etc) using the same dataset and VAR method (i.e. 72 | the same first stage conditional mean filtration). Though the classical VAR 73 | estimation is very fast and may not require this extra step, the robust method 74 | is slow and therefore benefits from calculating this only once.\cr 75 | For extensive examples look in the \sQuote{rmgarch.tests} folder. 76 | } 77 | \keyword{methods} 78 | -------------------------------------------------------------------------------- /man/cgarchsim-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{cgarchsim-methods} 2 | \docType{methods} 3 | \alias{cgarchsim} 4 | \alias{cgarchsim,ANY-method} 5 | \alias{cgarchsim,cGARCHfit-method} 6 | \title{function: Copula-GARCH Simulation} 7 | \description{ 8 | Method for creating a Copula-GARCH simulation object. 9 | } 10 | \usage{ 11 | cgarchsim(fit, n.sim = 1000, n.start = 0, m.sim = 1, 12 | startMethod = c("unconditional", "sample"), presigma = NULL, preresiduals = NULL, 13 | prereturns = NULL, preR = NULL, preQ = NULL, preZ = NULL, rseed = NULL, 14 | mexsimdata = NULL, vexsimdata = NULL, cluster = NULL, only.density = FALSE, 15 | prerealized = NULL, ...) 16 | } 17 | \arguments{ 18 | \item{fit}{ 19 | A \code{\linkS4class{cGARCHfit}} object created by calling \code{\link{cgarchfit}}.} 20 | \item{n.sim}{ The simulation horizon.} 21 | \item{n.start}{ The burn-in sample.} 22 | \item{m.sim}{ The number of simulations.} 23 | \item{startMethod}{ Starting values for the simulation. Valid methods are 24 | \sQuote{unconditional} for the expected values given the density, 25 | and \sQuote{sample} for the ending values of the actual data from the fit 26 | object. This is mostly related to the univariate GARCH dynamics.} 27 | \item{presigma}{ Allows the starting sigma values to be provided by the user 28 | for the univariate GARCH dynamics.} 29 | \item{prereturns}{ Allows the starting return data to be provided by the 30 | user for the conditional mean simulation.} 31 | \item{preresiduals}{ Allows the starting residuals to be provided by the 32 | user and used in the GARCH dynamics simulation.} 33 | \item{preR}{ Allows the starting correlation to be provided by the user and 34 | mostly useful for the static copula.} 35 | \item{preQ}{ Allows the starting \sQuote{DCC-Q} value to be provided by the 36 | user and though unnecessary for the first 1-ahead simulation using the 37 | \dQuote{sample} option in the \code{startMethod}, this is key to obtaining 38 | a rolling n-ahead forecast type simulation (see details below).} 39 | \item{preZ}{ Allows the starting transformed standardized residuals (used in 40 | the DCC model) to be provided by the user and though unnecessary for the 41 | first 1-ahead simulation using the \dQuote{sample} option in the 42 | \code{startMethod}, this is key to obtaining a rolling n-ahead forecast type 43 | simulation (see details below).} 44 | \item{rseed}{ Optional seeding value(s) for the random number generator. 45 | This should be of length equal to m.sim.} 46 | \item{mexsimdata}{ A list (equal to the number of asset) of matrices of 47 | simulated external regressor-in-mean data with row length equal to 48 | n.sim + n.start. If the fit object contains external regressors in the mean 49 | equation, this must be provided else will be assumed to be zero.} 50 | \item{vexsimdata}{ A list (equal to the number of asset) of matrices of 51 | simulated external regressor-in-variance data with row length equal to 52 | n.sim + n.start. If the fit object contains external regressors in the 53 | variance equation, this must be provided else will be assumed to be zero.} 54 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 55 | the parallel package. If it is not NULL, then this will be used for parallel 56 | estimation (remember to stop the cluster on completion).} 57 | \item{only.density}{Whether to return only the simulated returns (discrete 58 | time approximation to the multivariate density). This is sometimes useful 59 | in order to control memory management for large simulations not requiring 60 | any other information.} 61 | \item{prerealized}{Allows the starting realized volatility values to be provided 62 | by the user for the univariate GARCH dynamics.} 63 | \item{...}{.} 64 | } 65 | \value{ 66 | A \code{\linkS4class{cGARCHsim}} object containing details of the Copula-GARCH 67 | simulation. 68 | } 69 | \details{ 70 | Since there is no explicit forecasting routine, the user should use this method 71 | for incrementally building up n-ahead forecasts by simulating 1-ahead, obtaining 72 | the means of the returns, sigma, Rho etc and feeding them to the next round of 73 | simulation as starting values. The \sQuote{rmgarch.tests} folder contains 74 | specific examples which illustrate this particular point. 75 | } 76 | \references{ 77 | Joe, H. \emph{Multivariate Models and Dependence Concepts}, 1997, 78 | Chapman \& Hall, London.\cr 79 | Genest, C., Ghoudi, K. and Rivest, L. \emph{A semiparametric estimation 80 | procedure of dependence parameters in multivariate families of distributions}, 81 | 1995, Biometrika, 82, 543-552.\cr 82 | } 83 | \author{Alexios Galanos} 84 | \keyword{methods} 85 | -------------------------------------------------------------------------------- /man/cgarchspec-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{cgarchspec-methods} 2 | \docType{methods} 3 | \alias{cgarchspec} 4 | \alias{cgarchspec,ANY-method} 5 | \alias{cgarchspec,uGARCHmultispec-method} 6 | \title{function: Copula-GARCH Specification} 7 | \description{ 8 | Method for creating a Copula-GARCH specification object prior to fitting. 9 | } 10 | \usage{ 11 | cgarchspec(uspec, VAR = FALSE, robust = FALSE, lag = 1, lag.max = NULL, 12 | lag.criterion = c("AIC", "HQ", "SC", "FPE"), external.regressors = NULL, 13 | robust.control = list(gamma = 0.25, delta = 0.01, nc = 10, ns = 500), 14 | dccOrder = c(1, 1), asymmetric = FALSE, 15 | distribution.model = list(copula = c("mvnorm", "mvt"), 16 | method = c("Kendall", "ML"), time.varying = FALSE, 17 | transformation = c("parametric", "empirical", "spd")), 18 | start.pars = list(), fixed.pars = list()) 19 | } 20 | \arguments{ 21 | \item{uspec}{ 22 | A \code{\linkS4class{uGARCHmultispec}} object created by calling 23 | \code{\link{multispec}} on a list of univariate GARCH specifications.} 24 | \item{VAR}{ Whether to fit a VAR model for the conditional mean.} 25 | \item{robust}{ Whether to use the robust version of VAR.} 26 | \item{lag}{ The VAR lag.} 27 | \item{lag.max}{ The maximum VAR lag to search for best fit.} 28 | \item{lag.criterion}{ The criterion to use for choosing the best lag when 29 | lag.max is not NULL.} 30 | \item{external.regressors}{ Allows for a matrix of common pre-lagged external 31 | regressors for the VAR option. 32 | } 33 | \item{robust.control}{ The tuning parameters to the robust regression 34 | including the proportion to trim (\dQuote{gamma}), the critical value for 35 | reweighted estimator (\dQuote{delta}), the number of subsets (\dQuote{ns}) and 36 | the number of C-steps (\dQuote{nc}.} 37 | \item{dccOrder}{ The DCC autoregressive order.} 38 | \item{asymmetric}{ Whether to include an asymmetry term to the DCC model (thus 39 | estimating the aDCC).} 40 | \item{distribution.model}{ The Copula distribution model. Currently the 41 | multivariate Normal and Student Copula are supported. } 42 | \item{time.varying}{ Whether to fit a dynamic DCC Copula. } 43 | \item{transformation}{ The type of transformation to apply to the marginal 44 | innovations of the GARCH fitted models. Supported methods are parametric 45 | (Inference Function of Margins), empirical (Pseudo ML), and Semi-Parametric 46 | using a kernel interior and GPD tails (via the \sQuote{spd} package).} 47 | \item{start.pars}{ (optional) Starting values for the DCC parameters 48 | (starting values for the univariate garch specification should be passed 49 | directly via the \sQuote{uspec} object).} 50 | \item{fixed.pars}{ (optional) Fixed DCC parameters.} 51 | } 52 | \value{ 53 | A \code{\linkS4class{cGARCHspec}} object containing details of the Copula-GARCH 54 | specification. 55 | } 56 | \details{ 57 | The transformation method allows for parametric (Inference-Functions for Margins), 58 | empirical (Pseudo-Likelihood) and semi-parametric (via the spd package).\cr 59 | When the Student Copula is jointly estimated with student margins having so that 60 | a common shape parameter is obtained, this results in the multivariate Student 61 | distribution. When estimating the Student Copula with disparate margins, a 62 | meta-student distribution is obtained. Additionally, the correlation parameter 63 | in the static Student Copula may be estimated either by Kendall's tau 64 | transformation or Maximum Likelihood.\cr 65 | The \code{robust} option allows for a robust version of VAR based on the 66 | multivariate Least Trimmed Squares Estimator described in Croux and Joossens 67 | (2008). 68 | } 69 | \author{Alexios Galanos} 70 | \keyword{methods} 71 | -------------------------------------------------------------------------------- /man/cordist.Rd: -------------------------------------------------------------------------------- 1 | \name{cordist} 2 | \alias{cordist} 3 | \title{ 4 | A Correlation Distance Measure 5 | } 6 | \description{ 7 | Given an array of correlation snapshots in time, returns a matrix of some rolling 8 | distance measure on the correlations. 9 | } 10 | \usage{ 11 | cordist(R, distance = c("ma","ms","meda","meds","eigen", "cmd"), n = 25, 12 | plot = TRUE, dates = NULL, title = NULL) 13 | } 14 | \arguments{ 15 | \item{R}{ 16 | An array of correlations. 17 | } 18 | \item{distance}{ 19 | The measure to use to capture the change between 2 correlation matrices 20 | (see details). 21 | } 22 | \item{n}{ 23 | The distance between 2 correlation matrices. 24 | } 25 | \item{plot}{ 26 | Whether to create a heatmap plot of the result. 27 | } 28 | \item{dates}{ 29 | A \code{POSIXct} vector of dates to use for the heatmap (recommend to 30 | supply). 31 | } 32 | \item{title}{ 33 | Title for the heatmap plot. 34 | } 35 | } 36 | \details{ 37 | This function provides for a visualization of dynamic correlation distance 38 | between periods with a number of plausible measures including \dQuote{ma} 39 | (mean absolute), \dQuote{ms} (mean squared), \dQuote{meda} (median absolute), 40 | \dQuote{meds} (median squared) \dQuote{eigen} (largest eigenvalue difference) and 41 | \dQuote{cmd} (correlation matrix distance). See the references for more details. 42 | } 43 | \value{ 44 | A symmetric matrix of the rolling distance measure for each period. 45 | } 46 | \references{ 47 | Munnix, M. C., Shimada, T., Schafer, R., Leyvraz, F., Seligman, T. H., 48 | Guhr, T., & Stanley, H. E. (2012). Identifying states of a financial market. 49 | \emph{Scientific Reports 2}.\cr 50 | Herdin, M., Czink, N., Ozcelik, H., & Bonek, E. (2005). Correlation matrix 51 | distance, a meaningful measure for evaluation of non-stationary MIMO channels. 52 | \emph{Vehicular Technology Conference, 2005, IEEE 61st}, \bold{1}, 136--140. 53 | } 54 | \author{Alexios Galanos} 55 | -------------------------------------------------------------------------------- /man/dccfilter-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{dccfilter-methods} 2 | \docType{methods} 3 | \alias{dccfilter} 4 | \alias{dccfilter,ANY-method} 5 | \alias{dccfilter,DCCspec-method} 6 | \title{function: DCC-GARCH Filter} 7 | \description{ 8 | Method for creating a DCC-GARCH filter object. 9 | } 10 | \usage{ 11 | dccfilter(spec, data, out.sample = 0, filter.control = list(n.old = NULL), 12 | cluster = NULL, varcoef = NULL, realizedVol = NULL, ...) 13 | } 14 | \arguments{ 15 | \item{spec}{ A \code{\linkS4class{DCCspec}} object created by calling 16 | \code{\link{dccspec}} with fixed parameters for the coefficients.} 17 | \item{data}{ A multivariate data object of class xts, or one which can be 18 | coerced to such.} 19 | \item{out.sample}{ A positive integer indicating the number of periods 20 | before the last to keep for out of sample forecasting.} 21 | \item{filter.control}{Control arguments passed to the filtering routine (see 22 | note.} 23 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 24 | the parallel package. If it is not NULL, then this will be used for parallel 25 | estimation (remember to stop the cluster on completion).} 26 | \item{varcoef}{ If a VAR model was chosen, then this is the VAR coefficient 27 | matrix which must be supplied. No checks are done on its dimension or 28 | correctness so it is up to the user to perform the appropriate checks.} 29 | \item{realizedVol}{ Required xts matrix for the realGARCH model.} 30 | \item{...}{ . } 31 | } 32 | \value{ 33 | A \code{\linkS4class{DCCfilter}} object containing details of the DCC-GARCH 34 | filter. 35 | } 36 | \note{ 37 | The \sQuote{n.old} option in the \code{filter.control} argument is key in 38 | replicating conditions of the original fit. That is, if you want to filter a 39 | dataset consisting of an expanded dataset (versus the original used in fitting), 40 | but want to use the same assumptions as the original dataset then the \sQuote{n.old} 41 | argument denoting the original number of data points passed to the 42 | \code{\link{dccfit}} function must be provided. This is then used to ensure 43 | that some calculations which make use of the full dataset (unconditional 44 | starting values for the garch filtering and the dcc model) only use the first 45 | \sQuote{n.old} points thus replicating the original conditions making filtering 46 | appropriate for rolling 1-ahead forecasting.\cr 47 | For extensive examples look in the \sQuote{rmgarch.tests} folder. 48 | } 49 | \author{Alexios Galanos} 50 | \keyword{methods} 51 | -------------------------------------------------------------------------------- /man/dccfit-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{dccfit-methods} 2 | \docType{methods} 3 | \alias{dccfit} 4 | \alias{dccfit,ANY-method} 5 | \alias{dccfit,DCCspec-method} 6 | \title{function: DCC-GARCH Fit} 7 | \description{ 8 | Method for creating a DCC-GARCH fit object. 9 | } 10 | \usage{ 11 | dccfit(spec, data, out.sample = 0, solver = "solnp", solver.control = list(), 12 | fit.control = list(eval.se = TRUE, stationarity = TRUE, scale = FALSE), 13 | cluster = NULL, fit = NULL, VAR.fit = NULL, realizedVol = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{spec}{ A \code{\linkS4class{DCCspec}} object created by calling 17 | \code{\link{dccspec}}.} 18 | \item{data}{ A multivariate data object of class xts or one which can be 19 | coerced to such.} 20 | \item{out.sample}{ A positive integer indicating the number of periods 21 | before the last to keep for out of sample forecasting.} 22 | \item{solver}{ Either \dQuote{nlminb}, \dQuote{solnp}, \dQuote{gosolnp} or 23 | \dQuote{lbfgs}. It can also optionally be a vector of length 2 with the first 24 | solver being used for the first stage univariate GARCH estimation (in which 25 | case the option of \dQuote{hybrid} is also available).} 26 | \item{solver.control}{Control arguments list passed to optimizer.} 27 | \item{fit.control}{Control arguments passed to the fitting routine. 28 | The \sQuote{eval.se} option determines whether standard errors are calculated 29 | (see details below). The \sQuote{stationarity} option is for the univariate 30 | stage GARCH fitting routine, whilst for the second stage DCC this is 31 | imposed by design. The \sQuote{scale} option is also for the first stage 32 | univariate GARCH fitting routine.} 33 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 34 | the parallel package. If it is not NULL, then this will be used for parallel 35 | estimation (remember to stop the cluster on completion).} 36 | \item{fit}{ (optional) A previously estimated univariate 37 | \code{\linkS4class{uGARCHmultifit}} object (see details).} 38 | \item{VAR.fit}{ (optional) A previously estimated VAR object returned from 39 | calling the \code{\link{varxfit}} function.} 40 | \item{realizedVol}{ Required xts matrix for the realGARCH model.} 41 | \item{...}{ . } 42 | } 43 | \value{ 44 | A \code{\linkS4class{DCCfit}} object containing details of the DCC-GARCH fit. 45 | } 46 | \author{Alexios Galanos} 47 | \details{ 48 | The 2-step DCC estimation fits a GARCH-Normal model to the univariate data and 49 | then proceeds to estimate the second step based on the chosen multivariate 50 | distribution. Because of this 2-step approach, standard errors are expensive to 51 | calculate and therefore the use of parallel functionality, built into both the 52 | fitting and standard error calculation routines is key. The switch to turn off 53 | the calculation of standard errors through the \sQuote{fit.control} option could 54 | be quite useful in rolling estimation such as in the \code{\link{dccroll}} 55 | routine.\cr 56 | The optional \sQuote{fit} argument allows to pass your own \code{\linkS4class{uGARCHmultifit}} 57 | object instead of having the routine estimate it. This is very useful in cases 58 | of multiple use of the same fit and problems in convergence which might require 59 | a more hands on approach to the univariate fitting stage. However, it is up to 60 | the user to ensure consistency between the \sQuote{fit} and supplied \sQuote{spec}. 61 | } 62 | \note{ 63 | There is no check on the VAR.fit list passed to the method so particular care 64 | should be exercised so that the same data used in the fitting routine is also 65 | used in the VAR fit routine. This this must have been called with the option 66 | \code{postpad} \sQuote{constant}. The ability to pass this list of the 67 | pre-calculated VAR model is particularly useful when comparing different models 68 | (such as copula-GARCH, GO-GARCH etc) using the same dataset and VAR method (i.e. 69 | the same first stage conditional mean filtration). Though the classical VAR 70 | estimation is very fast and may not require this extra step, the robust method 71 | is slow and therefore benefits from calculating this only once.\cr 72 | For extensive examples look in the \sQuote{rmgarch.tests} folder. 73 | } 74 | \keyword{methods} 75 | -------------------------------------------------------------------------------- /man/dccforecast-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{dccforecast-methods} 2 | \docType{methods} 3 | \alias{dccforecast} 4 | \alias{dccforecast,ANY-method} 5 | \alias{dccforecast,DCCfit-method} 6 | \title{function: DCC-GARCH Forecast} 7 | \description{ 8 | Method for creating a DCC-GARCH forecast object. 9 | } 10 | \usage{ 11 | dccforecast(fit, n.ahead = 1, n.roll = 0, 12 | external.forecasts = list(mregfor = NULL, vregfor = NULL), cluster = NULL, ...) 13 | } 14 | \arguments{ 15 | \item{fit}{ A \code{\linkS4class{DCCfit}} object created by calling 16 | \code{\link{dccfit}}.} 17 | \item{n.ahead}{ The forecast horizon.} 18 | \item{n.roll}{ The no. of rolling forecasts to create beyond the first one 19 | (see details).} 20 | \item{external.forecasts}{ A list with forecasts for the external regressors 21 | in the mean and/or variance equations if specified (see details).} 22 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 23 | the parallel package. If it is not NULL, then this will be used for parallel 24 | estimation (remember to stop the cluster on completion).} 25 | \item{...}{.} 26 | } 27 | \value{ 28 | A \code{\linkS4class{DCCforecast}} object containing details of the DCC-GARCH 29 | forecast. 30 | } 31 | \details{ 32 | When using \code{n.roll}, it is assumed that \code{\link{dccfit}} was called 33 | with argument \sQuote{out.sample} being large enough to cover n-rolling 34 | forecasts.\cr 35 | When n.roll = 0, all forecasts are based on an unconditional n-ahead forecast 36 | routine based on the approximation method described in ENGLE and SHEPPARD (2001) 37 | paper (see reference below). If any external regressors are present, then the 38 | user must pass in their unconditional forecasts in the \sQuote{external.forecasts} 39 | list, as matrices with dimensions equal to n.ahead x n.assets. This assumes 40 | that the univariate GARCH specifications share common external regressors 41 | (this may change in the future).\cr 42 | When n.roll>0 and n.ahead = 1, then this is a pure rolling forecast based on the 43 | available out.sample data provided for in the call to the fit routine. It is 44 | also assumed that if any external regressors were passed to the fit routine that 45 | they contained enough values to cover the out.sample period so that they could 46 | be used in this forecast scenario.\cr 47 | The case of n.roll > 0 AND n.ahead > 1 is not implemented.\cr 48 | } 49 | \references{ 50 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 51 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 52 | } 53 | \author{Alexios Galanos} 54 | \keyword{methods} 55 | -------------------------------------------------------------------------------- /man/dccroll-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{dccroll-methods} 2 | \docType{methods} 3 | \alias{dccroll} 4 | \alias{dccroll,ANY-method} 5 | \alias{dccroll,DCCspec-method} 6 | \title{function: DCC-GARCH Rolling Forecast} 7 | \description{ 8 | Method for creating a DCC-GARCH rolling forecast object. 9 | } 10 | \usage{ 11 | dccroll(spec, data, n.ahead = 1, forecast.length = 50, refit.every = 25, 12 | n.start = NULL, refit.window = c("recursive", "moving"), window.size = NULL, 13 | solver = "solnp", solver.control = list(), 14 | fit.control = list(eval.se = TRUE, stationarity = TRUE, scale = FALSE), 15 | cluster = NULL, save.fit = FALSE, save.wdir = NULL, realizedVol = NULL, 16 | clusterOnAssets=FALSE, ...) 17 | } 18 | \arguments{ 19 | \item{spec}{ A \code{\linkS4class{DCCspec}} object with fixed parameters.} 20 | \item{data}{ A multivariate xts dataset or one which can be coerced to such.} 21 | \item{n.ahead}{ The number of periods to forecast. } 22 | \item{forecast.length}{ The length of the total forecast for which out of 23 | sample data from the dataset will be used for testing.} 24 | \item{n.start}{ Instead of forecast.length, this determines the starting 25 | point in the dataset from which to initialize the rolling forecast.} 26 | \item{refit.every}{ Determines every how many periods the model is 27 | re-estimated.} 28 | \item{refit.window}{ 29 | Whether the refit is done on an expanding window including all the previous 30 | data or a moving window where all previous data is used for the first estimation 31 | and then moved by a length equal to refit.every (unless the window.size option 32 | is used instead).} 33 | \item{window.size}{ 34 | If not NULL, determines the size of the moving window in the rolling estimation, 35 | which also determines the first point used.} 36 | \item{solver}{ The solver to use.} 37 | \item{fit.control}{ Control parameters parameters passed to the fitting 38 | function.} 39 | \item{solver.control}{ Control parameters passed to the solver.} 40 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 41 | the parallel package. If it is not NULL, then this will be used for parallel 42 | estimation of the refits (remember to stop the cluster on completion).} 43 | \item{save.fit}{ Whether to save the fitted objects of class 44 | \code{\linkS4class{DCCfit}} during the estimation of each (\dQuote{refit.every}). 45 | If true, the directory to save must be provided. The function will not save 46 | this by default for reasons of memory management, but can save it as an 47 | \dQuote{.rda} file in the user's chosen directory for further analysis.} 48 | \item{save.wdir}{ If \dQuote{save.fit} is true, the directory in which to 49 | save the \code{\linkS4class{DCCfit}} objects (1 for each \dQuote{refit.every}).} 50 | \item{realizedVol}{ Required xts matrix for the realGARCH model.} 51 | \item{clusterOnAssets}{If a cluster object is provided, use parallel resources on 52 | the univariate estimation (TRUE) else on the rolling windows (FALSE).} 53 | \item{\dots}{.} 54 | } 55 | \value{ 56 | A \code{\linkS4class{DCCroll}} object containing details of the DCC-GARCH 57 | rolling forecast. 58 | } 59 | \author{Alexios Galanos} 60 | \keyword{methods} 61 | -------------------------------------------------------------------------------- /man/dccsim-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{dccsim-methods} 2 | \docType{methods} 3 | \alias{dccsim} 4 | \alias{dccsim,ANY-method} 5 | \alias{dccsim,DCCspec-method} 6 | \alias{dccsim,DCCfit-method} 7 | \title{function: DCC-GARCH Simulation} 8 | \description{ 9 | Method for creating a DCC-GARCH simulation object. 10 | } 11 | \usage{ 12 | dccsim(fitORspec, n.sim = 1000, n.start = 0, m.sim = 1, 13 | startMethod = c("unconditional", "sample"), presigma = NULL, preresiduals = NULL, 14 | prereturns = NULL, preQ = NULL, preZ = NULL, Qbar = NULL, Nbar = NULL, 15 | rseed = NULL, mexsimdata = NULL, vexsimdata = NULL, cluster = NULL, 16 | VAR.fit = NULL, prerealized = NULL, ...) 17 | } 18 | \arguments{ 19 | \item{fitORspec}{ A \code{\linkS4class{DCCspec}} or \code{\linkS4class{DCCfit}} 20 | object created by calling either \code{\link{dccspec}} with fixed parameters 21 | or \code{\link{dccfit}}.} 22 | \item{n.sim}{ The simulation horizon.} 23 | \item{n.start}{ The burn-in sample.} 24 | \item{m.sim}{ The number of simulations.} 25 | \item{startMethod}{ Starting values for the simulation. Valid methods are 26 | \dQuote{unconditional} for the expected values given the density, and 27 | \dQuote{sample} for the ending values of the actual data from the fit 28 | object (for the dispatch method using a specification, \dQuote{sample} is 29 | not relevant).} 30 | \item{presigma}{ Allows the starting sigma values to be provided by the user 31 | for the univariate GARCH dynamics.} 32 | \item{prereturns}{ Allows the starting return data to be provided by the 33 | user for the conditional mean simulation.} 34 | \item{preresiduals}{ Allows the starting residuals to be provided by the 35 | user and used in the GARCH dynamics simulation.} 36 | \item{preQ}{ Allows the starting \sQuote{DCC-Q} value to be provided by the 37 | user and though unnecessary for the first 1-ahead simulation using the 38 | \dQuote{sample} option in the \code{startMethod}, this is key to obtaining 39 | a rolling n-ahead forecast type simulation (see details below).} 40 | \item{preZ}{ Allows the starting standardized residuals to be provided by 41 | the user and though unnecessary for the first 1-ahead simulation using 42 | the \dQuote{sample} option in the \code{startMethod}, this is key to 43 | obtaining a rolling n-ahead forecast type simulation (see details below).} 44 | \item{Qbar}{ The DCC dynamics unconditional Q matrix, required for the 45 | specification dispatch method.} 46 | \item{Nbar}{ The aDCC dynamics unconditional asymmetry matrix, required for 47 | the specification dispatch method.} 48 | \item{rseed}{ Optional seeding value(s) for the random number generator. 49 | For m.sim>1, it is possible to provide either a single seed to initialize 50 | all values, or one seed per separate simulation (i.e. m.sim seeds). However, 51 | in the latter case this may result in some slight overhead depending on 52 | how large m.sim is.} 53 | \item{mexsimdata}{ A list (equal to the number of asset) of matrices of 54 | simulated external regressor-in-mean data with row length equal to 55 | n.sim + n.start. If the fit object contains external regressors in the mean 56 | equation, this must be provided else will be assumed to be zero.} 57 | \item{vexsimdata}{ A list (equal to the number of asset) of matrices of 58 | simulated external regressor-in-variance data with row length equal to 59 | n.sim + n.start. If the fit object contains external regressors in the 60 | variance equation, this must be provided else will be assumed to be zero.} 61 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 62 | the parallel package. If it is not NULL, then this will be used for parallel 63 | estimation (remember to stop the cluster on completion).} 64 | \item{VAR.fit}{ An VAR.fit list returned from calling the 65 | \code{\link{varxfilter}} or \code{\link{varxfit}} function with \code{postpad} 66 | set to \dQuote{constant}. This is required for the specification dispatch 67 | method.} 68 | \item{prerealized}{Allows the starting realized volatility values to be provided 69 | by the user for the univariate GARCH dynamics.} 70 | \item{...}{.} 71 | } 72 | \value{ 73 | A \code{\linkS4class{DCCsim}} object containing details of the DCC-GARCH 74 | simulation. 75 | } 76 | \details{ 77 | In order to pass a correct specification to the filter routine, you must ensure 78 | that it contains the appropriate \sQuote{fixed.pars} in both the multivariate 79 | DCC part of the specification as well as the multiple univariate specification 80 | part, for which the method \code{\link{setfixed<-}} should be used. 81 | } 82 | \author{Alexios Galanos} 83 | \keyword{methods} 84 | -------------------------------------------------------------------------------- /man/dccspec-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{dccspec-methods} 2 | \docType{methods} 3 | \alias{dccspec} 4 | \alias{dccspec,ANY-method} 5 | \alias{dccspec,uGARCHmultispec-method} 6 | \title{function: DCC-GARCH Specification} 7 | \description{ 8 | Method for creating a DCC-GARCH specification object prior to fitting. 9 | } 10 | \usage{ 11 | dccspec(uspec, VAR = FALSE, robust = FALSE, lag = 1, lag.max = NULL, 12 | lag.criterion = c("AIC", "HQ", "SC", "FPE"), external.regressors = NULL, 13 | robust.control = list("gamma" = 0.25, "delta" = 0.01, "nc" = 10, "ns" = 500), 14 | dccOrder = c(1,1), model = c("DCC", "aDCC", "FDCC"), groups = rep(1, length(uspec@spec)), 15 | distribution = c("mvnorm", "mvt", "mvlaplace"), start.pars = list(), fixed.pars = list()) 16 | } 17 | \arguments{ 18 | \item{uspec}{ 19 | A \code{\linkS4class{uGARCHmultispec}} object created by calling 20 | \code{\link{multispec}} on a list of univariate GARCH specifications.} 21 | \item{VAR}{ Whether to fit a VAR model for the conditional mean.} 22 | \item{robust}{ Whether to use the robust version of VAR.} 23 | \item{lag}{ The VAR lag.} 24 | \item{lag.max}{ The maximum VAR lag to search for best fit.} 25 | \item{lag.criterion}{ The criterion to use for choosing the best lag when 26 | lag.max is not NULL.} 27 | \item{external.regressors}{ Allows for a matrix of common pre-lagged external 28 | regressors for the VAR option. 29 | } 30 | \item{robust.control}{ The tuning parameters to the robust regression 31 | including the proportion to trim (\dQuote{gamma}), the critical value for 32 | re-weighted estimator (\dQuote{delta}), the number of subsets (\dQuote{ns}) 33 | and the number of C-steps (\dQuote{nc}.} 34 | \item{dccOrder}{ The DCC autoregressive order.} 35 | \item{model}{ The DCC model to use, with a choice of the symmetric DCC, 36 | asymmetric (aDCC) and the Flexible DCC (FDCC). See notes for more details.} 37 | \item{groups}{ The groups corresponding to each asset in the FDCC model, where 38 | these are assumed and checked to be contiguous and increasing (unless only 1 group).} 39 | \item{distribution}{ The multivariate distribution. Currently the multivariate 40 | Normal, Student and Laplace are implemented, and only the Normal for the FDCC model.} 41 | \item{start.pars}{ (optional) Starting values for the DCC parameters (starting 42 | values for the univariate garch specification should be passed directly 43 | via the \sQuote{uspec} object).} 44 | \item{fixed.pars}{ (optional) Fixed DCC parameters. This is required in the 45 | \code{\link{dccfilter}}, \code{\link{dccforecast}}, \code{\link{dccsim}} with 46 | spec, and \code{\link{dccroll}} 47 | methods.} 48 | } 49 | \value{ 50 | A \code{\linkS4class{DCCspec}} object containing details of the DCC-GARCH 51 | specification. 52 | } 53 | \details{ 54 | The \code{robust} option allows for a robust version of VAR based on the 55 | multivariate Least Trimmed Squares Estimator described in Croux and Joossens 56 | (2008). 57 | } 58 | \note{ 59 | The FDCC model of Billio, Caporin and Gobbo (2006) allows different DCC 60 | parameters to govern the dynamics of the correlation of distinct groups. The 61 | drawback is a somewhat larger parameter set, and no correlation targeting. 62 | Still, it remains a feasible model for not too large a number of groups, and 63 | avoids the unrealistic assumption, particularly for large datasets, of one 64 | parameter governing all the dynamics, as in the DCC model. Note that the group 65 | indices must be increasing (unless all 1), which means that you should arrange 66 | your dataset so that the assets are ordered by their groups. 67 | } 68 | \references{ 69 | Billio, M., Caporin, M., & Gobbo, M. 2006, Flexible dynamic conditional 70 | correlation multivariate GARCH models for asset allocation, \emph{Applied 71 | Financial Economics Letters}, \bold{2(02)}, 123--130.\cr 72 | Croux, C. and Joossens, K. 2008, Robust estimation of the vector autoregressive 73 | model by a least trimmed squares procedure, \emph{COMPSTAT}, 489--501.\cr 74 | Cappiello, L., Engle, R.F. and Sheppard, K. 2006, Asymmetric dynamics in the 75 | correlations of global equity and bond returns, \emph{Journal of Financial 76 | Econometrics} \bold{4}, 537--572.\cr 77 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 78 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 79 | } 80 | \author{Alexios Galanos} 81 | \keyword{methods} 82 | -------------------------------------------------------------------------------- /man/dji30retw.Rd: -------------------------------------------------------------------------------- 1 | \name{dji30retw} 2 | \docType{data} 3 | \alias{dji30retw} 4 | \title{data: Dow Jones 30 Constituents Closing Value log Weekly Return} 5 | \description{ 6 | Dow Jones 30 Constituents closing value weekly (Friday) log returns from 7 | 1987-03-16 to 2009-02-03 from Yahoo Finance. Note that AIG was replaced by KFT 8 | (Kraft Foods) on September 22, 2008. This is not reflected in this data set as 9 | that would bring the starting date of the data to 2001. When data was not 10 | available for a Friday, the closest previous close for which data was available 11 | was used. 12 | } 13 | \usage{data(dji30retw)} 14 | \format{A data.frame containing 30x1141 observations.} 15 | \source{Yahoo Finance} 16 | \keyword{datasets} 17 | -------------------------------------------------------------------------------- /man/fMoments-class.Rd: -------------------------------------------------------------------------------- 1 | \name{fMoments-class} 2 | \docType{class} 3 | \alias{fMoments-class} 4 | \alias{show,fMoments-method} 5 | \alias{fitted,fMoments-method} 6 | \alias{rcov,fMoments-method} 7 | \alias{rcoskew,fMoments-method} 8 | \alias{rcokurt,fMoments-method} 9 | \title{Class \code{"fMoments"}} 10 | \description{ 11 | Object returned from calling \code{\link{fmoments}}. 12 | } 13 | \section{Objects from the Class}{ 14 | Objects can be created by calls of the form \code{new("fMoments", ...)}. 15 | } 16 | \section{Slots}{ 17 | \describe{ 18 | \item{\code{moments}:}{Object of class \code{"vector"} A list with the 19 | (roll+1) n-ahead forecast moment matrices.} 20 | \item{\code{model}:}{Object of class \code{"vector"} A list with details of 21 | data generating process.} 22 | } 23 | } 24 | \section{Methods}{ 25 | \describe{ 26 | \item{show}{\code{signature(object = "fMoments")}: Summary method. } 27 | \item{fitted}{\code{signature(object = "fMoments")}: Conditional mean 28 | forecast matrix. } 29 | \item{rcov}{\code{signature(object = "fMoments")}: Conditional covariance 30 | forecast array.} 31 | \item{rcoskew}{\code{signature(object = "fMoments")}: Conditional third 32 | co-moment array. } 33 | \item{rcokurt}{\code{signature(object = "fMoments")}: Conditional fourth 34 | co-moment array. } 35 | } 36 | } 37 | \author{Alexios Galanos} 38 | \examples{ 39 | showClass("fMoments") 40 | } 41 | \keyword{classes} 42 | -------------------------------------------------------------------------------- /man/fScenario-class.Rd: -------------------------------------------------------------------------------- 1 | \name{fScenario-class} 2 | \docType{class} 3 | \alias{fScenario-class} 4 | \alias{show,fScenario-method} 5 | \alias{goget,fScenario-method} 6 | \alias{goget,ANY-method} 7 | \alias{goget} 8 | \alias{fitted,fScenario-method} 9 | \title{Class \code{"fScenario"}} 10 | \description{ 11 | Object returned from calling \code{\link{fscenario}}. 12 | } 13 | \section{Objects from the Class}{ 14 | Objects can be created by calls of the form \code{new("fScenario", ...)}. 15 | } 16 | \section{Slots}{ 17 | \describe{ 18 | \item{\code{scenario}:}{Object of class \code{"vector"} A list with the 19 | (roll+1) scenario matrices.} 20 | \item{\code{model}:}{Object of class \code{"vector"} A list with details of 21 | data generating process.} 22 | } 23 | } 24 | \section{Methods}{ 25 | \describe{ 26 | \item{show}{\code{signature(object = "fScenario")}: Summary method. } 27 | \item{goget}{\code{signature(object = "fScenario")}: Get a specified 28 | \sQuote{arg} from the object (only \sQuote{scenario} used).} 29 | \item{fitted}{\code{signature(object = "fScenario")}: Returns an array 30 | of the simulated scenario returns, of dimensions n.sim by n.assets 31 | by (roll+1), with third dimension labels the actual forecast time index, 32 | and second dimension labels the asset names. The last forecast scenario 33 | will always be completely out of sample so the time index label for that 34 | is generated using the \code{generatefwd} function in the rugarch package.} 35 | } 36 | } 37 | \author{Alexios Galanos} 38 | \keyword{classes} 39 | -------------------------------------------------------------------------------- /man/fmoments-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{fmoments-methods} 2 | \docType{methods} 3 | \alias{fmoments} 4 | \alias{fmoments-methods} 5 | \alias{fmoments,ANY-method} 6 | \title{Moment Based Forecast Generation} 7 | \description{ 8 | Generates n-ahead forecast moment matrices given a choice of data generating 9 | processes. 10 | } 11 | \usage{ 12 | fmoments(spec, Data, n.ahead = 1, roll = 0, solver = "solnp", 13 | solver.control = list(), fit.control = list(eval.se = FALSE), 14 | cluster = NULL, save.output = FALSE, save.dir = getwd(), 15 | save.name = paste("M", sample(1:1000, 1), sep = ""), ...) 16 | } 17 | \arguments{ 18 | \item{Data}{ An n-by-m data matrix or data.frame.} 19 | \item{spec}{ Either a DCCspec or GOGARCHspec.} 20 | \item{n.ahead}{ The n.ahead forecasts (n.ahead>1 is unconditional).} 21 | \item{roll}{ Whether to fit the data using (n - roll) periods and then 22 | return a (roll+1) n-ahead rolling forecast moments.} 23 | 24 | \item{solver}{ The choice of solver to use for all models but \dQuote{var}, 25 | and includes \sQuote{solnp}, \sQuote{nlminb} and \sQuote{nloptr}.} 26 | \item{solver.control}{ Optional control options passed to the appropriate solver 27 | chosen.} 28 | \item{fit.control}{Control arguments passed to the fitting routine.} 29 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 30 | the parallel package. If it is not NULL, then this will be used for parallel 31 | estimation of the refits (remember to stop the cluster on completion).} 32 | \item{save.output}{ Whether output should be saved to file instead of being 33 | returned to the workspace.} 34 | \item{save.dir}{ The directory to save output if save.output is TRUE.} 35 | \item{save.name}{ The name of the file to save the output list.} 36 | \item{...}{ Additional parameters passed to the model fitting routines. In 37 | particular, for the \sQuote{gogarch} model additional parameters are passed to 38 | the ICA routines, whereas for the \sQuote{dcc} and \sQuote{cgarch} models 39 | this would include the \sQuote{realizedVol} xts matrix for the realGARCH model.} 40 | } 41 | \value{ 42 | A \code{\linkS4class{fMoments}} object containing the forecast moments 43 | (list of length roll+1) and the model details (list). 44 | } 45 | \details{ 46 | The function allows to generate forecast covariance matrices for use in the 47 | QP based EV model, and also for the \dQuote{gogarch} model higher co-moment 48 | matrices for use in the Utility maximization model implemented separately. 49 | } 50 | \author{Alexios Galanos} 51 | \keyword{methods} 52 | -------------------------------------------------------------------------------- /man/fscenario-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{fscenario-methods} 2 | \docType{methods} 3 | \alias{fscenario} 4 | \alias{fscenario-methods} 5 | \alias{fscenario,ANY-method} 6 | \title{Scenario Generation} 7 | \description{ 8 | Generates a 1-ahead forecast scenario given a choice of data generating 9 | processes (for use in stochastic programming or risk management). 10 | } 11 | \usage{ 12 | fscenario(Data, sim = 1000, roll = 0, 13 | model = c("gogarch", "dcc", "cgarch", "var", "mdist"), 14 | spec = NULL, 15 | var.model = list(lag = 1, lag.max = NULL, 16 | lag.criterion = c("AIC", "HQ", "SC", "FPE"), 17 | robust = FALSE, robust.control = list("gamma" = 0.25, 18 | "delta" = 0.01, "nc" = 10, "ns" = 500)), 19 | mdist.model = list(distribution = c("mvn", "mvt", "manig"), 20 | AR = TRUE, lag = 1), 21 | spd.control = list(lower = 0.1, upper = 0.9, type = "pwm", 22 | kernel = "epanech"), 23 | cov.method = c("ML", "LW", "EWMA", "MVE", "MCD", "MVT", "BS"), 24 | cov.options = list(shrinkage=-1, lambda = 0.96), 25 | solver = "solnp", solver.control = list(), 26 | fit.control = list(eval.se = FALSE), 27 | cluster = NULL, save.output = FALSE, save.dir = getwd(), 28 | save.name = paste("S", sample(1:1000, 1), sep = ""), rseed = NULL, ...) 29 | } 30 | \arguments{ 31 | \item{Data}{ An n-by-m data matrix or data.frame.} 32 | \item{sim}{ The size of the simulated 1-ahead forecast.} 33 | \item{roll}{ Whether to fit the data using (n - roll) periods and then 34 | return a (roll+1) 1-ahead rolling simulated scenarios.} 35 | \item{model}{ A choice of 5 models for generating scenarios.} 36 | \item{spec}{ Required if choosing \sQuote{gogarch}, \sQuote{dcc} or \sQuote{cgarch}, 37 | in which case this represents a specification object (see rmgarch package) .} 38 | \item{var.model}{ Required if model is var.} 39 | \item{mdist.model}{ Required if model is mdist, and provides details for the model 40 | estimation (not yet implemented).} 41 | \item{spd.control}{ Required if model is \dQuote{cgarch} and transformation is spd.} 42 | \item{cov.method}{ For model \dQuote{var} this represents the choice of 43 | covariance matrix to use to generate random deviates.} 44 | \item{cov.options}{ For model \dQuote{var} this provides the optional parameters 45 | to certain types of covariance estimation methods.} 46 | \item{solver}{ The choice of solver to use for all models but \dQuote{var}, 47 | and includes \sQuote{solnp}, \sQuote{nlminb} and \sQuote{nloptr}.} 48 | \item{solver.control}{ Optional control options passed to the appropriate solver 49 | chosen.} 50 | \item{fit.control}{Control arguments passed to the fitting routine.} 51 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 52 | the parallel package. If it is not NULL, then this will be used for parallel 53 | estimation of the refits (remember to stop the cluster on completion).} 54 | \item{save.output}{ Whether output should be saved to file instead of being 55 | returned to the workspace.} 56 | \item{save.dir}{ The directory to save output if save.output is TRUE.} 57 | \item{save.name}{ The name of the file to save the output list.} 58 | \item{rseed}{ A vector of length sim to initiate the random number generator.} 59 | \item{...}{ Additional parameters passed to the model fitting routines. In 60 | particular, for the \sQuote{gogarch} model additional parameters are passed to 61 | the ICA routines, whereas for the \sQuote{dcc} and \sQuote{cgarch} models 62 | this would include the \sQuote{realizedVol} xts matrix for the realGARCH model.} 63 | } 64 | \value{ 65 | A \code{\linkS4class{fScenario}} object containing the scenario and the model 66 | details (list). The scenario list contains a list of the 67 | (roll+1) simulated forecast scenarios, the list of (roll+1) simulated forecast 68 | residuals, the forecast conditional mean, the forecast covariance and the list 69 | of random generator seed values used for replication. In addition, for the 70 | gogarch model the ICA whitening (K) and rotation matrices are also returned 71 | and required for replication of results (these may be entered in the 72 | \sQuote{gogarchspec} function). Use the \code{fitted} method on the object to 73 | extract the simulated returns forecast. 74 | } 75 | \details{ 76 | The functionality here provides some wrapper functions, to create 1-ahead (and 77 | optionally rolling, useful for backtesting) scenarios for use in portfolio 78 | optimization using stochastic programming methods. The nature of these 79 | data generating processes (as implemented here) and resulting optimization 80 | problems results in the so called anticipative class of stochastic programming 81 | models. If save.output is chosen, and given a save.dir, the scenario is saved 82 | (using save.name) and an object is returned containing an empty list for the 83 | scenario but with a model details list and the seed values. This can then be 84 | passed on to the \code{goload} function which can read from the directory and 85 | return a complete object with the scenario. 86 | } 87 | \author{Alexios Galanos} 88 | \keyword{methods} 89 | -------------------------------------------------------------------------------- /man/goGARCHfft-class.Rd: -------------------------------------------------------------------------------- 1 | \name{goGARCHfft-class} 2 | \docType{class} 3 | \alias{goGARCHfft-class} 4 | \alias{dfft,goGARCHfft-method} 5 | \alias{dfft} 6 | \alias{pfft,goGARCHfft-method} 7 | \alias{pfft} 8 | \alias{qfft,goGARCHfft-method} 9 | \alias{qfft} 10 | \alias{nportmoments,goGARCHfft-method} 11 | \alias{nportmoments} 12 | \title{Class: GO-GARCH portfolio density} 13 | \description{Class for the GO-GARCH portfolio density} 14 | \section{Objects from the Class}{ 15 | The class is returned by calling the function \code{\link{convolution}} on 16 | objects of class \code{\linkS4class{goGARCHfit}}, \code{\linkS4class{goGARCHfilter}}, 17 | \code{\linkS4class{goGARCHforecast}}, \code{\linkS4class{goGARCHsim}} and 18 | \code{\linkS4class{goGARCHroll}} 19 | } 20 | \section{Slots}{ 21 | \describe{ 22 | \item{\code{dist}:}{ A list with the portfolio density and other details.} 23 | \item{\code{model}:}{ A list with the model details carried across objects.} 24 | } 25 | } 26 | \section{Methods}{ 27 | \describe{ 28 | \item{dfft}{\code{signature(object = "goGARCHfft")}: 29 | The takes additional argument \dQuote{index} to indicate the particular time 30 | point, and returns an interpolated density function which may be called like 31 | any other \dQuote{d} type density function. 32 | } 33 | \item{pfft}{\code{signature(object = "goGARCHfft")} 34 | The takes additional argument \dQuote{index} to indicate the particular time 35 | point, and returns an interpolated distribution function which may be called 36 | like any other \dQuote{p} type distribution function.} 37 | \item{qfft}{\code{signature(object = "goGARCHfft")} 38 | This takes additional argument \dQuote{index} to indicate the particular time 39 | point, and returns an interpolated quantile function which may be called like 40 | any other \dQuote{q} type quantile function. This may also be used to generate 41 | pseudo-random variables from the distribution by using random standard uniform 42 | numbers as inputs.} 43 | \item{nportmoments}{\code{signature(object = "goGARCHfft")}: 44 | Calculate and returns a matrix of the first 4 standardized moments by evaluation 45 | of the portfolio density using quadrature based method (i.e. calling R's 46 | \dQuote{integrate} function on the portfolio FFT based density). Depending on 47 | the GOGARCH class the density was based (e.g. goGARCHfit vs goGARCHforecast), 48 | the format of the output will be different, and generally follow the 49 | format \sQuote{rules} of that class.} 50 | } 51 | } 52 | \section{notes}{ 53 | In the case that \code{convolution} was called on a \code{\linkS4class{goGARCHforecast}} 54 | or \code{\linkS4class{goGARCHroll}} object, the \code{dist} slot will contain the max 55 | of n.ahead or n.roll. There should be no confusion here since the multivariate 56 | forecast methods in rmgarch only allow either n.ahead>1 with n.roll = 0 57 | (pure unconditional), or n.ahead = 1 with n.roll>=0 (pure rolling), and only the 58 | latter in the case of a \code{\link{gogarchroll}}. While the \code{nportmoments} 59 | method reconstitutes the forecasts into a more familiar form (n.ahead x n.moments x 60 | (n.roll+1)), this does not make sense for the distribution methods (d*, p*, 61 | and q*), and it is understood that when the user calls for example 62 | \code{dfft(object, index=5)} on an object created from a forecast with 63 | n.ahead=10 and n.roll=0, the index is meant to indicate the unconditional 64 | density forecast at time T+5. Similarly, when calling 65 | code{dfft(object, index=0)} on an object created from a forecast with 66 | n.ahead=1 and n.roll = 1 (remember that n.roll is zero based), the index is 67 | meant to indicate the first (of two, since rolls = 0:1) rolling forecast 68 | density. 69 | } 70 | \author{Alexios Galanos} 71 | \keyword{classes} 72 | -------------------------------------------------------------------------------- /man/goGARCHroll-class.Rd: -------------------------------------------------------------------------------- 1 | \name{goGARCHroll-class} 2 | \docType{class} 3 | \alias{goGARCHroll-class} 4 | \alias{fitted,goGARCHroll-method} 5 | \alias{sigma,goGARCHroll-method} 6 | \alias{rcor,goGARCHroll-method} 7 | \alias{rcov,goGARCHroll-method} 8 | \alias{rcoskew,goGARCHroll-method} 9 | \alias{rcokurt,goGARCHroll-method} 10 | \alias{convolution,goGARCHroll-method} 11 | \alias{gportmoments,goGARCHroll-method} 12 | \alias{coef,goGARCHroll-method} 13 | \title{class: GO-GARCH Roll Class} 14 | \description{Class for the GO-GARCH Roll.} 15 | \section{Objects from the Class}{ 16 | The class is returned by calling the function \code{\link{gogarchroll}}. 17 | } 18 | \section{Slots}{ 19 | \describe{ 20 | \item{\code{forecast}:}{Object of class \code{"vector"} which contains the 21 | rolling forecasts of the distributional parameters for each factor.} 22 | \item{\code{model}:}{Object of class \code{"vector"} containing details of the 23 | GOGARCH model specification.} 24 | } 25 | } 26 | \section{Extends}{ 27 | Class \code{"\linkS4class{mGARCHroll}"}, directly. 28 | Class \code{"\linkS4class{GARCHroll}"}, by class "mGARCHroll", distance 2. 29 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHroll", distance 3. 30 | } 31 | \section{Methods}{ 32 | \describe{ 33 | \item{coef}{\code{signature(object = "goGARCHroll")}: 34 | Extraction of independent factor GARCH model coefficients saved from the 35 | goGARCHfit objects(returns a list).} 36 | \item{fitted}{\code{signature(object = "goGARCHroll")}: 37 | Extracts the conditional fitted forecast values (returns an xts object with 38 | index the actual forecast T+1 times).} 39 | \item{sigma}{\code{signature(object = "goGARCHroll")}: 40 | Extracts the conditional sigma forecast values (returns an xts object with 41 | index the actual forecast T+1 times). Takes optional argument \dQuote{factors} 42 | (default TRUE) denoting whether to return the factor conditional sigma or 43 | the transformed sigma for the assets.} 44 | \item{rcov}{\code{signature(object = "goGARCHroll")}: 45 | Returns the time-varying n.asset x n.asset x (n.roll+1) covariance matrix in 46 | array format, where the third dimension labels are now the actual rolling 47 | n.ahead=1 forecast time indices (T+1). A further argument \sQuote{output} allows 48 | to switch between \dQuote{array} and \dQuote{matrix} returned object.} 49 | \item{rcor}{\code{signature(object = "goGARCHroll")}: 50 | Returns the time-varying n.asset x n.asset x (n.roll+1) correlation matrix 51 | in array format, where the third dimension labels are now the actual rolling 52 | n.ahead=1 forecast time indices (T+1). A further argument \sQuote{output} 53 | allows to switch between \dQuote{array} and \dQuote{matrix} returned object.} 54 | \item{rcoskew}{\code{signature(object = "goGARCHroll")}: 55 | Returns the time-varying n.asset x n.asset^2 x (n.roll+1) coskewness matrix 56 | in array format, where the third dimension labels are now the actual rolling 57 | n.ahead=1 forecast time indices (T+1). There is a \dQuote{standardize} 58 | option which indicates whether the coskewness should be standardized by the 59 | conditional sigma (see equations in vignette).} 60 | \item{rcokurt}{\code{signature(object = "goGARCHroll")}: 61 | Returns the time-varying n.asset x n.asset^3 x (n.roll+1) cokurtosis matrix 62 | in array format, where the third dimension labels are now the actual rolling 63 | n.ahead=1 forecast time indices (T+1). There is a \dQuote{standardize} 64 | option which indicates whether the cokurtosis should be standardized by the 65 | conditional sigma (see equations in vignette).} 66 | \item{gportmoments}{\code{signature(object = "goGARCHroll")}:\cr 67 | function:\cr 68 | \bold{gportmoments(object, weights)}\cr 69 | Calculates the first 4 standardized portfolio moments using the geometric 70 | properties of the model, given a matrix of asset weights with row dimension 71 | equal to the total rolling forecast horizon. Returns an xts object of 72 | dimensions (total rolling forecast) x 4 (moments), with the index denoting 73 | the T+1 actual forecast time. If the number of assets > 100, then the 74 | kurtosis is not returned (see cokurtosis restrictions below).} 75 | \item{convolution}{\code{signature(object = "goGARCHroll")}:\cr 76 | function:\cr 77 | \bold{convolution(object, weights, fft.step = 0.001, fft.by = 0.0001, 78 | fft.support = c(-1, 1), support.method = c("user", "adaptive"), 79 | use.ff = TRUE, cluster = NULL, trace = 0,...)}\cr 80 | The convolution method takes a goGARCHroll object and a weights vector or 81 | matrix and calculates the weighted density. If a vector is given, it must be 82 | the same length as the number of assets, otherwise a matrix with 83 | row dimension equal to the row dimension of total forecast horizon. 84 | In the case of the multivariate normal distribution, this simply returns the 85 | linear and quadratic transformation of the mean and covariance matrix, while 86 | in the multivariate affine NIG distribution this is based on the numerical 87 | inversion by FFT of the characteristic function. In that case, the 88 | \dQuote{fft.step} option determines the stepsize for tuning the 89 | characteristic function inversion, \dQuote{fft.by} determines the resolution 90 | for the equally spaced support given by \dQuote{fft.support}, while the use 91 | of the \dQuote{ff} package is recommended to avoid memory problems on some 92 | systems and is turned on via the \dQuote{use.ff} option. 93 | The \dQuote{support.method} option allows either a fixed support range to be 94 | given (option \sQuote{user}), else an adaptive method is used based on the 95 | min and max of the assets at each point in time at the 0.00001 and 1-0.00001 96 | quantiles. The range is equally spaced subject to the \dQuote{fft.by} value 97 | but the returned object no longer makes of the \dQuote{ff} package returning 98 | instead a list. The option for parallel computation is available 99 | via the use of a cluster object as elsewhere in this package. Passing this 100 | object to the distribution methods (e.g. qfft) follows the same rules as 101 | the goGARCHforecast object, namely that the index is zero based.} 102 | \item{show}{\code{signature(object = "goGARCHroll")}: Summary. } 103 | } 104 | } 105 | \author{Alexios Galanos} 106 | \keyword{classes} 107 | -------------------------------------------------------------------------------- /man/goGARCHsim-class.Rd: -------------------------------------------------------------------------------- 1 | \name{goGARCHsim-class} 2 | \docType{class} 3 | \alias{goGARCHsim-class} 4 | \alias{convolution,goGARCHsim-method} 5 | \alias{gportmoments,goGARCHsim-method} 6 | \alias{rcor,goGARCHsim-method} 7 | \alias{rcoskew,goGARCHsim-method} 8 | \alias{rcokurt,goGARCHsim-method} 9 | \alias{rcov,goGARCHsim-method} 10 | \alias{as.matrix,goGARCHsim-method} 11 | \title{class: GO-GARCH Simultion Class} 12 | \description{Class for the GO-GARCH Simulation.} 13 | \section{Objects from the Class}{ 14 | The class is returned by calling the function \code{\link{gogarchsim}}. 15 | } 16 | \section{Slots}{ 17 | \describe{ 18 | \item{\code{msim}:}{Object of class \code{"vector"} The multivariate 19 | simulation list.} 20 | \item{\code{model}:}{Object of class \code{"vector"} containing details of the 21 | GOGARCH model specification.} 22 | } 23 | } 24 | \section{Extends}{ 25 | Class \code{"\linkS4class{mGARCHsim}"}, directly. 26 | Class \code{"\linkS4class{GARCHsim}"}, by class "mGARCHsim", distance 2. 27 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHsim", distance 3. 28 | } 29 | \section{Methods}{ 30 | \describe{ 31 | \item{convolution}{\code{signature(object = "goGARCHsim")}:\cr 32 | function:\cr 33 | \bold{convolution(object, weights, fft.step = 0.001, fft.by = 0.0001, 34 | fft.support = c(-1, 1), support.method = c("user", "adaptive"), 35 | use.ff = TRUE, sim = 1, cluster = NULL, trace = 0,...)}\cr 36 | The convolution method takes a goGARCHsim object and a weights vector and 37 | calculates the weighted density. The vector must be the same length as the 38 | number of assets. 39 | The \dQuote{sim} option indicates the simulation index to use, given 40 | the \dQuote{m.sim} option chosen in the call to the simulation function. 41 | In the case of the multivariate normal distribution, this simply returns the 42 | linear and quadratic transformation of the mean and covariance matrix, 43 | while in the multivariate affine NIG distribution this is based on the 44 | numerical inversion by FFT of the characteristic function. In that case, 45 | the \dQuote{fft.step} option determines the stepsize for tuning the 46 | characteristic function inversion, \dQuote{fft.by} determines the resolution 47 | for the equally spaced support given by \dQuote{fft.support}, while the use 48 | of the \dQuote{ff} package is recommended to avoid memory problems on some 49 | systems and is turned on via the \dQuote{use.ff} option. The \dQuote{support.method} 50 | option allows either a fixed support range to be given (option \sQuote{user}), 51 | else an adaptive method is used based on the min and max of the assets at 52 | each point in time at the 0.00001 and 1-0.00001 quantiles. The range is 53 | equally spaced subject to the \dQuote{fft.by} value but the returned object no 54 | longer makes use of the \dQuote{ff} package returning instead a list. 55 | Finally, the option for parallel computation is available via the use of a 56 | cluster object as elsewhere in this package.} 57 | \item{gportmoments}{\code{signature(object = "goGARCHsim")}:\cr 58 | function:\cr 59 | \bold{gportmoments(object, weights, sim = 1)}\cr 60 | Calculates the first 3 portfolio moments using the geometric properties of 61 | the model, given a matrix of asset weights with row dimension equal to the 62 | row dimension of the filtered dataset (i.e. less any lags). 63 | The \dQuote{sim} option indicates the simulation index to use, 64 | given the \dQuote{m.sim} option chosen in the call to the simulation function. 65 | } 66 | \item{rcoskew}{\code{signature(object = "goGARCHsim")}:\cr 67 | function:\cr 68 | \bold{rcoskew(object, from = 1, to = 1, sim = 1)}\cr 69 | Returns the 'time-varying' NxN^2 coskewness tensor in array format. 70 | The \dQuote{from} and \dQuote{to} options indicate the time indices for 71 | which to return the arrays. Because of memory issues, this is limited to 100 72 | indices. The \dQuote{sim} option indicates the simulation index to use, 73 | given the \dQuote{m.sim} option chosen in the call to the simulation 74 | function.} 75 | \item{rcokurt}{\code{signature(object = "goGARCHsim")}:\cr 76 | function:\cr 77 | \bold{rcokurt(object, standardize = TRUE, from = 1, to = 1)}\cr 78 | Returns the 'time-varying' NxN^3 cokurtosis tensor in array format. The 79 | \dQuote{from} and \dQuote{to} options indicate the time indices for which 80 | to return the arrays. Because of memory issues, this is limited to models 81 | with less than 20 assets.} 82 | \item{rcov}{\code{signature(object = "goGARCHsim")}: 83 | Returns the time-varying NxN covariance matrix in array format. There is an 84 | additional \dQuote{sim} option which indicates the simulation index to 85 | use, given the \dQuote{m.sim} option chosen in the call to the simulation 86 | function. A further argument \sQuote{output} allows to switch between 87 | \dQuote{array} and \dQuote{matrix} returned object.} 88 | \item{rcor}{\code{signature(object = "goGARCHsim")}: 89 | Returns the time-varying NxN correlation matrix in array format. 90 | There is an additional \dQuote{sim} option which indicates the simulation 91 | index to use, given the \dQuote{m.sim} option chosen in the call to the 92 | simulation function. A further argument \sQuote{output} allows to switch 93 | between \dQuote{array} and \dQuote{matrix} returned object.} 94 | \item{as.matrix}{\code{signature(x = "goGARCHsim")}:\cr 95 | function:\cr 96 | \bold{as.matrix(x, which = "A")}\cr 97 | This returns four types of matrices relating to the estimation of the 98 | independent components in the GO-GARCH model. Valid choices are \dQuote{A} 99 | for the mixing matrix, \dQuote{W} for the unmixing matrix, \dQuote{U} for the 100 | rotational matrix and \dQuote{K} for the whitening matrix, \dQuote{Kinv} for 101 | the de-whitening matrix.} 102 | } 103 | } 104 | \author{Alexios Galanos} 105 | \keyword{classes} 106 | -------------------------------------------------------------------------------- /man/goGARCHspec-class.Rd: -------------------------------------------------------------------------------- 1 | \name{goGARCHspec-class} 2 | \docType{class} 3 | \alias{goGARCHspec-class} 4 | \alias{show,goGARCHspec-method} 5 | \title{class: GO-GARCH Specification Class} 6 | \description{Class for the GO-GARCH specification.} 7 | \section{Objects from the Class}{ 8 | The class is returned by calling the function \code{\linkS4class{goGARCHspec}}. 9 | } 10 | \section{Slots}{ 11 | \describe{ 12 | \item{\code{model}:}{ Multivariate model specification.} 13 | \item{\code{umodel}:}{ Univariate model specification.} 14 | } 15 | } 16 | \section{Extends}{ 17 | Class \code{"\linkS4class{mGARCHspec}"}, directly. 18 | Class \code{"\linkS4class{GARCHspec}"}, by class "mGARCHspec", distance 2. 19 | Class \code{"\linkS4class{rGARCH}"}, by class "mGARCHspec", distance 3. 20 | } 21 | \section{Methods}{ 22 | \describe{ 23 | \item{show}{\code{signature(object = "goGARCHspec")}: Summary method. } 24 | } 25 | } 26 | \references{ 27 | van der Weide, R. 2002, GO-GARCH: a multivariate generalized orthogonal GARCH 28 | model, \emph{Journal of Applied Econometrics}, 549--564.\cr 29 | Zhang, K. and Chan, L. 2009, Efficient factor GARCH models and factor-DCC models, 30 | \emph{Quantitative Finance}, 71--91.\cr 31 | Broda, S.A. and Paolella, M.S. 2009, CHICAGO: A Fast and Accurate Method for 32 | Portfolio Risk Calculation, \emph{Journal of Financial Econometrics}, 412--436.\cr 33 | Ghalanos, A. and Rossi, E. and Urga, G. 2011, Independent Factor Autoregressive 34 | Conditional Density Model, \emph{Pending--submitted}. 35 | } 36 | \author{Alexios Galanos} 37 | \note{ 38 | The mixing matrix in the GO-GARCH model implemented in the rmgarch package is 39 | based on non-parametric independent component analysis (ICA) methodology. 40 | The estimation is a 2-stage methodology described in Broda and Paolella (2009) 41 | and Zhang and Chan (2009). The extension to the use of the full multivariate 42 | affine GH distribution is detailed in Ghalanos et al (2011). 43 | } 44 | \keyword{classes} 45 | -------------------------------------------------------------------------------- /man/gogarchfilter-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{gogarchfilter-methods} 2 | \docType{methods} 3 | \alias{gogarchfilter} 4 | \alias{gogarchfilter,ANY-method} 5 | \alias{gogarchfilter,goGARCHfit-method} 6 | \title{function: GO-GARCH Filter} 7 | \description{ 8 | Method for filtering the GO-GARCH model. 9 | } 10 | \usage{ 11 | gogarchfilter(fit, data, out.sample = 0, n.old = NULL, cluster = NULL, ...) 12 | } 13 | \arguments{ 14 | \item{fit}{ 15 | A GO-GARCH fit object of class \code{\linkS4class{goGARCHfit}}.} 16 | \item{data}{ 17 | A multivariate data object. Can be a matrix or data.frame or timeSeries.} 18 | \item{out.sample}{ 19 | A positive integer indicating the number of periods before the last to keep for 20 | out of sample forecasting.} 21 | \item{n.old}{ 22 | For comparison with goGARCHfit models using the out.sample argument, this is the 23 | length of the original dataset.} 24 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 25 | the parallel package. If it is not NULL, then this will be used for parallel 26 | estimation (remember to stop the cluster on completion).} 27 | \item{...}{.} 28 | } 29 | \value{ 30 | A \code{\linkS4class{goGARCHfilter}} object containing details of the GO-GARCH 31 | filter. 32 | } 33 | \author{Alexios Galanos} 34 | \examples{ 35 | \dontrun{ 36 | data(dji30ret) 37 | spec = gogarchspec() 38 | fit = gogarchfit(spec = spec, data = dji30ret[,1:4], gfun = "tanh") 39 | filter = gogarchfilter(fit, data = dji30ret[,1:4]) 40 | }} 41 | \keyword{methods} 42 | -------------------------------------------------------------------------------- /man/gogarchfit-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{gogarchfit-methods} 2 | \docType{methods} 3 | \alias{gogarchfit} 4 | \alias{gogarchfit,ANY-method} 5 | \alias{gogarchfit,goGARCHspec-method} 6 | \title{function: GO-GARCH Filter} 7 | \description{ 8 | Method for filtering the GO-GARCH model. 9 | } 10 | \usage{ 11 | gogarchfit(spec, data, out.sample = 0, solver = "solnp", 12 | fit.control = list(stationarity = 1), solver.control = list(), cluster = NULL, 13 | VAR.fit = NULL, ARcoef = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{spec}{ 17 | A GO-GARCH spec object of class \code{\linkS4class{goGARCHspec}}.} 18 | \item{data}{ 19 | A multivariate data object. Can be a matrix or data.frame or timeSeries.} 20 | \item{out.sample}{ 21 | A positive integer indicating the number of periods before the last to keep for 22 | out of sample forecasting.} 23 | \item{solver}{ 24 | One of either \dQuote{nlminb}, \dQuote{solnp} or \dQuote{gosolnp}. } 25 | \item{solver.control}{ 26 | Control arguments list passed to optimizer.} 27 | \item{fit.control}{ 28 | Control arguments passed to the fitting routine. Stationarity explicitly imposes 29 | the variance stationarity constraint during optimization.} 30 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 31 | the parallel package. If it is not NULL, then this will be used for parallel 32 | estimation (remember to stop the cluster on completion).} 33 | \item{VAR.fit}{ 34 | (optional) A previously estimated VAR list returned from calling the 35 | \code{\link{varxfilter}} function.} 36 | \item{ARcoef}{ 37 | An optional named matrix of the fitted AR parameters obtained from calling the 38 | \code{arfimafit} function on each series and then extracting the coefficients 39 | (the normal distribution should be used for the AR estimation). The number of 40 | columns should be equal to the number of series, and the rows should include the 41 | AR coefficients (common lag for all series), \sQuote{sigma}, and if included the 42 | mean (\sQuote{mu}). The option to pass the coefficients directly rather than 43 | letting the function estimate them may be useful for example when there are 44 | convergence problems in the arfima routine and user control of each series 45 | estimation is desirable. 46 | } 47 | \item{...}{ 48 | Additional arguments passed to the ICA functions.} 49 | } 50 | \value{ 51 | A \code{\linkS4class{goGARCHfit}} object containing details of the GO-GARCH fit. 52 | } 53 | \note{ 54 | There is no check on the VAR.fit list passed to the method so particular care 55 | should be exercised so that the same data used in the fitting routine is also 56 | used in the VAR filter routine. The ability to pass this list of the 57 | pre-calculated VAR model is particularly useful when comparing different models 58 | (such as copula GARCH, DCC GARCH etc) using the same dataset and VAR method. 59 | Though the classical VAR estimation is very fast and may not require this extra 60 | step, the robust method is slow and therefore benefits from calculating this 61 | only once. 62 | } 63 | \author{Alexios Galanos} 64 | \examples{ 65 | \dontrun{ 66 | data(dji30ret) 67 | spec = gogarchspec(mean.model = list(demean = "constant"), 68 | variance.model = list(model = "sGARCH", garchOrder = c(1,1), submodel = NULL), 69 | distribution.model = list(distribution = "manig"),ica = "fastica") 70 | 71 | fit = gogarchfit(spec = spec, data = dji30ret[,1:4, drop = FALSE], 72 | out.sample = 50, gfun = "tanh") 73 | fit 74 | }} 75 | \keyword{methods} 76 | -------------------------------------------------------------------------------- /man/gogarchforecast-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{gogarchforecast-methods} 2 | \docType{methods} 3 | \alias{gogarchforecast} 4 | \alias{gogarchforecast-methods} 5 | \alias{gogarchforecast,ANY-method} 6 | \alias{gogarchforecast,goGARCHfit-method} 7 | \title{function: GO-GARCH Forecast} 8 | \description{ 9 | Method for forecasting from the GO-GARCH model. 10 | } 11 | \usage{ 12 | gogarchforecast(fit, n.ahead = 10, n.roll = 0, 13 | external.forecasts = list(mregfor = NULL), cluster = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{fit}{ 17 | A GO-GARCH fit object of class \code{\linkS4class{goGARCHfit}}.} 18 | \item{n.ahead}{ 19 | The forecast horizon.} 20 | \item{n.roll}{ 21 | The no. of rolling forecasts to create beyond the first one.} 22 | \item{external.forecasts}{ 23 | A list with a matrix object of the external lagged forecasts (if used). These 24 | must contain (n.roll+1) x n.ahead forecasts. } 25 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 26 | the parallel package. If it is not NULL, then this will be used for parallel 27 | estimation (remember to stop the cluster on completion).} 28 | \item{...}{.} 29 | } 30 | \value{ 31 | A \code{\linkS4class{goGARCHforecast}} object containing details of the GO-GARCH 32 | forecast. 33 | } 34 | \author{Alexios Galanos} 35 | \examples{ 36 | \dontrun{ 37 | data(dji30ret) 38 | spec = gogarchspec() 39 | fit = gogarchfit(spec = spec, data = dji30ret[,1:4], out.sample = 10, 40 | gfun = "tanh") 41 | forecast = gogarchforecast(fit, n.ahead = 1, n.roll = 9) 42 | }} 43 | \keyword{methods} 44 | -------------------------------------------------------------------------------- /man/gogarchroll-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{gogarchroll-methods} 2 | \alias{gogarchroll} 3 | \alias{gogarchroll,ANY-method} 4 | \alias{gogarchroll,goGARCHspec-method} 5 | \title{function: GO-GARCH Rolling Estimation} 6 | \description{ 7 | Method for performing rolling estimation of the GO-GARCH model. 8 | } 9 | \usage{ 10 | gogarchroll(spec, data, n.ahead = 1, forecast.length = 50, n.start = NULL, 11 | refit.every = 25, refit.window = c("recursive", "moving"), window.size = NULL, 12 | solver = "solnp", solver.control = list(), fit.control = list(), rseed = NULL, 13 | cluster = NULL, save.fit = FALSE, save.wdir = NULL, ...) 14 | } 15 | \arguments{ 16 | \item{spec}{ 17 | A GO-GARCH spec object of class \code{\linkS4class{goGARCHspec}}.} 18 | \item{data}{ 19 | A multivariate data object. Can be a matrix or data.frame or timeSeries. } 20 | \item{n.ahead}{ 21 | The forecast horizon (only 1-ahead supported for rolling forecasts). } 22 | \item{forecast.length}{ 23 | The length of the total forecast for which out of sample data from the dataset 24 | will be excluded for testing. } 25 | \item{n.start}{ Instead of forecast.length, this determines the starting 26 | point in the dataset from which to initialize the rolling forecast.} 27 | \item{refit.every}{ 28 | Determines every how many periods the model is re-estimated. } 29 | \item{refit.window}{ 30 | Whether the refit is done on an expanding window including all the previous data 31 | or a moving window where all previous data is used for the first estimation 32 | and then moved by a length equal to refit.every (unless the window.size option 33 | is used instead). 34 | } 35 | \item{window.size}{ 36 | If not NULL, determines the size of the moving window in the rolling estimation, 37 | which also determines the first point used. 38 | } 39 | \item{solver}{ 40 | The solver to use. } 41 | \item{fit.control}{ 42 | Control parameters parameters passed to the fitting function. } 43 | \item{solver.control}{ 44 | Control parameters passed to the solver. } 45 | \item{rseed}{ 46 | Initialization seed for first ICA fit. The rest of the ICA fits are initialized 47 | with the previous mixing matrix (using A.init). } 48 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 49 | the parallel package. If it is not NULL, then this will be used for parallel 50 | estimation (remember to stop the cluster on completion).} 51 | \item{save.fit}{ 52 | Whether to save the fitted objects of class \code{\linkS4class{goGARCHfit}} 53 | during the estimation of each (\dQuote{refit.every}). If true, the directory to 54 | save must be provided (see below). The function will not save this by default 55 | for reasons of memory management, but can save it as an \dQuote{.rda} file in 56 | the user's chosen directory for further analysis.} 57 | \item{save.wdir}{ 58 | If \dQuote{save.fit} is true, the directory in which to save the 59 | \code{\linkS4class{goGARCHfit}} objects (1 for each \dQuote{refit.every}).} 60 | \item{\dots}{.} 61 | } 62 | \value{ 63 | An object of class \code{\linkS4class{goGARCHroll}}. 64 | } 65 | \author{Alexios Galanos} 66 | \keyword{methods} 67 | -------------------------------------------------------------------------------- /man/gogarchsim-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{gogarchsim-methods} 2 | \docType{methods} 3 | \alias{gogarchsim} 4 | \alias{gogarchsim,ANY-method} 5 | \alias{gogarchsim,goGARCHfit-method} 6 | \alias{gogarchsim,goGARCHfilter-method} 7 | \title{function: GO-GARCH Simulation} 8 | \description{ 9 | Method for simulation from a fitted GO-GARCH model. 10 | } 11 | \usage{ 12 | gogarchsim(object, n.sim = 1, n.start = 0, m.sim = 1, 13 | startMethod = c("unconditional", "sample"), prereturns = NA, preresiduals = NA, 14 | presigma = NA, mexsimdata = NULL, rseed = NULL, cluster = NULL, ...) 15 | } 16 | \arguments{ 17 | \item{object}{ 18 | A GO-GARCH fit object of class \code{\linkS4class{goGARCHfit}} or \code{\linkS4class{goGARCHfilter}}.} 19 | \item{n.sim}{ 20 | The simulation horizon.} 21 | \item{n.start}{ 22 | The burn-in sample.} 23 | \item{m.sim}{ 24 | The number of simulations.} 25 | \item{startMethod}{ 26 | Starting values for the simulation. Valid methods are \dQuote{unconditional} 27 | for the expected values given the density, and \dQuote{sample} for the 28 | ending values of the actual data from the fit object.} 29 | \item{prereturns}{ 30 | Allows the starting return data to be provided by the user.} 31 | \item{preresiduals}{ 32 | Allows the starting factor residuals to be provided by the user.} 33 | \item{presigma}{ 34 | Allows the starting conditional factor sigma to be provided by the user.} 35 | \item{mexsimdata}{ 36 | A list of matrices with the simulated lagged external variables (if any). The 37 | list should be of size m.sim and the matrices each have n.sim + n.start rows.} 38 | \item{rseed}{ 39 | Optional seeding value(s) for the random number generator.} 40 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 41 | the parallel package. If it is not NULL, then this will be used for parallel 42 | estimation (remember to stop the cluster on completion).} 43 | \item{\dots}{.} 44 | } 45 | \value{ 46 | A \code{\linkS4class{goGARCHsim}} object containing details of the GO-GARCH 47 | simulation. 48 | } 49 | \author{Alexios Galanos} 50 | \keyword{methods} 51 | -------------------------------------------------------------------------------- /man/gogarchspec-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{gogarchspec-methods} 2 | \alias{gogarchspec} 3 | \alias{gogarchspec-methods} 4 | \alias{gogarchspec,ANY-method} 5 | \title{function: GO-GARCH Specification} 6 | \description{ 7 | Method for creating a GO-GARCH specification object prior to fitting. 8 | } 9 | \usage{ 10 | gogarchspec(mean.model = list(model = c("constant", "AR", "VAR"), robust = FALSE, 11 | lag = 1, lag.max = NULL, lag.criterion = c("AIC", "HQ", "SC", "FPE"), 12 | external.regressors = NULL, 13 | robust.control = list("gamma" = 0.25, "delta" = 0.01, "nc" = 10, "ns" = 500)), 14 | variance.model = list(model = "sGARCH", garchOrder = c(1,1), submodel = NULL, 15 | variance.targeting = FALSE), distribution.model = c("mvnorm", "manig", "magh"), 16 | ica = c("fastica", "radical"), 17 | ica.fix = list(A = NULL, K = NULL), ...) 18 | } 19 | \arguments{ 20 | \item{mean.model}{ 21 | The mean specification. Allows for either a constant filtration of the return 22 | series, a univariate AR for each series with common lag (via the \dQuote{lag} 23 | argument) else a classical or robust Vector Autoregressive Model (VAR). The 24 | \sQuote{robust} option allows for a robust version of VAR based on the 25 | multivariate Least Trimmed Squares Estimator described in Croux and 26 | Joossens (2008). The \sQuote{robust.control} includes additional tuning 27 | parameters to the robust regression including the proportion to 28 | trim (\dQuote{gamma}), the critical value for Reweighted estimator (\dQuote{delta}), 29 | the number of subsets (\dQuote{ns}) and the number of C-steps (\dQuote{nc}). 30 | The external.regressors argument allows for a matrix of common external 31 | regressors in the constant, AR or VAR formulations. 32 | } 33 | \item{variance.model}{ 34 | The univariate variance specification for the independent factors of the 35 | GO-GARCH model. 36 | } 37 | \item{distribution.model}{ 38 | The distributions supported are the multivariate normal (\dQuote{mvnorm}) and 39 | the multivariate affine NIG (\dQuote{manig}) and GHYP (\dQuote{magh}) 40 | distributions of Schmidt et al (see references). 41 | } 42 | \item{ica}{ 43 | The algorithm to use for extracting the independent components. 44 | The \code{\link{fastica}} and \code{\link{radical}} algorithms are the only 45 | ICA algorithms currently allowed and locally implemented. See their 46 | documentation for a list of additional arguments possible, which may be passed 47 | in the \code{\link{gogarchfit}} method. 48 | } 49 | \item{ica.fix}{ 50 | This allows the option of supplying the mixing matrix (A) and optionally the 51 | whitening Matrix (K). This is likely to be use when comparing different models 52 | (with the same mean filtration and dataset but different variance models) and 53 | you wish to use the same independent factors. 54 | } 55 | \item{\dots}{.} 56 | } 57 | \value{ 58 | A \code{\linkS4class{goGARCHspec}} object containing details of the GO-GARCH 59 | specification. 60 | } 61 | \author{Alexios Galanos} 62 | \keyword{methods} 63 | -------------------------------------------------------------------------------- /man/goload-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{goload-methods} 2 | \docType{methods} 3 | \alias{goload} 4 | \alias{goload-methods} 5 | \alias{goload,ANY-method} 6 | \alias{goload,fScenario-method} 7 | \alias{goload,fMoments-method} 8 | 9 | \title{Load Scenario from File} 10 | \description{ 11 | Loads a previously saved fScenario from file and returns 12 | a \code{\linkS4class{fScenario}} or \code{\linkS4class{fMoments}} object. 13 | } 14 | \usage{ 15 | goload(object, ...) 16 | } 17 | \arguments{ 18 | \item{object}{ A \code{\linkS4class{fScenario}} or \code{\linkS4class{fMoments}} 19 | object which was created with save.output set to TRUE.} 20 | \item{...}{ not used.} 21 | } 22 | \value{ 23 | A \code{\linkS4class{fScenario}} or \code{\linkS4class{fMoments}} object with 24 | the scenario or moments slot now filled with the saved data from file. 25 | } 26 | \details{ 27 | There are times when it is more efficient to save large scenarios to file 28 | (particularly when creating them in parallel), rather than returning them to the 29 | user workspace. The save.output option in the \code{\link{fscenario}} and 30 | \code{\link{fmoments}} allows to do just that, returning instead a lighter 31 | object with an empty scenario slot, but with the model slot included, containing 32 | the details of the location and name of the saved scenario (or moments list). 33 | The goload function then takes this object, reads the location and name and 34 | loads the scenario (or moments) into its slot in the object and returns 35 | this to the user's workspace. 36 | } 37 | \author{Alexios Galanos} 38 | \keyword{methods} 39 | -------------------------------------------------------------------------------- /man/last-methods.Rd: -------------------------------------------------------------------------------- 1 | \name{last-methods} 2 | \docType{methods} 3 | \alias{last-methods} 4 | \alias{last,ANY-method} 5 | \alias{last,array-method} 6 | \alias{first-methods} 7 | \alias{first,ANY-method} 8 | \alias{first,array-method} 9 | \alias{first} 10 | \alias{last} 11 | \title{First and Last methods for accessing objects} 12 | \description{ 13 | Functions for accessing first-n and last-n values of an object 14 | (similar to head and tail). 15 | } 16 | \usage{ 17 | last(x, index = 1, ...) 18 | first(x, index = 1, ...) 19 | } 20 | \arguments{ 21 | \item{x}{ Currently only arrays supported.} 22 | \item{index}{ First or Last n-indices to return values for.} 23 | \item{...}{ For expansion to other classes.} 24 | } 25 | \section{Methods}{ 26 | \describe{ 27 | \item{\code{signature(x = "ANY")}}{} 28 | \item{\code{signature(x = "array")}}{} 29 | }} 30 | \author{Alexios Galanos} 31 | \keyword{methods} 32 | -------------------------------------------------------------------------------- /man/mGARCHfilter-class.Rd: -------------------------------------------------------------------------------- 1 | \name{mGARCHfilter-class} 2 | \Rdversion{1.1} 3 | \docType{class} 4 | \alias{mGARCHfilter-class} 5 | 6 | \title{Class: Multivariate GARCH Filter Class} 7 | \description{High Level multivariate GARCH filter class.} 8 | \section{Objects from the Class}{A virtual Class: No objects may be created from 9 | it.} 10 | \section{Extends}{ 11 | Class \code{"\linkS4class{GARCHfilter}"}, directly. 12 | Class \code{"\linkS4class{rGARCH}"}, by class "GARCHfilter", distance 2. 13 | } 14 | \section{Methods}{ 15 | No methods defined with class "mGARCHfilter" in the signature. 16 | } 17 | \author{Alexios Galanos} 18 | \keyword{classes} 19 | -------------------------------------------------------------------------------- /man/mGARCHfit-class.Rd: -------------------------------------------------------------------------------- 1 | \name{mGARCHfit-class} 2 | \docType{class} 3 | \alias{mGARCHfit-class} 4 | \title{Class: Multivariate GARCH Fit Class} 5 | \description{High Level multivariate GARCH fit class.} 6 | \section{Objects from the Class}{A virtual Class: No objects may be created from 7 | it.} 8 | \section{Extends}{ 9 | Class \code{"\linkS4class{GARCHfit}"}, directly. 10 | Class \code{"\linkS4class{rGARCH}"}, by class "GARCHfit", distance 2. 11 | } 12 | \section{Methods}{ 13 | No methods defined with class "mGARCHfit" in the signature. 14 | } 15 | \author{Alexios Galanos} 16 | \keyword{classes} 17 | -------------------------------------------------------------------------------- /man/mGARCHforecast-class.Rd: -------------------------------------------------------------------------------- 1 | \name{mGARCHforecast-class} 2 | \docType{class} 3 | \alias{mGARCHforecast-class} 4 | \title{Class: Multivariate GARCH Forecast Class} 5 | \description{High Level multivariate GARCH forecast class.} 6 | \section{Objects from the Class}{A virtual Class: No objects may be created from 7 | it.} 8 | \section{Extends}{ 9 | Class \code{"\linkS4class{GARCHforecast}"}, directly. 10 | Class \code{"\linkS4class{rGARCH}"}, by class "GARCHforecast", distance 2. 11 | } 12 | \section{Methods}{ 13 | No methods defined with class "mGARCHforecast" in the signature. 14 | } 15 | \author{Alexios Galanos} 16 | \keyword{classes} 17 | -------------------------------------------------------------------------------- /man/mGARCHroll-class.Rd: -------------------------------------------------------------------------------- 1 | \name{mGARCHroll-class} 2 | \docType{class} 3 | \alias{mGARCHroll-class} 4 | \title{Class: Multivariate GARCH Roll Class} 5 | \description{High Level multivariate GARCH roll class.} 6 | \section{Objects from the Class}{A virtual Class: No objects may be created from 7 | it.} 8 | \section{Extends}{ 9 | Class \code{"\linkS4class{GARCHroll}"}, directly. 10 | Class \code{"\linkS4class{rGARCH}"}, by class "GARCHroll", distance 2. 11 | } 12 | \section{Methods}{ 13 | No methods defined with class "mGARCHroll" in the signature. 14 | } 15 | \author{Alexios Galanos} 16 | \keyword{classes} 17 | -------------------------------------------------------------------------------- /man/mGARCHsim-class.Rd: -------------------------------------------------------------------------------- 1 | \name{mGARCHsim-class} 2 | \docType{class} 3 | \alias{mGARCHsim-class} 4 | \title{Class: Multivariate GARCH Simulation Class} 5 | \description{High Level multivariate GARCH simulation class.} 6 | \section{Objects from the Class}{A virtual Class: No objects may be created from 7 | it.} 8 | \section{Extends}{ 9 | Class \code{"\linkS4class{GARCHsim}"}, directly. 10 | Class \code{"\linkS4class{rGARCH}"}, by class "GARCHsim", distance 2. 11 | } 12 | \section{Methods}{ 13 | No methods defined with class "mGARCHsim" in the signature. 14 | } 15 | \author{Alexios Galanos} 16 | \keyword{classes} 17 | -------------------------------------------------------------------------------- /man/mGARCHspec-class.Rd: -------------------------------------------------------------------------------- 1 | \name{mGARCHspec-class} 2 | \docType{class} 3 | \alias{mGARCHspec-class} 4 | \title{Class: Multivariate GARCH Specification} 5 | \description{High Level multivariate GARCH specification class.} 6 | \section{Objects from the Class}{A virtual Class: No objects may be created from 7 | it.} 8 | \section{Extends}{ 9 | Class \code{"\linkS4class{GARCHspec}"}, directly. 10 | Class \code{"\linkS4class{rGARCH}"}, by class "GARCHspec", distance 2. 11 | } 12 | \section{Methods}{ 13 | No methods defined with class "mGARCHspec" in the signature. 14 | } 15 | \author{Alexios Galanos} 16 | \keyword{classes} 17 | -------------------------------------------------------------------------------- /man/radical.Rd: -------------------------------------------------------------------------------- 1 | \name{radical} 2 | \alias{radical} 3 | \title{ 4 | The Robust Accurate, Direct ICA aLgorithm (RADICAL). 5 | } 6 | \description{ 7 | An ICA algorithm based on an efficient entropy estimator (due to Vasicek) which 8 | is robust to outliers. 9 | } 10 | \usage{ 11 | radical(X, n.comp = dim(X)[2], demean = TRUE, pca.cov = c("ML", "LW", "ROB", "EWMA"), 12 | k = 150, augment = FALSE, replications = 30, sd = 0.175, firstEig = 1, 13 | lastEig = dim(X)[1], pcaE = NULL, pcaD = NULL, whiteSig = NULL, whiteMat = NULL, 14 | dewhiteMat = NULL, rseed = NULL, trace = FALSE, ...) 15 | } 16 | \arguments{ 17 | \item{X}{ The multidimensional signal matrix, where each column of matrix represents 18 | one observed signal.} 19 | \item{n.comp}{ Number of independent components to estimate, defaults to the 20 | dimension of the data (rows). Is overwritten by \code{firstEig} and \code{lastEig}.} 21 | \item{demean}{ (Logical) Whether the data should be centered.} 22 | \item{pca.cov}{ 23 | The method to use for the calculation of the covariance matrix during the 24 | PCA whitening phase. \dQuote{ML} is the standard maximum likelihood method, 25 | \dQuote{LW} is the Ledoit-Wolf method, \dQuote{ROB} is the robust method from 26 | the MASS package and \dQuote{EWMA} an exponentially weighted moving average 27 | estimator. Optional parameters passed via the \dots argument. 28 | } 29 | \item{k}{ The number of angles at which to evaluate the contrast function. The 30 | ICA contrast function will be evaluated at K evenly spaced rotations from -Pi/4 31 | to Pi/4 32 | } 33 | \item{augment}{ Whether to augment the data (as explained in paper). For large 34 | datasets of >10,000 points this should be set to FALSE.} 35 | \item{replications}{ This is the number of replicated points for each original 36 | point. The default value is 30. The larger the number of points in the data set, 37 | the smaller this value can be. For data sets of 10,000 points or more, point 38 | replication should be de-activated by setting augment to FALSE.} 39 | \item{sd}{This is the standard deviation (noise) of the replicated points when 40 | using the augmentation option.} 41 | \item{firstEig}{ This and \code{lastEig} specify the range for eigenvalues 42 | that are retained, \code{firstEig} is the index of largest eigenvalue to be 43 | retained. Making use of this option overwrites \code{n.comp}. 44 | } 45 | \item{lastEig}{ This is the index of the last (smallest) eigenvalue to be 46 | retained and overwrites \code{n.comp} argument.} 47 | \item{pcaE}{ Optionally provided eigenvector (must also supply \code{pcaD}).} 48 | \item{pcaD}{ Optionally provided eigenvalues (must also supply \code{pcaE}).} 49 | \item{whiteSig}{Optionally provided Whitened signal.} 50 | \item{whiteMat}{ Optionally provided Whitening matrix (no.factors by no.signals).} 51 | \item{dewhiteMat}{Optionally provided dewhitening matrix (no.signals by no.factors).} 52 | \item{rseed}{Optionally provided seed to initialize the augmented data matrix.} 53 | \item{trace}{To report progress in the console, set this to \code{TRUE}.} 54 | \item{\dots}{Optional arguments passed to the pca.cov methods.} 55 | } 56 | \details{ 57 | The interested reader should consult the paper in the references section for 58 | details on the properties of the algorithm.\cr 59 | The algorithm is quite slow, despite partial implementation in C++, and should 60 | only be used on small to medium sized sets. 61 | } 62 | \value{ 63 | A list containing the following values: 64 | \item{A}{Estimated Mixing Matrix (no.signals by no.factors).} 65 | \item{W}{Estimated UnMixing Matrix (no.factors by no.signals). } 66 | \item{U}{Estimated rotation Matrix (no.factors by no.factors). } 67 | \item{S}{The column vectors of estimated independent components (no.obs by no.factors).} 68 | \item{C}{Estimated Covariance Matrix (no.signals by no.signals).} 69 | \item{whiteningMatrix}{The Whitening matrix (no.factors by no.signals).} 70 | \item{dewhiteningMatrix}{The de-Whitening matrix (no.signals by no.factors).} 71 | \item{rseed}{The random seed used (if any) for initializing the mixing matrix A.} 72 | \item{elapsed}{The elapsed time.} 73 | } 74 | \references{ 75 | Learned-Miller, A.G and Fisher III, J.W., 2003, ICA Using Spacings Estimates of 76 | Entropy, \emph{Journal of Machine Learning Research}, \bold{4}, 1271-1295. 77 | \url{http://www.cs.umass.edu/~elm/ICA/} 78 | } 79 | \author{ 80 | Erik G. Learned-Miller for the Radical algorithm and Matlab package.\cr 81 | Alexios Galanos for this R-port. 82 | } 83 | \examples{ 84 | \dontrun{ 85 | # create a set of independent signals S, glued together by a mixing matrix A 86 | # (note the notation and matrix multiplication direction as we are dealing with 87 | # row rather than column vectors) 88 | set.seed(100) 89 | S <- matrix(runif(10000), 5000, 2) 90 | A <- matrix(c(1, 1, -1, 2), 2, 2, byrow = TRUE) 91 | # the mixed signal X 92 | X = S \%*\% t(A) 93 | # The function centers and whitens (by the eigenvalue decomposition of the 94 | # unconditional covariance matrix) the data before applying the theICA algorithm. 95 | IC <- radical(X, n.comp = 2) 96 | 97 | # demeaned data: 98 | X_bar = scale(X, scale = FALSE) 99 | 100 | # whitened data: 101 | X_white = X_bar \%*\% t(IC$whiteningMatrix) 102 | 103 | # check whitening: 104 | # check correlations are zero 105 | cor(X_white) 106 | # check diagonals are 1 in covariance 107 | cov(X_white) 108 | 109 | # check that the estimated signals(S) multiplied by the 110 | # estimated mxing matrix (A) are the same as the original dataset (X) 111 | round(head(IC$S \%*\% t(IC$A)), 12) == round(head(X), 12) 112 | 113 | # do some plots: 114 | par(mfrow = c(1, 3)) 115 | plot(IC$S \%*\% t(IC$A), main = "Pre-processed data") 116 | plot(X_white, main = "Whitened and Centered components") 117 | plot(IC$S, main = "ICA components") 118 | }} 119 | \keyword{multivariate} 120 | -------------------------------------------------------------------------------- /man/rmgarch-package.Rd: -------------------------------------------------------------------------------- 1 | \name{rmgarch-package} 2 | \alias{rmgarch-package} 3 | \alias{rmgarch} 4 | \title{The rmgarch package} 5 | \description{ 6 | The rmgarch provides a selection of multivariate GARCH models with methods for 7 | fitting, filtering, forecasting and simulation with additional support functions 8 | for working with the returned objects. At present, the Generalized Orthogonal 9 | GARCH using Independent Components Analysis (\emph{ICA}) and Dynamic Conditional 10 | Correlation (with multivariate Normal, Laplace and Student distributions) models 11 | are fully implemented, with methods for spec, fit, filter, forecast, simulation, 12 | and rolling estimation and forecasting, as well as specialized functions to 13 | calculate and work with the weighted portfolio conditional density. 14 | The Copula-GARCH model is also implemented with the multivariate Normal 15 | and Student distributions, with dynamic (DCC) and static estimation of 16 | the correlation.\cr 17 | } 18 | \details{ 19 | The main package functionality, currently supports the \emph{GO-GARCH} with ICA 20 | method, and is available through the \code{\link{gogarchspec}}, 21 | \code{\link{gogarchfit}}, \code{\link{gogarchfilter}}, \code{\link{gogarchforecast}}, 22 | \code{\link{gogarchsim}} and \code{\link{gogarchroll}} functions. The \emph{DCC} 23 | with multivariate Normal, Laplace and Student distributions is also supported 24 | with the main functionality in \code{\link{dccspec}}, \code{\link{dccfit}}, 25 | \code{\link{dccfilter}}, \code{\link{dccforecast}}, \code{\link{dccsim}} and 26 | \code{\link{dccroll}}. The Normal and Student Copula-GARCH, with dynamic or 27 | static correlation, is implemented with the main functionality in 28 | \code{\link{cgarchspec}}, \code{\link{cgarchfit}}, \code{\link{cgarchfilter}}, 29 | and \code{\link{cgarchsim}}. Usual extractor and support methods for the 30 | multivariate GARCH models are documented in the class of the returned objects.\cr. 31 | } 32 | \section{How to cite this package}{ 33 | Whenever using this package, please cite as\cr 34 | \preformatted{@Manual{Ghalanos_2014, 35 | author = {Alexios Galanos}, 36 | title = {{rmgarch}: Multivariate GARCH models.}, 37 | year = {2019}, 38 | note = {R package version 1.3-6.}}} 39 | } 40 | \section{License}{ 41 | The releases of this package is licensed under GPL version 3. 42 | } 43 | \author{Alexios Galanos} 44 | \references{ 45 | Bollerslev, T. 1990, Modelling the coherence in short-run nominal exchange 46 | rates: a multivariate generalized ARCH model, \emph{The Review of Economics and 47 | Statistics}, \bold{72(3)}, 498--505.\cr 48 | Broda, S.A. and Paolella, M.S. 2009, CHICAGO: A Fast and Accurate Method for 49 | Portfolio Risk Calculation, \emph{Journal of Financial Econometrics} \bold{7(4)}, 50 | 412--436 .\cr 51 | Cappiello, L., Engle, R.F. and Sheppard, K. 2006, Asymmetric dynamics in the 52 | correlations of global equity and bond returns, \emph{Journal of Financial 53 | Econometrics} \bold{4}, 537--572.\cr 54 | Croux, C. and Joossens, K. 2008, Robust estimation of the vector autoregressive 55 | model by a least trimmed squares procedure, \emph{COMPSTAT}, 489--501.\cr 56 | Chen, Y., Hardle, W., and Spokoiny, V. 2010, GHICA - Risk analysis with GH 57 | distributions and independent components, \emph{Journal of Empirical Finance}, 58 | \bold{17(2)}, 255--269.\cr 59 | de Athayde, G.M. and Flores Jr, R.G. 2002, On Certain Geometric Aspects of 60 | Portfolio Optimisation with Higher Moments, \emph{mimeo}.\cr 61 | Engle, R.F. 2002, Dynamic conditional correlation, \emph{Journal of Business and 62 | Economic Statistics} \bold{20}, 339--350.\cr 63 | Engle, R.F. and Sheppard, K. 2001, Theoretical and empirical properties of 64 | dynamic conditional correlation multivariate GARCH, \emph{NBER Working Paper}.\cr 65 | Genest, C., Ghoudi, K. and Rivest, L. 1995, A semiparametric estimation 66 | procedure of dependence parameters in multivariate families of distributions, 67 | \emph{Biometrika}, \bold{82}, 543--552.\cr 68 | Ghalanos, A., Rossi, E., and Urga, G. (2014). \emph{Independent Factor 69 | Autoregressive Conditional Density Model}, \bold{Econometric Reviews}.\cr 70 | Paolella, M.S. 2007, Intermediate Probability - A Computational Approach, 71 | \emph{Wiley-Interscience}.\cr 72 | Schmidt, R., Hrycej, T. and Stutzle 2006, Multivariate distribution models with 73 | generalized hyperbolic margins, \emph{Computational Statistics \& Data Analysis} 74 | \bold{50(8)}, 2065--2096.\cr 75 | } 76 | -------------------------------------------------------------------------------- /man/varxfit.Rd: -------------------------------------------------------------------------------- 1 | \name{varxfit} 2 | \alias{varxfilter} 3 | \alias{varxfit} 4 | \alias{varxforecast} 5 | \alias{varxsim} 6 | \title{ 7 | VARX Fit/Filter/Forecast/Simulation Functions 8 | } 9 | \description{ 10 | Vector Autoregressive (VAR) with Constant and Optional Exogenous Regressors (X) 11 | Fit, Filter, Forecast and Simulation functions for use with multivariate GARCH 12 | models. 13 | } 14 | \usage{ 15 | varxfit(X, p, constant = TRUE, exogen = NULL, robust = FALSE, gamma = 0.25, 16 | delta = 0.01, nc = 10, ns = 500, postpad = c("none", "constant", "zero", "NA"), 17 | cluster = NULL) 18 | varxfilter(X, p, Bcoef, exogen = NULL, postpad = c("none", "constant", "zero", "NA")) 19 | varxforecast(X, Bcoef, p, out.sample, n.ahead, n.roll, mregfor) 20 | varxsim (X, Bcoef, p, n.sim, n.start, prereturns, resids, mexsimdata) 21 | } 22 | \arguments{ 23 | \item{X}{ 24 | A multivariate data matrix. 25 | } 26 | \item{p}{ 27 | The number of autoregressive lags. 28 | } 29 | \item{constant}{ 30 | Whether to include a constant. 31 | } 32 | \item{exogen}{ 33 | An optional matrix of exogenous regressors with as many rows as X, and 34 | appropriately lagged. 35 | } 36 | \item{Bcoef}{ 37 | A matrix of coefficients for the varxfilter function. 38 | } 39 | \item{robust}{ 40 | Whether to use the robust version of VAR based on the multivariate Least 41 | Trimmed Squares Estimator described in Croux and Joossens (2008). 42 | } 43 | \item{gamma}{ 44 | Proportion to trim in the robust method. 45 | } 46 | \item{delta}{ 47 | The critical value for Reweighted estimator for the robust method. 48 | } 49 | \item{ns}{ 50 | The number of subsets to use for the robust method. 51 | } 52 | \item{nc}{ 53 | The number of C-steps to use for the robust method. 54 | } 55 | \item{postpad}{ 56 | (defaults to \sQuote{none}) Whether to postpad the fitted/filtered values 57 | (and hence calculation of residuals) with the estimated constant, zeros or NA's, 58 | thus returning matrices of the same size as the input data (rather than input 59 | data size less the number of lags). 60 | } 61 | \item{cluster}{ A cluster object created by calling \code{makeCluster} from 62 | the parallel package. If it is not NULL, then this will be used for parallel 63 | estimation in the case of the robust VAR version (remember to stop the cluster 64 | on completion).} 65 | \item{out.sample}{ 66 | The number of points kept for out of sample rolling forecast. 67 | } 68 | \item{n.ahead}{ 69 | The forecast horizon. 70 | } 71 | \item{n.roll}{ 72 | In combination with \code{out.sample}, determines the number of times to roll 73 | forward the n.ahead forecast using data left out of sample. 74 | } 75 | \item{mregfor}{ 76 | Matrix of external regressor forecasts (with appropriate lag structure). 77 | } 78 | \item{n.sim}{ 79 | Simulation horizon. 80 | } 81 | \item{n.start}{ 82 | Simulation burn-in sample. 83 | } 84 | \item{prereturns}{ 85 | Optionally supplied pre-return matrix with \dQuote{p} lags to initialize 86 | simulation. 87 | } 88 | \item{resids}{ 89 | Matrix of randomly generated residuals of size n.sim+n.start. 90 | } 91 | \item{mexsimdata}{ 92 | Matrix of external regressor pre-generated random values to use in the 93 | simulation (if NULL then assumed zero). 94 | } 95 | } 96 | \details{ 97 | This are convenience functions to be optionally used when using the multivariate 98 | GARCH methods. 99 | } 100 | \value{ 101 | A list with the following items:\cr 102 | \item{Bcoef }{[varxfit, varxfilter]\cr 103 | The coefficient matrix with rows equal to number of assets, and columns equal to 104 | number of assets x number of lags plus 1 (constant) plus number of exogenous 105 | regressors.} 106 | \item{xfitted }{[varxfit, varxfilter]\cr 107 | The fitted/filtered series (conditional mean series).} 108 | \item{xresiduals }{[varxfit, varxfilter]\cr 109 | The residuals.} 110 | \item{Bcov }{[varxfit]\cr 111 | The covariance matrix of the coefficients.} 112 | \item{se }{[varxfit]\cr 113 | The standard error of the coefficients.} 114 | \item{tstat }{[varxfit]\cr 115 | The t-stat of the s.e.} 116 | \item{pstat }{[varxfit]\cr 117 | The p-values of the s.e.} 118 | \item{lag }{[varxfit, varxfilter]\cr 119 | The number of autoregressive lags.} 120 | \item{mxn}{[varxfit]\cr 121 | The number of exogenous regressors .} 122 | \item{meansim}{[varxsim]\cr 123 | The simulated conditional mean.}\cr 124 | The varxsim returns an n.sim x n.asset matrix of the simulated conditional 125 | means, while the varxforecast returns an n.ahead x n.assets x (n.roll+1) array 126 | of the forecast conditional means. 127 | } 128 | \references{ 129 | Lutkepohl, H. 2005, New introduction to multiple time series analysis, 130 | \emph{Springer}.\cr 131 | Croux, C. and Joossens, K. 2008, Robust estimation of the vector autoregressive 132 | model by a least trimmed squares procedure, \emph{COMPSTAT}, 489--501.\cr 133 | } 134 | \author{Alexios Galanos} 135 | \note{ 136 | Part of the varxfit functionality and structure is inspired from the 'vars' 137 | package, but the estimation method is implemented in a very quick way without 138 | calling 'lm'. The robust method is based on the matlab program of Christophe 139 | Croux available from his website and the option of using parallel computation is 140 | implemented for this particular choice.The \code{postpad} option is used when the 141 | returned data needs to be of the same size as the inputed data for easier 142 | manipulation/comparison (since padding is done post-estimation, there is no bias 143 | introduced during estimation). 144 | } 145 | -------------------------------------------------------------------------------- /man/wmargin.Rd: -------------------------------------------------------------------------------- 1 | \name{wmargin} 2 | \alias{wmargin} 3 | \title{ 4 | Weighted Distribution Margin 5 | } 6 | \description{ 7 | Return the weighted margin of one of 3 elliptical distributions given a matrix 8 | of weights. 9 | } 10 | \usage{ 11 | wmargin(distribution = "mvnorm", weights, mean, Sigma, shape = NA, skew = NA) 12 | } 13 | \arguments{ 14 | \item{distribution}{ 15 | One of \sQuote{mvnorm}, \sQuote{mvlaplace} or \sQuote{mvt}. 16 | } 17 | \item{weights}{ 18 | Either a vector or matrix of weights, in the latter case must be of the same 19 | row dimension as the covariance array. 20 | } 21 | \item{mean}{ 22 | Wither a vector or matrix of conditional distribution means, in the latter 23 | case must be of the same row dimension as the covariance array. 24 | } 25 | \item{Sigma}{ 26 | An array of covariances, usually returned by calling the \sQuote{rcov} method 27 | on one of the multivariate GARCH fitted objects. 28 | } 29 | \item{shape}{ 30 | The shape (d.o.f.) parameter of the multivariate student distribution. 31 | } 32 | \item{skew}{ 33 | Not currently required for the 3 distributions used. 34 | } 35 | } 36 | \details{ 37 | This is just a convenience function to return the weighted variance and mean of 38 | the three elliptical distributions given a set of weights. 39 | } 40 | \value{ 41 | A matrix with each row representing the conditional weighted marginal density 42 | with corresponding parameters. 43 | } 44 | \author{Alexios Galanos} 45 | -------------------------------------------------------------------------------- /src/Makevars: -------------------------------------------------------------------------------- 1 | PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS) 2 | PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) 3 | -------------------------------------------------------------------------------- /src/Makevars.win: -------------------------------------------------------------------------------- 1 | PKG_LIBS = `$(R_HOME)/bin/Rscript.exe -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS) 2 | PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) 3 | -------------------------------------------------------------------------------- /src/copulas.h: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | #ifndef _copulas_H 18 | #define _copulas_H 19 | #include "rmdist.h" 20 | #include 21 | RcppExport SEXP copulaNormalC1(SEXP , SEXP); 22 | RcppExport SEXP copulaNormalC2(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP); 23 | RcppExport SEXP copulaStudentC1(SEXP , SEXP , SEXP , SEXP , SEXP); 24 | RcppExport SEXP copulaStudentC2(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP); 25 | RcppExport SEXP copuladccsimmvn(SEXP , SEXP , SEXP , SEXP, SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 26 | RcppExport SEXP copuladccsimmvt(SEXP , SEXP , SEXP , SEXP, SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 27 | #endif 28 | -------------------------------------------------------------------------------- /src/gogarch.h: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | #ifndef _gogarch_H 18 | #define _gogarch_H 19 | #include 20 | RcppExport SEXP tvbetacovar(SEXP wi, SEXP Vi, SEXP di); 21 | RcppExport SEXP tvbetacoskew(SEXP wi, SEXP Si, SEXP di); 22 | RcppExport SEXP tvbetacokurt(SEXP wi, SEXP Ki, SEXP di); 23 | RcppExport SEXP gogarchSigma(SEXP S, SEXP A); 24 | RcppExport SEXP gogarchCov(SEXP S, SEXP A); 25 | RcppExport SEXP gogarchCor(SEXP S, SEXP A); 26 | RcppExport SEXP Cov2Cor(SEXP , SEXP ); 27 | RcppExport SEXP ArrayDiag(SEXP , SEXP ); 28 | RcppExport SEXP Cov2Res(SEXP , SEXP , SEXP ); 29 | RcppExport SEXP RowApplySort(SEXP ); 30 | RcppExport SEXP RowUnique(SEXP ); 31 | RcppExport SEXP gogarchcssigma(SEXP , SEXP ); 32 | RcppExport SEXP gogarchcksigma(SEXP , SEXP ); 33 | arma::mat coskewind( arma::rowvec ); 34 | #endif 35 | -------------------------------------------------------------------------------- /src/ica.cpp: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | 18 | #include "ica.h" 19 | using namespace Rcpp; 20 | 21 | SEXP radicalrot(SEXP X, SEXP idx) 22 | { 23 | try { 24 | Rcpp::NumericMatrix RX(X); 25 | int *ridx = INTEGER(idx); 26 | int m = ridx[0]; 27 | int k = ridx[1]; 28 | int nx = RX.nrow(), mx = RX.ncol(), i; 29 | arma::mat AX(RX.begin(), nx, mx, true); 30 | arma::mat rot(2,2); 31 | arma::mat rotp(nx, mx); 32 | double theta = 0.0; 33 | arma::rowvec ent(k); 34 | arma::rowvec vals(mx); 35 | arma::rowvec margtheta(2); 36 | arma::rowvec tmp; 37 | for(i=0;iradical c++ exception (unknown reason)" ); 61 | } 62 | return R_NilValue; 63 | } 64 | 65 | arma::mat fs10(arma::mat X, arma::mat B, const double nsamples) 66 | { 67 | //Rcpp::NumericMatrix RX(X); 68 | //Rcpp::NumericMatrix RB(B); 69 | //int nrx = RX.nrow(), ncx = RX.ncol(); 70 | //int nrb = RB.nrow(), ncb = RB.ncol(); 71 | //arma::mat AX(RX.begin(), nrx, ncx, true); 72 | //arma::mat AB(RB.begin(), nrb, ncb, true); 73 | //double *rv = REAL(v); 74 | //double nsamples = rv[0]; 75 | arma::mat A = (X * arma::pow(X.t()*B, 3))/nsamples - 3*B; 76 | return(A); 77 | } 78 | 79 | arma::mat fs11(arma::mat X, arma::mat B, const double nsamples, const double myy) 80 | { 81 | arma::mat Y = X.t()*B; 82 | arma::mat Gpow3 = arma::pow(Y, 3); 83 | arma::mat Beta = arma::sum(Y%Gpow3); 84 | arma::mat D = 1/(Beta -3*nsamples); 85 | arma::mat A = B + myy*B*(Y.t()*Gpow3 - arma::diagmat(Beta)) * arma::diagmat(D); 86 | return(A); 87 | } 88 | 89 | arma::mat sqrtm(arma::mat X) 90 | { 91 | arma::mat U; 92 | arma::vec s; 93 | arma::mat V; 94 | arma::svd(U,s,V,X); 95 | arma::mat A = U * arma::sqrt(arma::diagmat(s)) * U.t(); 96 | return(A); 97 | } 98 | -------------------------------------------------------------------------------- /src/ica.h: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | #ifndef _ica_H 18 | #define _ica_H 19 | #define STRICT_R_HEADERS 20 | #include 21 | RcppExport SEXP radicalrot(SEXP , SEXP); 22 | arma::mat fs10(arma::mat X, arma::mat B, const double nsamples); 23 | arma::mat fs11(arma::mat X, arma::mat B, const double nsamples, const double myy); 24 | arma::mat sqrtm(arma::mat X); 25 | #endif 26 | -------------------------------------------------------------------------------- /src/init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include // for NULL 4 | #include 5 | 6 | /* .Call calls */ 7 | extern SEXP ArrayDiag(SEXP, SEXP); 8 | extern SEXP copuladccsimmvn(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 9 | extern SEXP copuladccsimmvt(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 10 | extern SEXP copulaNormalC1(SEXP, SEXP); 11 | extern SEXP copulaNormalC2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 12 | extern SEXP copulaStudentC1(SEXP, SEXP, SEXP, SEXP, SEXP); 13 | extern SEXP copulaStudentC2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 14 | extern SEXP Cov2Cor(SEXP, SEXP); 15 | extern SEXP Cov2Res(SEXP, SEXP, SEXP); 16 | extern SEXP dcclaplaceC1(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 17 | extern SEXP dcclaplaceC2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 18 | extern SEXP dccnormC1(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 19 | extern SEXP dccnormC2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 20 | extern SEXP dccsimmvl(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 21 | extern SEXP dccsimmvn(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 22 | extern SEXP dccsimmvt(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 23 | extern SEXP dccstudentC1(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 24 | extern SEXP dccstudentC2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 25 | extern SEXP fdccnormC1(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 26 | extern SEXP fdccnormC2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 27 | extern SEXP fdccsimmvn(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); 28 | extern SEXP gogarchcksigma(SEXP, SEXP); 29 | extern SEXP gogarchCor(SEXP, SEXP); 30 | extern SEXP gogarchCov(SEXP, SEXP); 31 | extern SEXP gogarchcssigma(SEXP, SEXP); 32 | extern SEXP gogarchSigma(SEXP, SEXP); 33 | extern SEXP radicalrot(SEXP, SEXP); 34 | extern SEXP tvbetacokurt(SEXP, SEXP, SEXP); 35 | extern SEXP tvbetacoskew(SEXP, SEXP, SEXP); 36 | extern SEXP tvbetacovar(SEXP, SEXP, SEXP); 37 | 38 | static const R_CallMethodDef CallEntries[] = { 39 | {"ArrayDiag", (DL_FUNC) &ArrayDiag, 2}, 40 | {"copuladccsimmvn", (DL_FUNC) &copuladccsimmvn, 10}, 41 | {"copuladccsimmvt", (DL_FUNC) &copuladccsimmvt, 10}, 42 | {"copulaNormalC1", (DL_FUNC) &copulaNormalC1, 2}, 43 | {"copulaNormalC2", (DL_FUNC) &copulaNormalC2, 8}, 44 | {"copulaStudentC1", (DL_FUNC) &copulaStudentC1, 5}, 45 | {"copulaStudentC2", (DL_FUNC) &copulaStudentC2, 9}, 46 | {"Cov2Cor", (DL_FUNC) &Cov2Cor, 2}, 47 | {"Cov2Res", (DL_FUNC) &Cov2Res, 3}, 48 | {"dcclaplaceC1", (DL_FUNC) &dcclaplaceC1, 8}, 49 | {"dcclaplaceC2", (DL_FUNC) &dcclaplaceC2, 9}, 50 | {"dccnormC1", (DL_FUNC) &dccnormC1, 8}, 51 | {"dccnormC2", (DL_FUNC) &dccnormC2, 9}, 52 | {"dccsimmvl", (DL_FUNC) &dccsimmvl, 10}, 53 | {"dccsimmvn", (DL_FUNC) &dccsimmvn, 10}, 54 | {"dccsimmvt", (DL_FUNC) &dccsimmvt, 10}, 55 | {"dccstudentC1", (DL_FUNC) &dccstudentC1, 8}, 56 | {"dccstudentC2", (DL_FUNC) &dccstudentC2, 9}, 57 | {"fdccnormC1", (DL_FUNC) &fdccnormC1, 6}, 58 | {"fdccnormC2", (DL_FUNC) &fdccnormC2, 7}, 59 | {"fdccsimmvn", (DL_FUNC) &fdccsimmvn, 9}, 60 | {"gogarchcksigma", (DL_FUNC) &gogarchcksigma, 2}, 61 | {"gogarchCor", (DL_FUNC) &gogarchCor, 2}, 62 | {"gogarchCov", (DL_FUNC) &gogarchCov, 2}, 63 | {"gogarchcssigma", (DL_FUNC) &gogarchcssigma, 2}, 64 | {"gogarchSigma", (DL_FUNC) &gogarchSigma, 2}, 65 | {"radicalrot", (DL_FUNC) &radicalrot, 2}, 66 | {"tvbetacokurt", (DL_FUNC) &tvbetacokurt, 3}, 67 | {"tvbetacoskew", (DL_FUNC) &tvbetacoskew, 3}, 68 | {"tvbetacovar", (DL_FUNC) &tvbetacovar, 3}, 69 | {NULL, NULL, 0} 70 | }; 71 | 72 | void R_init_rmgarch(DllInfo *dll) 73 | { 74 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 75 | R_useDynamicSymbols(dll, FALSE); 76 | } 77 | -------------------------------------------------------------------------------- /src/rdcc.h: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | #ifndef _rdcc_H 18 | #define _rdcc_H 19 | #include 20 | #include "rmdist.h" 21 | RcppExport SEXP dccnormC1(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 22 | RcppExport SEXP dccnormC2(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 23 | RcppExport SEXP dccstudentC1(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 24 | RcppExport SEXP dccstudentC2(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 25 | RcppExport SEXP dcclaplaceC1(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 26 | RcppExport SEXP dcclaplaceC2(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 27 | RcppExport SEXP dccfilter(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 28 | RcppExport SEXP dccsimmvn(SEXP , SEXP , SEXP, SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 29 | RcppExport SEXP dccsimmvt(SEXP , SEXP , SEXP, SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 30 | RcppExport SEXP dccsimmvl(SEXP , SEXP , SEXP, SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 31 | RcppExport SEXP fdccnormC1(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 32 | RcppExport SEXP fdccnormC2(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP , SEXP ); 33 | RcppExport SEXP fdccsimmvn(SEXP , SEXP , SEXP , SEXP , SEXP , SEXP, SEXP , SEXP , SEXP ); 34 | #endif 35 | -------------------------------------------------------------------------------- /src/rmdist.cpp: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | #include "rmdist.h" 18 | 19 | arma::rowvec rmvnormx(arma::mat R, arma::rowvec Z){ 20 | Rcpp::RNGScope scope; 21 | int m = R.n_rows; 22 | arma::vec eigval(m); 23 | arma::mat eigvec(m, m); 24 | arma::mat temp(m, m); 25 | arma::eig_sym(eigval, eigvec, R); 26 | arma::rowvec ans(m); 27 | temp = ( eigvec * arma::diagmat( arma::sqrt( eigval ) ) * arma::inv( eigvec ) ); 28 | ans = Z * temp; 29 | return ans; 30 | } 31 | 32 | arma::rowvec rmvtx(arma::mat R, const double nu, arma::rowvec Z){ 33 | Rcpp::RNGScope scope; 34 | int m = R.n_rows; 35 | double rc = Rf_rchisq(nu); 36 | arma::mat RR = ((nu-2.0)/nu)*R; 37 | double v = sqrt(nu/rc); 38 | arma::rowvec ans(m); 39 | ans = v*rmvnormx(RR, Z); 40 | return ans; 41 | } 42 | 43 | arma::rowvec rmvlx(arma::mat R, arma::rowvec Z){ 44 | Rcpp::RNGScope scope; 45 | int m = R.n_rows; 46 | double e = Rf_rexp(1); 47 | arma::rowvec ans(m); 48 | ans = sqrt(e) * rmvnormx(R, Z); 49 | return ans; 50 | } 51 | -------------------------------------------------------------------------------- /src/rmdist.h: -------------------------------------------------------------------------------- 1 | /*################################################################################ 2 | ## 3 | ## R package rmgarch by Alexios Galanos Copyright (C) 2009-2013 4 | ## This file is part of the R package rmgarch. 5 | ## 6 | ## The R package rmgarch is free software: you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## The R package rmgarch is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | #################################################################################*/ 17 | #ifndef _rmdist_H 18 | #define _rmdist_H 19 | #undef trunc 20 | #undef ftrunc 21 | #define R_NO_REMAP 22 | #define STRICT_R_HEADERS 23 | #include 24 | #include 25 | arma::rowvec rmvnormx(arma::mat , arma::rowvec ); 26 | arma::rowvec rmvtx(arma::mat , const double , arma::rowvec ); 27 | arma::rowvec rmvlx(arma::mat , arma::rowvec ); 28 | #endif 29 | -------------------------------------------------------------------------------- /vignettes/rmgarchbib.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cran/rmgarch/2699f032d3811d4f539deb90aac589f5823ebdb4/vignettes/rmgarchbib.bib --------------------------------------------------------------------------------