### Example GO-GARCH Workflow Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html A complete example showing the specification, fitting, and filtering of a GO-GARCH model. ```R ## Not run: data(dji30ret) spec = gogarchspec() fit = gogarchfit(spec = spec, data = dji30ret[,1:4], gfun = "tanh") filter = gogarchfilter(fit, data = dji30ret[,1:4]) ## End(Not run) ``` -------------------------------- ### Simulate from GO-GARCH Model Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Simulate data from a fitted GO-GARCH model. Allows for specifying the number of simulations and starting conditions. Useful for model validation and scenario analysis. ```R gogarchsim(object, n.sim = 1, n.start = 0, m.sim = 1, startMethod = c("unconditional", "sample"), prereturns = NA, preresiduals = NA, presigma = NA, mexsimdata = NULL, rseed = NULL, cluster = NULL, ...) ``` -------------------------------- ### Independent Component Analysis with fastica Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html This example demonstrates how to use the fastica function to perform independent component analysis. It covers creating synthetic data, applying the ICA algorithm, and performing checks on the results, including data preprocessing and visualization. ```R set.seed(100) S <- matrix(runif(10000), 5000, 2) A <- matrix(c(1, 1, -1, 2), 2, 2, byrow = TRUE) # the mixed signal X X = S %*% t(A) # The function centers and whitens (by the eigenvalue decomposition of the # unconditional covariance matrix) the data before applying the theICA algorithm. IC <- fastica(X, n.comp = 2, approach = "symmetric", gfun = "tanh", trace = TRUE, A.init = diag(2)) # demeaned data: X_bar = scale(X, scale = FALSE) # whitened data: X_white = X_bar %*% t(IC$whiteningMatrix) # check whitening: # check correlations are zero cor(X_white) # check diagonals are 1 in covariance cov(X_white) # check that the estimated signals(S) multiplied by the # estimated mxing matrix (A) are the same as the original dataset (X) round(head(IC$S %*% t(IC$A)), 12) == round(head(X), 12) # do some plots: par(mfrow = c(1, 3)) plot(IC$S %*% t(IC$A), main = "Pre-processed data") plot(X_white, main = "Whitened and Centered components") plot(IC$S, main = "ICA components") ``` -------------------------------- ### Copula-GARCH Simulation Function Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Use this function to create a Copula-GARCH simulation object. It requires a fitted 'cGARCHfit' object and allows customization of simulation parameters like horizon, starting values, and external regressors. ```R cgarchsim(fit, n.sim = 1000, n.start = 0, m.sim = 1, startMethod = c("unconditional", "sample"), presigma = NULL, preresiduals = NULL, prereturns = NULL, preR = NULL, preQ = NULL, preZ = NULL, rseed = NULL, mexsimdata = NULL, vexsimdata = NULL, cluster = NULL, only.density = FALSE, prerealized = NULL, ...) ``` -------------------------------- ### GET /data/dji30retw Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Retrieves the Dow Jones 30 Constituents closing value weekly log returns dataset. ```APIDOC ## GET /data/dji30retw ### Description Returns the Dow Jones 30 Constituents closing value weekly (Friday) log returns from 1987-03-16 to 2009-02-03. ### Format A data.frame containing 30x1141 observations. ``` -------------------------------- ### goload Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Loads a previously saved fScenario from file and returns a fScenario or fMoments object. ```APIDOC ## goload ### Description Loads a previously saved fScenario from file and returns a fScenario or fMoments object. ### Parameters - **object** (object) - Required - A fScenario or fMoments object created with save.output set to TRUE. ### Response - **fScenario/fMoments** (object) - An object with the scenario or moments slot filled with the saved data from file. ``` -------------------------------- ### Calculate GO-GARCH model moments and metrics Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Demonstrates fitting a GO-GARCH model and extracting likelihood, coefficients, and portfolio moments. Requires the dji30ret dataset. ```R ## Not run: data(dji30ret) spec = gogarchspec(mean.model = list(demean = "constant"), variance.model = list(model = "sGARCH", garchOrder = c(1,1), submodel = NULL), distribution.model = list(distribution = "manig"), ica = "fastica") fit = gogarchfit(spec = spec, data = dji30ret[,1:4, drop = FALSE], out.sample = 50, gfun = "tanh") # The likelihood of the model likelihood(fit) # the GARCH coefficients of the independent factors coef(fit) # a news-impact surface plot #ni = nisurface(fit, type = "cov", pair = c(1, 2), factor = c(1,2), plot = TRUE) # the time varying correlation array mc = rcor(fit) # plot(mc[1,2,], type = "l") # The moments of an equally weighted portfolio (subtract the out.sample from dimension) gm = gportmoments(fit, weights = matrix(1/4, ncol = 4, row = dim(dji30ret)[1]-50), debug = TRUE) ## End(Not run) ``` -------------------------------- ### Get First or Last Elements of an Array Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Retrieves the first or last n-indices of values from an array. Currently, only arrays are supported for the 'x' argument. ```R last(x, index = 1, ...) first(x, index = 1, ...) ``` -------------------------------- ### Load Saved Scenario or Moments Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Load a previously saved fScenario or fMoments object from disk. This is efficient for large simulation outputs saved with 'save.output = TRUE'. ```R goload(object, ...) ``` -------------------------------- ### goGARCHfft Class Methods Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Methods for interacting with the goGARCHfft class to retrieve density, distribution, and quantile functions, as well as calculating portfolio moments. ```APIDOC ## Methods for goGARCHfft ### dfft - **Signature**: signature(object = "goGARCHfft") - **Description**: Returns an interpolated density function. Requires an 'index' argument to specify the time point. ### pfft - **Signature**: signature(object = "goGARCHfft") - **Description**: Returns an interpolated distribution function. Requires an 'index' argument. ### qfft - **Signature**: signature(object = "goGARCHfft") - **Description**: Returns an interpolated quantile function. Requires an 'index' argument. ### nportmoments - **Signature**: signature(object = "goGARCHfft") - **Description**: Calculates and returns a matrix of the first 4 standardized moments using quadrature-based evaluation of the portfolio density. ``` -------------------------------- ### GO-GARCH Moment Beta Methods Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Methods for calculating covariance, coskewness, and cokurtosis betas for a goGARCHfit object. ```APIDOC ## betacovar(object, weights, asset = 1, cluster = NULL) ## betacoskew(object, weights, asset = 1, cluster = NULL) ## betacokurt(object, weights, asset = 1, cluster = NULL) ### Description Returns the covariance, coskewness, or cokurtosis beta given a matrix of benchmark weights and the asset number for a goGARCHfit object. ### Parameters - **object** (goGARCHfit) - Required - The fitted GO-GARCH model object. - **weights** (matrix/vector) - Required - Matrix of benchmark weights (length equal to rows of original data) or a vector which is recycled. - **asset** (integer) - Optional - The asset number to calculate the beta for. Defaults to 1. - **cluster** (object) - Optional - Cluster object for parallel processing. ``` -------------------------------- ### POST /fmoments Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Generates n-ahead forecast moment matrices given a choice of data generating processes. ```APIDOC ## POST /fmoments ### Description Generates n-ahead forecast moment matrices given a choice of data generating processes. ### Method POST ### Endpoint /fmoments ### Parameters #### Request Body - **spec** (DCCspec or GOGARCHspec) - Required - The data generating process specification. - **Data** (matrix/data.frame) - Required - An n-by-m data matrix. - **n.ahead** (integer) - Optional - The number of steps ahead to forecast (default: 1). - **roll** (integer) - Optional - Number of rolling periods for forecast (default: 0). - **solver** (string) - Optional - Solver to use (default: "solnp"). - **solver.control** (list) - Optional - Control options for the solver. - **fit.control** (list) - Optional - Control arguments for the fitting routine. - **cluster** (object) - Optional - Cluster object for parallel estimation. - **save.output** (boolean) - Optional - Whether to save output to file. - **save.dir** (string) - Optional - Directory to save output. - **save.name** (string) - Optional - Filename for saved output. ### Response #### Success Response (200) - **moments** (list) - The generated forecast moment matrices. ``` -------------------------------- ### Create a DCC-GARCH specification Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Initializes a DCC-GARCH specification object required before fitting the model. ```R dccspec(uspec, VAR = FALSE, robust = FALSE, lag = 1, lag.max = NULL, lag.criterion = c("AIC", "HQ", "SC", "FPE"), external.regressors = NULL, robust.control = list("gamma" = 0.25, "delta" = 0.01, "nc" = 10, "ns" = 500), dccOrder = c(1,1), model = c("DCC", "aDCC", "FDCC"), groups = rep(1, length(uspec@spec)), distribution = c("mvnorm", "mvt", "mvlaplace"), start.pars = list(), fixed.pars = list()) ``` -------------------------------- ### Specify GO-GARCH Model Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Create a GO-GARCH specification object. Configure mean, variance, and distribution models, and select an ICA algorithm. Use 'ica.fix' to provide pre-determined mixing and whitening matrices. ```R gogarchspec(mean.model = list(model = c("constant", "AR", "VAR"), robust = FALSE, lag = 1, lag.max = NULL, lag.criterion = c("AIC", "HQ", "SC", "FPE"), external.regressors = NULL, robust.control = list("gamma" = 0.25, "delta" = 0.01, "nc" = 10, "ns" = 500)), variance.model = list(model = "sGARCH", garchOrder = c(1,1), submodel = NULL, variance.targeting = FALSE), distribution.model = c("mvnorm", "manig", "magh"), ica = c("fastica", "radical"), ica.fix = list(A = NULL, K = NULL), ...) ``` -------------------------------- ### GO-GARCH Simulation Methods Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Methods available for GO-GARCH simulation objects. ```APIDOC ## POST /api/goGARCHsim/convolution ### Description Calculates the weighted density for a goGARCHsim object. ### Method POST ### Endpoint /api/goGARCHsim/convolution ### Parameters #### Query Parameters - **object** (goGARCHsim) - Required - The goGARCHsim object. - **weights** (numeric vector) - Required - A vector of asset weights. - **fft.step** (numeric) - Optional - Step size for FFT. - **fft.by** (numeric) - Optional - Resolution for FFT support. - **fft.support** (numeric vector) - Optional - Support range for FFT. - **support.method** (character) - Optional - Method for support calculation ('user' or 'adaptive'). - **use.ff** (logical) - Optional - Whether to use the 'ff' package. - **sim** (numeric) - Optional - Simulation index to use. - **cluster** (cluster object) - Optional - For parallel computation. - **trace** (numeric) - Optional - Trace level for output. ### Request Example ```json { "object": "goGARCHsim_object", "weights": [0.1, 0.2, 0.7], "fft.step": 0.001, "fft.by": 0.0001, "fft.support": [-1, 1], "support.method": "user", "use.ff": true, "sim": 1, "cluster": null, "trace": 0 } ``` ### Response #### Success Response (200) - **convolution_result** (list or array) - The calculated weighted density. #### Response Example ```json { "convolution_result": { ... } } ``` ## POST /api/goGARCHsim/gportmoments ### Description Calculates the first 3 portfolio moments using the geometric properties of the model. ### Method POST ### Endpoint /api/goGARCHsim/gportmoments ### Parameters #### Query Parameters - **object** (goGARCHsim) - Required - The goGARCHsim object. - **weights** (matrix) - Required - A matrix of asset weights. - **sim** (numeric) - Optional - Simulation index to use. ### Request Example ```json { "object": "goGARCHsim_object", "weights": [[0.1, 0.2, 0.7]], "sim": 1 } ``` ### Response #### Success Response (200) - **portfolio_moments** (numeric vector) - The first 3 portfolio moments. #### Response Example ```json { "portfolio_moments": [0.1, 0.05, 0.01] } ``` ## POST /api/goGARCHsim/rcoskew ### Description Returns the time-varying NxN^2 coskewness tensor. ### Method POST ### Endpoint /api/goGARCHsim/rcoskew ### Parameters #### Query Parameters - **object** (goGARCHsim) - Required - The goGARCHsim object. - **from** (numeric) - Optional - Starting time index. - **to** (numeric) - Optional - Ending time index. - **sim** (numeric) - Optional - Simulation index to use. ### Request Example ```json { "object": "goGARCHsim_object", "from": 1, "to": 10, "sim": 1 } ``` ### Response #### Success Response (200) - **coskewness_tensor** (array) - The NxN^2 coskewness tensor. #### Response Example ```json { "coskewness_tensor": [[[...]]] } ``` ## POST /api/goGARCHsim/rcokurt ### Description Returns the time-varying NxN^3 cokurtosis tensor. ### Method POST ### Endpoint /api/goGARCHsim/rcokurt ### Parameters #### Query Parameters - **object** (goGARCHsim) - Required - The goGARCHsim object. - **standardize** (logical) - Optional - Whether to standardize the tensor. - **from** (numeric) - Optional - Starting time index. - **to** (numeric) - Optional - Ending time index. ### Request Example ```json { "object": "goGARCHsim_object", "standardize": true, "from": 1, "to": 10 } ``` ### Response #### Success Response (200) - **cokurtosis_tensor** (array) - The NxN^3 cokurtosis tensor. #### Response Example ```json { "cokurtosis_tensor": [[[[...]]]] } ``` ## POST /api/goGARCHsim/rcov ### Description Returns the time-varying NxN covariance matrix. ### Method POST ### Endpoint /api/goGARCHsim/rcov ### Parameters #### Query Parameters - **object** (goGARCHsim) - Required - The goGARCHsim object. - **sim** (numeric) - Optional - Simulation index to use. - **output** (character) - Optional - Output format ('array' or 'matrix'). ### Request Example ```json { "object": "goGARCHsim_object", "sim": 1, "output": "array" } ``` ### Response #### Success Response (200) - **covariance_matrix** (array or matrix) - The NxN covariance matrix. #### Response Example ```json { "covariance_matrix": [[...]] } ``` ## POST /api/goGARCHsim/rcor ### Description Returns the time-varying NxN correlation matrix. ### Method POST ### Endpoint /api/goGARCHsim/rcor ### Parameters #### Query Parameters - **object** (goGARCHsim) - Required - The goGARCHsim object. - **sim** (numeric) - Optional - Simulation index to use. - **output** (character) - Optional - Output format ('array' or 'matrix'). ### Request Example ```json { "object": "goGARCHsim_object", "sim": 1, "output": "array" } ``` ### Response #### Success Response (200) - **correlation_matrix** (array or matrix) - The NxN correlation matrix. #### Response Example ```json { "correlation_matrix": [[...]] } ``` ## POST /api/goGARCHsim/as.matrix ### Description Returns matrices related to the estimation of independent components in the GO-GARCH model. ### Method POST ### Endpoint /api/goGARCHsim/as.matrix ### Parameters #### Query Parameters - **x** (goGARCHsim) - Required - The goGARCHsim object. - **which** (character) - Required - Type of matrix to return ('A', 'W', 'U', 'K', 'Kinv'). ### Request Example ```json { "x": "goGARCHsim_object", "which": "A" } ``` ### Response #### Success Response (200) - **matrix_result** (matrix) - The requested matrix. #### Response Example ```json { "matrix_result": [[...]] } ``` ``` -------------------------------- ### Show Class Structure for 'fMoments' Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Displays the structure of the 'fMoments' class, which is returned by the fmoments function. This class holds forecast moment matrices and data-generating process details. ```r showClass("fMoments") ``` -------------------------------- ### GO-GARCH Simulation Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Method for simulation from a fitted GO-GARCH model. ```APIDOC ## gogarchsim ### Description Method for simulation from a fitted GO-GARCH model. ### Parameters - **object** (object) - Required - A fitted GO-GARCH model. - **n.sim** (numeric) - Optional - Number of simulations. - **n.start** (numeric) - Optional - Starting point. - **m.sim** (numeric) - Optional - Number of simulation paths. - **startMethod** (string) - Optional - Method for starting the simulation (unconditional or sample). - **cluster** (object) - Optional - A cluster object for parallel simulation. ``` -------------------------------- ### Generate Forecast Scenarios Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Use fscenario to generate 1-ahead forecast scenarios for portfolio optimization. It supports multiple data generating processes and offers options for rolling forecasts and saving output. ```R fscenario(Data, sim = 1000, roll = 0, model = c("gogarch", "dcc", "cgarch", "var", "mdist"), spec = NULL, var.model = list(lag = 1, lag.max = NULL, lag.criterion = c("AIC", "HQ", "SC", "FPE"), robust = FALSE, robust.control = list("gamma" = 0.25, "delta" = 0.01, "nc" = 10, "ns" = 500)), mdist.model = list(distribution = c("mvn", "mvt", "manig"), AR = TRUE, lag = 1), spd.control = list(lower = 0.1, upper = 0.9, type = "pwm", kernel = "epanech"), cov.method = c("ML", "LW", "EWMA", "MVE", "MCD", "MVT", "BS"), cov.options = list(shrinkage=-1, lambda = 0.96), solver = "solnp", solver.control = list(), fit.control = list(eval.se = FALSE), cluster = NULL, save.output = FALSE, save.dir = getwd(), save.name = paste("S", sample(1:1000, 1), sep = ""), rseed = NULL, ...) ``` -------------------------------- ### betacoskew(object, weights, asset, cluster) Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Returns the coskewness beta given a matrix of benchmark weights and the asset number for a goGARCHfilter object. ```APIDOC ## betacoskew ### Description Returns the coskewness beta given a matrix (of length equal to the number of rows of the original data, or vector which is then recycled to the number of rows of the original data) of benchmark weights and the asset number. ### Parameters - **object** (goGARCHfilter) - Required - The filter object. - **weights** (matrix/vector) - Required - Benchmark weights. - **asset** (numeric) - Optional - The asset number (default: 1). - **cluster** (NULL) - Optional - Cluster specification. ``` -------------------------------- ### Show Class Structure for 'fScenario' Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Displays the structure of the 'fScenario' class, which is returned by the fscenario function. This class is used for scenario analysis. ```r showClass("fScenario") ``` -------------------------------- ### Fit DCC-GARCH models Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Creates a DCC-GARCH fit object by estimating parameters from the provided data and specification. ```R dccfit(spec, data, out.sample = 0, solver = "solnp", solver.control = list(), fit.control = list(eval.se = TRUE, stationarity = TRUE, scale = FALSE), cluster = NULL, fit = NULL, VAR.fit = NULL, realizedVol = NULL, ...) ``` -------------------------------- ### Multivariate GARCH Distribution Parameters Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html This section details the arguments used for specifying distributions and their parameters in multivariate GARCH models. ```APIDOC ## Arguments for Distribution Specification ### Parameters #### `distribution` - **type**: string - **description**: Specifies the type of multivariate distribution. Accepted values are ‘mvnorm’, ‘mvlaplace’, or ‘mvt’. #### `weights` - **type**: vector or matrix - **description**: Weights to be applied. If a matrix, it must have the same number of rows as the covariance array. #### `mean` - **type**: vector or matrix - **description**: Conditional distribution means. If a matrix, it must have the same number of rows as the covariance array. #### `Sigma` - **type**: array - **description**: Array of covariances, typically obtained from the ‘rcov’ method of a fitted multivariate GARCH object. #### `shape` - **type**: numeric - **description**: The shape (degrees of freedom) parameter for the multivariate student distribution. #### `skew` - **type**: N/A - **description**: Not currently required for the implemented distributions. ### Details This is a convenience function to calculate the weighted variance and mean for three elliptical distributions given a set of weights. ### Value Returns a matrix where each row represents the conditional weighted marginal density with corresponding parameters. ``` -------------------------------- ### Copula-GARCH Simulation Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Method for creating a Copula-GARCH simulation object. ```APIDOC ## Copula-GARCH Simulation ### Description Method for creating a Copula-GARCH simulation object. ### Usage ```R cgarchsim(fit, n.sim = 1000, n.start = 0, m.sim = 1, startMethod = c("unconditional", "sample"), presigma = NULL, preresiduals = NULL, prereturns = NULL, preR = NULL, preQ = NULL, preZ = NULL, rseed = NULL, mexsimdata = NULL, vexsimdata = NULL, cluster = NULL, only.density = FALSE, prerealized = NULL, ...) ``` ### Arguments `fit` | A `cGARCHfit` object created by calling `cgarchfit`. `n.sim` | The simulation horizon. `n.start` | The burn-in sample. `m.sim` | The number of simulations. `startMethod` | Starting values for the simulation. Valid methods are ‘unconditional’ for the expected values given the density, and ‘sample’ for the ending values of the actual data from the fit object. This is mostly related to the univariate GARCH dynamics. `presigma` | Allows the starting sigma values to be provided by the user for the univariate GARCH dynamics. `prereturns` | Allows the starting return data to be provided by the user for the conditional mean simulation. `preresiduals` | Allows the starting residuals to be provided by the user and used in the GARCH dynamics simulation. `preR` | Allows the starting correlation to be provided by the user and mostly useful for the static copula. `preQ` | Allows the starting ‘DCC-Q’ value to be provided by the user and though unnecessary for the first 1-ahead simulation using the “sample” option in the `startMethod`, this is key to obtaining a rolling n-ahead forecast type simulation (see details below). `preZ` | Allows the starting transformed standardized residuals (used in the DCC model) to be provided by the user and though unnecessary for the first 1-ahead simulation using the “sample” option in the `startMethod`, this is key to obtaining a rolling n-ahead forecast type simulation (see details below). `rseed` | Optional seeding value(s) for the random number generator. This should be of length equal to m.sim. `mexsimdata` | A list (equal to the number of assets) of matrices of simulated external regressor-in-mean data with row length equal to n.sim + n.start. If the fit object contains external regressors in the mean equation, this must be provided else will be assumed to be zero. `vexsimdata` | A list (equal to the number of assets) of matrices of simulated external regressor-in-variance data with row length equal to n.sim + n.start. If the fit object contains external regressors in the variance equation, this must be provided else will be assumed to be zero. `cluster` | A cluster object created by calling `makeCluster` from the parallel package. If it is not NULL, then this will be used for parallel estimation (remember to stop the cluster on completion). `only.density` | Whether to return only the simulated returns (discrete time approximation to the multivariate density). This is sometimes useful in order to control memory management for large simulations not requiring any other information. `prerealized` | Allows the starting realized volatility values to be provided by the user for the univariate GARCH dynamics. `...` | Additional arguments passed to methods. ``` -------------------------------- ### Copula-GARCH Fit (cgarchfit) Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Creates a Copula-GARCH fit object. This function estimates the parameters of a Copula-GARCH model. ```APIDOC ## POST /api/cran_r-project_web_packages_rmgarch/cgarchfit ### Description Creates a Copula-GARCH fit object. This function estimates the parameters of a Copula-GARCH model. ### Method POST ### Endpoint /websites/cran_r-project_web_packages_rmgarch/cgarchfit ### Parameters #### Request Body - **spec** (object) - Required - A `cGARCHspec` object created by calling `cgarchspec`. - **data** (xts) - Required - A multivariate xts data object or one which can be coerced to such. - **out.sample** (integer) - Optional - A positive integer indicating the number of periods before the last to keep for out of sample forecasting. - **solver** (string) - Optional - Either “nlminb”, “solnp”, “gosolnp” or “lbfgs”. It can also optionally be a vector of length 2 with the first solver being used for the first stage univariate GARCH estimation. - **solver.control** (list) - Optional - Control arguments list passed to optimizer. - **fit.control** (list) - Optional - Control arguments passed to the fitting routine. The ‘eval.se’ option determines whether standard errors are calculated. The ‘scale’ option is for the first stage univariate GARCH fitting routine. - **cluster** (object) - Optional - A cluster object created by calling `makeCluster` from the parallel package. If it is not NULL, then this will be used for parallel estimation. - **fit** (object) - Optional - A previously estimated univariate `uGARCHmultifit` object from the rugarch package. - **VAR.fit** (list) - Optional - A previously estimated VAR list returned from calling the `varxfit` function. - **spd.control** (list) - Optional - If the spd transformation was chosen in the specification, the spd.control passes its arguments to the `spdfit` routine of the `spd` package. - **realizedVol** (xts) - Optional - Required xts matrix for the realGARCH model. ### Response #### Success Response (200) - **cGARCHfit object** - Contains details of the Copula-GARCH fit. ### Note For extensive examples look in the ‘rmgarch.tests’ folder. ``` -------------------------------- ### betacokurt(object, weights, asset, cluster) Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Returns the cokurtosis beta given a matrix of benchmark weights and the asset number for a goGARCHfilter object. ```APIDOC ## betacokurt ### Description Returns the cokurtosis beta given a matrix (of length equal to the number of rows of the original data, or vector which is then recycled to the number of rows of the original data) of benchmark weights and the asset number. ### Parameters - **object** (goGARCHfilter) - Required - The filter object. - **weights** (matrix/vector) - Required - Benchmark weights. - **asset** (numeric) - Optional - The asset number (default: 1). - **cluster** (NULL) - Optional - Cluster specification. ``` -------------------------------- ### cGARCHfit Methods Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Methods available for the cGARCHfit object, used for fitting Copula-GARCH models. ```APIDOC ## Methods for cGARCHfit ### coef `signature(object = "cGARCHfit")`: Returns the coefficient vector. Additional argument `type` can be 'garch' or 'dcc', or omitted for all parameters. ### fitted `signature(object = "cGARCHfit")`: Returns the conditional mean fitted data as an xts object. ### likelihood `signature(object = "cGARCHfit")`: Returns the joint likelihood. ### rcor `signature(object = "cGARCHfit")`: Returns the conditional correlation array. An `output` argument can switch between 'array' and 'matrix'. ### rcov `signature(object = "cGARCHfit")`: Returns the conditional covariance array. An `output` argument can switch between 'array' and 'matrix'. ### rshape `signature(object = "cGARCHfit")`: Returns the multivariate distribution shape parameter(s). ### rskew `signature(object = "cGARCHfit")`: Returns the multivariate distribution skew parameter(s). ### residuals `signature(object = "cGARCHfit")`: Returns the model residuals as an xts object. ### show `signature(object = "cGARCHfit")`: Displays a summary of the object. ### sigma `signature(object = "cGARCHfit")`: Returns the model conditional sigma as an xts object. ``` -------------------------------- ### DCC-GARCH Simulation Usage Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Method signature for creating a DCC-GARCH simulation object. ```R dccsim(fitORspec, n.sim = 1000, n.start = 0, m.sim = 1, startMethod = c("unconditional", "sample"), presigma = NULL, preresiduals = NULL, prereturns = NULL, preQ = NULL, preZ = NULL, Qbar = NULL, Nbar = NULL, rseed = NULL, mexsimdata = NULL, vexsimdata = NULL, cluster = NULL, VAR.fit = NULL, prerealized = NULL, ...) ``` -------------------------------- ### Forecast Covariance Matrices Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Generates forecast covariance matrices for use in QP based EV models and higher co-moment matrices for the 'gogarch' model in utility maximization models. ```APIDOC ## Forecast Covariance Matrices ### Description Generates forecast covariance matrices for use in QP based EV models and higher co-moment matrices for the 'gogarch' model in utility maximization models. ### Value A `fMoments` object containing the forecast moments (list of length roll+1) and the model details (list). ### Author(s) Alexios Galanos ``` -------------------------------- ### Class fMoments Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Documentation for the fMoments class, which stores forecast moment matrices. ```APIDOC ## Class fMoments ### Description Object returned from calling fmoments, containing forecast moment matrices and model details. ### Slots - **moments** (vector) - A list with the (roll+1) n-ahead forecast moment matrices. - **model** (vector) - A list with details of the data-generating process. ### Methods - **show(object)**: Summary method. - **fitted(object)**: Conditional mean forecast matrix. - **rcov(object)**: Conditional covariance forecast array. - **rcoskew(object)**: Conditional third co-moment array. - **rcokurt(object)**: Conditional fourth co-moment array. ``` -------------------------------- ### POST dccforecast Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Creates a DCC-GARCH forecast object based on a previously fitted DCCfit object. ```APIDOC ## POST dccforecast ### Description Method for creating a DCC-GARCH forecast object. ### Parameters #### Request Body - **fit** (DCCfit) - Required - A DCCfit object created by calling dccfit. - **n.ahead** (integer) - Optional - The forecast horizon. - **n.roll** (integer) - Optional - The number of rolling forecasts to create beyond the first one. - **external.forecasts** (list) - Optional - A list with forecasts for the external regressors in the mean and/or variance equations. - **cluster** (object) - Optional - A cluster object created by calling makeCluster from the parallel package. ### Response #### Success Response (200) - **DCCforecast** (object) - A DCCforecast object containing details of the DCC-GARCH forecast. ``` -------------------------------- ### DCC-GARCH Simulation Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Creates a DCC-GARCH simulation object based on provided fit or specification. ```APIDOC ## POST /dccsim ### Description Method for creating a DCC-GARCH simulation object. ### Method POST ### Parameters #### Request Body - **fitORspec** (object) - Required - The fit or specification object. - **n.sim** (integer) - Optional - Number of simulations. - **n.start** (integer) - Optional - Starting point. - **m.sim** (integer) - Optional - Number of simulation paths. - **startMethod** (string) - Optional - Method for starting values (unconditional or sample). - **presigma** (matrix) - Optional - Pre-simulation sigma values. - **preresiduals** (matrix) - Optional - Pre-simulation residuals. - **prereturns** (matrix) - Optional - Pre-simulation returns. - **preQ** (matrix) - Optional - Pre-simulation Q matrix. - **preZ** (matrix) - Optional - Pre-simulation Z values. - **Qbar** (matrix) - Optional - Qbar matrix. - **Nbar** (matrix) - Optional - Nbar matrix. - **rseed** (integer) - Optional - Random seed. - **mexsimdata** (list) - Optional - External regressor data for mean. - **vexsimdata** (list) - Optional - External regressor data for variance. - **cluster** (cluster) - Optional - Parallel cluster object. - **VAR.fit** (object) - Optional - VAR fit object. - **prerealized** (matrix) - Optional - Pre-simulation realized values. ``` -------------------------------- ### VARX Model Fitting, Filtering, Forecasting, and Simulation Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html These functions provide tools for fitting VARX models, filtering time series data, forecasting future values, and simulating conditional means. ```APIDOC ## VARX Model Functions ### Description Convenience functions to be optionally used when using the multivariate GARCH methods. These include fitting, filtering, forecasting, and simulating VARX models. ### Usage ```R varxfit(X, p, constant = TRUE, exogen = NULL, robust = FALSE, gamma = 0.25, delta = 0.01, nc = 10, ns = 500, postpad = c("none", "constant", "zero", "NA"), cluster = NULL) varxfilter(X, p, Bcoef, exogen = NULL, postpad = c("none", "constant", "zero", "NA")) varxforecast(X, Bcoef, p, out.sample, n.ahead, n.roll, mregfor) varxsim (X, Bcoef, p, n.sim, n.start, prereturns, resids, mexsimdata) ``` ### Arguments - **X** (matrix) - A multivariate data matrix. - **p** (numeric) - The number of autoregressive lags. - **constant** (logical) - Whether to include a constant. Defaults to TRUE. - **exogen** (matrix) - An optional matrix of exogenous regressors with as many rows as X, and appropriately lagged. - **robust** (logical) - Whether to use the robust version of VAR based on the multivariate Least Trimmed Squares Estimator. Defaults to FALSE. - **gamma** (numeric) - Proportion to trim in the robust method. Defaults to 0.25. - **delta** (numeric) - The critical value for Reweighted estimator for the robust method. Defaults to 0.01. - **ns** (numeric) - The number of subsets to use for the robust method. Defaults to 500. - **nc** (numeric) - The number of C-steps to use for the robust method. Defaults to 10. - **postpad** (character) - Defaults to 'none'. Whether to postpad the fitted/filtered values with the estimated constant, zeros or NA's, thus returning matrices of the same size as the input data. - **cluster** (object) - A cluster object created by calling `makeCluster` from the parallel package. If not NULL, used for parallel estimation in the robust VAR version. - **out.sample** (numeric) - The number of points kept for out of sample rolling forecast. - **n.ahead** (numeric) - The forecast horizon. - **n.roll** (numeric) - In combination with `out.sample`, determines the number of times to roll forward the n.ahead forecast using data left out of sample. - **mregfor** (matrix) - Matrix of external regressor forecasts (with appropriate lag structure). - **Bcoef** (matrix) - A matrix of coefficients for the varxfilter function. - **n.sim** (numeric) - Simulation horizon. - **n.start** (numeric) - Simulation burn-in sample. - **prereturns** (matrix) - Optionally supplied pre-return matrix with “p” lags to initialize simulation. - **resids** (matrix) - Matrix of randomly generated residuals of size n.sim+n.start. - **mexsimdata** (matrix) - Matrix of external regressor pre-generated random values to use in the simulation (if NULL then assumed zero). ### Value A list with the following items: - **Bcoef** (matrix) - [varxfit, varxfilter] The coefficient matrix. - **xfitted** (matrix) - [varxfit, varxfilter] The fitted/filtered series (conditional mean series). - **xresiduals** (matrix) - [varxfit, varxfilter] The residuals. - **Bcov** (matrix) - [varxfit] The covariance matrix of the coefficients. - **se** (matrix) - [varxfit] The standard error of the coefficients. - **tstat** (matrix) - [varxfit] The t-stat of the s.e. - **pstat** (matrix) - [varxfit] The p-values of the s.e. - **lag** (numeric) - [varxfit, varxfilter] The number of autoregressive lags. - **mxn** (numeric) - [varxfit] The number of exogenous regressors. - **meansim** (matrix) - [varxsim] The simulated conditional mean. The `varxsim` returns an n.sim x n.asset matrix of the simulated conditional means, while `varxforecast` returns an n.ahead x n.assets x (n.roll+1) array of the forecast conditional means. ### Note Part of the `varxfit` functionality and structure is inspired from the 'vars' package. The robust method is based on the matlab program of Christophe Croux. The `postpad` option is used when the returned data needs to be of the same size as the inputed data for easier manipulation/comparison. ### Author(s) Alexios Galanos ### References - Lutkepohl, H. 2005, New introduction to multiple time series analysis, Springer. - Croux, C. and Joossens, K. 2008, Robust estimation of the vector autoregressive model by a least trimmed squares procedure, COMPSTAT, 489–501. ``` -------------------------------- ### VARX Fit/Filter/Forecast/Simulation Functions Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Provides functions for fitting, filtering, forecasting, and simulating Vector Autoregressive (VAR) models with Constant and Optional Exogenous Regressors (X), intended for use with multivariate GARCH models. ```APIDOC ## VARX Fit/Filter/Forecast/Simulation Functions ### Description Vector Autoregressive (VAR) with Constant and Optional Exogenous Regressors (X) Fit, Filter, Forecast and Simulation functions for use with multivariate GARCH models. ### Details This section provides functions for advanced time series analysis using VARX models, particularly in conjunction with multivariate GARCH models. It enables comprehensive analysis including model fitting, filtering of historical data, forecasting future values, and simulating potential future paths of the time series. ### Value (Details on the specific return values of these functions are not provided in the source text.) ### Examples (No specific examples are provided in the source text for these functions.) ``` -------------------------------- ### GO-GARCH portfolio density Class Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Defines the class for the GO-GARCH portfolio density. ```APIDOC ## Class: GO-GARCH portfolio density ### Description Class for the GO-GARCH portfolio density ``` -------------------------------- ### cGARCHsim Class Methods Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Methods for the cGARCHsim class, which represents simulated Copula-GARCH data. ```APIDOC ## Methods for cGARCHsim ### fitted `signature(object = "cGARCHsim")`: Returns the simulated conditional returns matrix. Takes an optional `sim` argument to specify the simulation run. ### sigma `signature(object = "cGARCHsim")`: Returns the simulated conditional sigma matrix. Takes an optional `sim` argument to specify the simulation run. ### rcor `signature(object = "cGARCHsim")`: Returns the simulated conditional correlation array (for DCC type). Takes an optional `sim` argument. An `output` argument can switch between 'array' and 'matrix'. ### rcov `signature(object = "cGARCHsim")`: Returns the simulated conditional covariance array. Takes an optional `sim` argument. An `output` argument can switch between 'array' and 'matrix'. ### show `signature(object = "cGARCHsim")`: Displays a summary of the object. ``` -------------------------------- ### likelihood Source: https://cran.r-project.org/web/packages/rmgarch/refman/rmgarch.html Calculates the quasi log-likelihood of the GO-GARCH model. ```APIDOC ## likelihood goGARCHfilter ### Description The quasi log-likelihood of the model, which being an independent factor model is the sum of the univariate GARCH log-likelihoods plus a term for the mixing matrix. For a dimensionality reduced system, this is NA. ### Method `likelihood` ### Parameters #### Path Parameters None #### Query Parameters - **object** (goGARCHfilter) - The goGARCHfilter object. ### Request Example ```R # Assuming 'fit' is a goGARCHfilter object likelihood(fit) ``` ### Response #### Success Response (200) The quasi log-likelihood value (numeric) or NA. ```