fGarch/0000755000176200001440000000000015116757102011451 5ustar liggesusersfGarch/tests/0000755000176200001440000000000015104730075012610 5ustar liggesusersfGarch/tests/doRUnit.R0000644000176200001440000000151615104730075014322 0ustar liggesusers#### doRUnit.R --- Run RUnit tests ####------------------------------------------------------------------------ ### Origianlly follows Gregor Gojanc's example in CRAN package 'gdata' ### and the corresponding section in the R Wiki: ### http://wiki.r-project.org/rwiki/doku.php?id=developers:runit ### MM: Vastly changed: This should also be "runnable" for *installed* ## package which has no ./tests/ ## ----> put the bulk of the code e.g. in ../inst/unitTests/runTests.R : if(require("RUnit", quietly = TRUE)) { ## --- Setup --- wd <- getwd() pkg <- sub("\\.Rcheck$", '', basename(dirname(wd))) library(package=pkg, character.only = TRUE) path <- system.file("unitTests", package = pkg) stopifnot(file.exists(path), file.info(path.expand(path))$isdir) source(file.path(path, "runTests.R"), echo = TRUE) } fGarch/MD50000644000176200001440000001466015116757102011770 0ustar liggesusers8ddf42e368503fb9cb47500e2e44adab *ChangeLog 4f71371d19e7d6fd2e807b2d8c7fd134 *DESCRIPTION 5e5b16b802185cb5c6bd6bd0e3135dd0 *NAMESPACE d01b5402eed9f3c05bc089883b40bb3c *NEWS.md c7a13a689bb6a905b6bbd9d191c7f0df *R/class-fGARCH.R 0eb2fa2612486d6e24b7ca89f27003c2 *R/class-fGARCHSPEC.R aaf7406e83fe74c1c684f7ae6d43f9e7 *R/cvar-VaR.R 97a094a106805ce33f4621ed5082266b *R/dist-absMoments.R 7b40285ba3f868b015ff905335f6d1df *R/dist-ged.R c4703f63fc51a3420476e610ab77c7b2 *R/dist-gedFit.R d35be82ca2b203f6e3ecb0678d6f2fb1 *R/dist-gedSlider.R 63642d3ad7536e4fa55e82e7eaa0593e *R/dist-sged.R cd5ff5e91cc2ed186ec0e60cabb16661 *R/dist-sgedFit.R f4b5d342a48c57b36f4a98a08f637e56 *R/dist-sgedSlider.R 485ae781212f3a00ffefd12dc1659815 *R/dist-snorm.R ec77009ba98b3bc98362da3e9812d7e0 *R/dist-snormFit.R 0c71233088546c742adfa6de041994d1 *R/dist-snormSlider.R 2835e2bd72ebd6989b091bd0a6f13347 *R/dist-sstd.R 2a8ac9d4ac150fa20428fdaf62281ab7 *R/dist-sstdFit.R 7e19de8d0b578ea3171bc050fd81784a *R/dist-sstdSlider.R 97fbe5d8149c1a0ff7cca075826c4c5f *R/dist-std.R de9f483be2041746c02cf755fd367145 *R/dist-stdFit.R d06897dd68e8f25e9678913e4bd4fa90 *R/dist-stdSlider.R 224624b554b51119fc6e56b3d489277c *R/fGarch-package.R 9741bff5bd063d83445d8457cbfb9f28 *R/fGarchEnv.R 049762f686f27bcb47b7838830e277d1 *R/garch-Distribution.R 2ac7c7d170ecd4434eb201e4d04ec7bf *R/garch-FitFromFormula.R d399b6182fe861dfef382d8428f56256 *R/garch-FitFromSpec.R c0e91199a1630adf9eff532496639380 *R/garch-FitInternal.R fff4d1f43e02a27c8dbb7f3a878158a7 *R/garch-GlobalVars.R 9556d8f69fddef06228e47462fbe19ea *R/garch-Gradient.R dd3e449a6b3875a242357390634738af *R/garch-Hessian.R e1b1fa3c676e0da11af6333cdaba9361 *R/garch-Initialization.R 2e36274f7c8891fc1c72083717a3d327 *R/garch-Sim.R d02bb65ed394232775cc7a65bec1c7a3 *R/garch-Solver.R effee1524457176e544a4159f06f9e65 *R/garch-SolverControl.R 774e7a534931a660f39b489e03503518 *R/garch-Spec.R b4c216db11d187be7b33a1b9208abcb5 *R/garch-Stats.R a0af43ada8cf98ae21ff931574f48317 *R/loglik-aparch.R 85dbb41d543618dd30d9b0514794a3b0 *R/loglik-egarch.R 6377dd1ccf33c655fd9163dd5511a4d0 *R/loglik.R 39efcefff0257a13ba13c2807d1c0b6c *R/methods-coef.R 1b8a1beeea7a7a993a169b0baf7e09f0 *R/methods-fitted.R 7f19cf78ce22bbab0b2322e96def3b39 *R/methods-formula.R 0011a6dd0b46cd74862cdc949cb2404a *R/methods-plot.R 4e940d8bba28b0a04f043c87b5fc7b28 *R/methods-predict.R c46ae3e7eb3ca4eaffbf35b6be00ab35 *R/methods-residuals.R 0d6e705fa0f87f27e5d42c9b2f0e1094 *R/methods-show.R c587c956b776ee0bbc21f6addb03bd47 *R/methods-summary.R 2a8962e41ed5a4de63d2fe649a9e12e3 *R/methods-update.R 1b223cf816ecee7b9fe1d26245fe9baa *R/methods-volatility.R 8da3513457c3bc1ac9d1edd0ef14d5c1 *R/mgarch-FitFromFormula.R 9edf9566b34ba6611b26b3639b8c4c04 *R/stats-tsdiag.R 5ba9ac762a4cd5bae7ed6ed15ea799f5 *R/zzz.R f30845041a4823f724f0d700b9fde7ad *README.md 48656f3176e3fe01ac9c3107ccd8cdef *build/partial.rdb fe75772d65e05a3b189023e372d3d1a2 *data/dem2gbp.csv.gz 58bbdc46c698bc7b97657229e8de1277 *data/sp500dge.csv.gz ea951cd95578aafc953dcd33c7e2631d *inst/NEWS.Rd 70a0d93bc75a19be75bdab2f50fc48a0 *inst/THANKS e7fedc2a130e66921ef3314fed34631c *inst/_pkgdown.yml 7c03c7017fafaa655d97074e21aa087b *inst/pkgdown.yml 665e719c6c9360340268b2e6ac891515 *inst/unitTests/Makefile 6daf0e9de9a62ce7c24edd2e9cd2f7e1 *inst/unitTests/runTests.R 8fa067e349485ddf6c94644cde5e3767 *inst/unitTests/runit.bugfix_6061.R 464451cc881cb5d016b445a5aa1dafb0 *inst/unitTests/runit.formula-methods.R 34ce038d4e5a9b92efb5c01751078296 *inst/unitTests/runit.garch-methods.R 14316d3164dc2ef549773a1197e97f34 *inst/unitTests/runit.garchFit.R 1bbc596063ca7584964b89c23608cb83 *inst/unitTests/runit.garchFit.algorithm.R 3107d6eaf4651d41432ccc76fbf01c6a *inst/unitTests/runit.garchFit.aparch.R e2e025242284f7379f314d39fe81e7ef *inst/unitTests/runit.garchFit.dist.R 5d9915d560e060cbfda0b531129f167d *inst/unitTests/runit.garchFit.faked.R b3764d2f99905a0c9d787c1f79484742 *inst/unitTests/runit.garchFit.garch.R cc8a22d3718b70390d1ad14e36e4ac11 *inst/unitTests/runit.garchFit.init.R 1807810452bb1abf15dd3ea36eedb5d8 *inst/unitTests/runit.garchHessian.R 0cd0ecf3aebbea146c02c31b3f517af1 *inst/unitTests/runit.garchSim.R 9fd027295b05fa559e7db79b2cb01be0 *inst/unitTests/runit.garchSolver.R d0df67b7fcd6fd58444049b69c29c2ec *inst/unitTests/runit.garchSpec.R 2db651c11a011446c606514d5022edbc *inst/unitTests/runit.plot-methods.R afeb0877a73a8b55095082caca3a9f40 *inst/unitTests/runit.predict-methods.R 37173cf965fe63542466f8af50a12fbd *inst/unitTests/runit.sged.R c5d4c5fc8f4880e61c1a3880e79bfba3 *inst/unitTests/runit.snorm.R dff8337ddb27e8865b4eb21996feff85 *inst/unitTests/runit.sstd.R 8d008c88b4056574c5ac40778b80c379 *man/00fGarch-package.Rd 118fc8bc9680e4e0aad2e0aae1163803 *man/VaR.Rd f0a337a3484a722d92902d7b5cdf846c *man/class-fGARCH.Rd 4259f79090ebc2e6b4fe246077776660 *man/class-fGARCHSPEC.Rd e859dfb8a543235ee8136cfb19125146 *man/class-fUGARCHSPEC.Rd 9f9a9806ab4f5a405f881764f768e18b *man/dist-Slider.Rd 7ded9413775d3b586593f53276e5525e *man/dist-absMoments.Rd 9f1673b3c1faf59873cd026523f5664e *man/dist-ged.Rd 20b8bb2c1fbdedda8b10db9d2219913a *man/dist-gedFit.Rd e58c8b6adcc7d83607bf3dbd30a2af4b *man/dist-sged.Rd 9b504e5799e7dc35479f82b4f8a0201f *man/dist-sgedFit.Rd d534007524a59bc0c13d8174fbd72b73 *man/dist-snorm.Rd dc8100d0a9975a84474534090807c201 *man/dist-snormFit.Rd 0144fde616bd439e681db26c76bf835f *man/dist-sstd.Rd 632e4579ffecb01795b4eb8efc076d1d *man/dist-sstdFit.Rd 37920c4de3cce5bab86c09c8fef50f7b *man/dist-std.Rd 294cd0c453c9c72af72fd8638d6485cd *man/dist-stdFit.Rd 9b30944f18aa44177f839db277e54717 *man/fGarchData.Rd e85b4974798bb5d6637814ad3e5f426c *man/garchFit.Rd e42ca3cab6d4fd30ba35675dc3d61513 *man/garchFitControl.Rd bd2e01e7b5db33dee913d05580197d2c *man/garchSim.Rd e77727456ad53183a9242d4b4b80d800 *man/garchSpec.Rd 277ae00d2592b628be2e554b2d404c2c *man/methods-coef.Rd e877368b273d1e1bd371b8848ed5fac0 *man/methods-fitted.Rd 85f72b13fe76ad9cb64dc64b0d520ac7 *man/methods-formula.Rd 5eb9400992905923967f0abfe64037d1 *man/methods-plot.Rd 4dd9a93782b34638ffc62b0ca8ac4ad8 *man/methods-predict.Rd eeed6ad45deab1e23d6fea0e42fbb2f0 *man/methods-residuals.Rd 5571ad61183ead5d70f46606493f0e15 *man/methods-summary.Rd d58a80a99aa551ad469ab40587edf152 *man/methods-volatility.Rd 35d8fdda60e66294a99cf4cb39776aae *man/stats-tsdiag.Rd 3996e7c16bfb96fad295ee425815cb4d *src/Makevars 4276e1893140fa52dab90c5f041511b0 *src/dist.f fce86d34d35e081f121901a423fc4bf1 *src/init.c ef9c63dfb10dc8f4460e339354e73ce5 *src/llhGarch.f 39ec04391b2bb400783da91b890d064c *src/math.f ca566e590ec30abd0718c5375e1a446f *tests/doRUnit.R fGarch/R/0000755000176200001440000000000015116747657011670 5ustar liggesusersfGarch/R/garch-FitInternal.R0000644000176200001440000003356015104730075015302 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .garchFit Internal GARCH Fit # .garchArgsParser Parses formula and data for garchFit # .garchModelSeries Composes model series like in lm fits # .garchOptimizerControl Sets default values for Garch Optimizer # .garchNames Slot names, @fit slot, parameters and controls ################################################################################ ## called from garchFit() and .ugarchFit() .garchFit <- function( formula.mean = ~arma(0, 0), formula.var = ~garch(1, 1), series, init.rec = c("mci", "uev"), delta = 2, skew = 1, shape = 4, cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "QMLE"), include.mean = TRUE, include.delta = NULL, include.skew = NULL, include.shape = NULL, leverage = NULL, trace = TRUE, algorithm = c("sqp", "nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), hessian = c("ropt", "rcd"), robust.cvar, control = list(), title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description # Fit parameters to a ARMA-GARCH model # Arguments: # formula.mean - ARMA(m,n) mean specification # formula.var - GARCH/APARCH(p,q) variance specification # series - time series # init.rec - names type of initialization of recurrence # mci = mu-current-iteration, or # uev = unconditional-expected-variances # delta - numeric value of the exponent delta # skew - optional skewness parameter # shape - optional shape parameter # cond.dist - name of the conditional distribution # include.mean - should the mean value be estimated ? # include.delta - should the exponent be estimated ? # leverage - should the leverage factors be estimated ? # trace - should the optimization be traced ? # algorithm - # control - list of additional control parameters for solver # title - an optional title string # description - an optional project description string # Note: # This is the old version of garchFit, we keep it for backward # compatibility. # FUNCTION: # Debug Mode: DEBUG <- FALSE # Allow only full formula specification: if(DEBUG) print("Formula Specification ...") fcheck = rev(all.names(formula.mean))[1] if (fcheck == "ma") { stop("Use full formula: arma(0,q) for ma(q)") } else if (fcheck == "ar") { stop("Use full formula expression: arma(p,0) for ar(p)") } # Check for Recursion Initialization: if(DEBUG) print("Recursion Initialization ...") if(init.rec[1] != "mci" & algorithm[1] != "sqp") { stop("Algorithm only supported for mci Recursion") } # Get Start Time: .StartFit <- Sys.time() # Generate Control List - Define Default Settings: if(DEBUG) print("Generate Control List ...") con <- .garchOptimizerControl(algorithm, cond.dist) con[(namc <- names(control))] <- control # Initialize Time Series Information - Save Globally: # keep copy of input data if(DEBUG) print("Initialize Time Series ...") data <- series # scale time series scale <- if (con$xscale) sd(series) else 1 series <- series/scale .series <- .garchInitSeries( formula.mean = formula.mean, formula.var = formula.var, cond.dist = cond.dist[1], series = series, scale = scale, init.rec = init.rec[1], h.start = NULL, llh.start = NULL, trace = trace) .setfGarchEnv(.series = .series) # Initialize Model Parameters - Save Globally: if(DEBUG) print("Initialize Model Parameters ...") .params <- .garchInitParameters( formula.mean = formula.mean, formula.var = formula.var, delta = delta, skew = skew, shape = shape, cond.dist = cond.dist[1], include.mean = include.mean, include.delta = include.delta, include.skew = include.skew, include.shape = include.shape, leverage = leverage, algorithm = algorithm[1], control = con, trace = trace) .setfGarchEnv(.params = .params) # Select Conditional Distribution Function: if(DEBUG) print("Select Conditional Distribution ...") .setfGarchEnv(.garchDist = .garchSetCondDist(cond.dist[1])) # Estimate Model Parameters - Minimize llh, start from big value: if(DEBUG) print("Estimate Model Parameters ...") .setfGarchEnv(.llh = 1.0e99) .llh <- .getfGarchEnv(".llh") fit = .garchOptimizeLLH(hessian, robust.cvar, trace) # Add to Fit: if (DEBUG) print("Add to fit ...") .series <- .getfGarchEnv(".series") .params <- .getfGarchEnv(".params") names(.series$h) <- NULL fit$series = .series fit$params = .params # Retrieve Residuals and Fitted Values: if (DEBUG) print("Retrieve Residuals and Fitted Values ...") residuals = .series$z fitted.values = .series$x - residuals h.t = .series$h deltainv <- 1/(if(.params$includes["delta"]) fit$par["delta"] else fit$params$delta) sigma.t = (.series$h)^deltainv # Standard Errors and t-Values: if (DEBUG) print("Standard Errors and t-Values ...") fit$cvar <- if (robust.cvar) (solve(fit$hessian) %*% (t(fit$gradient) %*% fit$gradient) %*% solve(fit$hessian)) else - solve(fit$hessian) fit$se.coef = sqrt(diag(fit$cvar)) fit$tval = fit$coef/fit$se.coef fit$matcoef = cbind(fit$coef, fit$se.coef, fit$tval, 2*(1-pnorm(abs(fit$tval)))) dimnames(fit$matcoef) = list(names(fit$tval), c(" Estimate", " Std. Error", " t value", "Pr(>|t|)")) # Add Title and Description: if (DEBUG) print("Add Title and Description ...") if(is.null(title)) title = "GARCH Modelling" if(is.null(description)) description = description() # {timeSeries} # Total Execution Time: Time = Sys.time() - .StartFit if(trace) { cat("\nTime to Estimate Parameters:\n ") print(Time) } # Return Value: new("fGARCH", call = as.call(match.call()), formula = formula(paste("~", formula.mean, "+", formula.var, collapse = " ")), method = "Max Log-Likelihood Estimation", data = data, fit = fit, residuals = residuals, fitted = fitted.values, h.t = h.t, sigma.t = as.vector(sigma.t), title = as.character(title), description = as.character(description) ) } # ------------------------------------------------------------------------------ .garchArgsParser <- function(formula, data, trace = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Parses formula and data for garchFit # Arguments: # formula - ARMA(m,n) + GARCH/APARCH(p,q) mean and variance # specification # data - time series input as a timeSeries # Note: # This function returns the input formula and input data in # proper formats. Two cases are deistinguished # FUNCTION: # Get Data: allVars = unique(sort(all.vars(formula))) allVarsTest = mean(allVars %in% colnames(data)) if (allVarsTest != 1) { print(allVars) print(colnames(data)) stop ("Formula and data units do not match.") } formula.lhs = as.character(formula)[2] # Model frame: mf = match.call(expand.dots = FALSE) if(trace) { cat("\nMatched Function Call:\n ") print(mf) } m = match(c("formula", "data"), names(mf), 0) mf = mf[c(1, m)] # Model the timeSeries - Have a look on the function .garchModelSeries() ... # here we cant use "model/frame" ! mf[[1]] = as.name(".garchModelSeries") mf$fake = FALSE mf$lhs = TRUE if(trace) { cat("\nModelSeries Call:\n ") print(mf) } x = eval(mf, parent.frame()) if(trace) print(x) # Now extract the modelled series ... x = as.vector(x[, 1]) names(x) = rownames(data) if(trace) print(x) # Compose Mean and Variance Formula: allLabels = attr(terms(formula), "term.labels") if(trace) { cat("\nAll Term Labels:\n ") print(allLabels) } if(length(allLabels) == 2) { formula.mean = as.formula(paste("~", allLabels[1])) formula.var = as.formula(paste("~", allLabels[2])) } else if(length(allLabels) == 1) { formula.mean = as.formula("~ arma(0, 0)") formula.var = as.formula(paste("~", allLabels[1])) } if(trace) { cat("\nMean Formula:\n ") print(formula.mean) cat("\nVariance Formula:\n ") print(formula.var) } # Result: ans <- list( formula.mean = formula.mean, formula.var = formula.var, formula.lhs = formula.lhs, series = x) # Return Value: ans } # ------------------------------------------------------------------------------ .garchModelSeries <- function (formula, data, fake = FALSE, lhs = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Composes model series like in lm fits # Arguments: # Note: # ... have a look on model.frame() # FUNCTION: # Formula: if (length(formula) == 2) { formula = as.formula(paste("x", formula[1], formula[2], collapse = "")) stopifnot(!missing(data)) } # Missing Data ? if (missing(data)) { data = eval(parse(text = search()[2]), parent.frame()) } # Numeric Data ? if (is.numeric(data)) { data = data.frame(data) colnames(data) = all.vars(formula)[1] lhs = TRUE } # Faked Formula ? if (fake) { response = as.character(formula)[2] Call = as.character(match.call()[[2]][[3]]) method = Call[1] predictors = Call[2] formula = as.formula(paste(response, "~", predictors)) } # Left-Hand-Side Formula ? if (lhs) { response = as.character(formula)[2] formula = as.formula(paste(response, "~", 1)) } # Compose Model Frame: x = model.frame(formula, data) # timeSeries ? if (inherits(data, "timeSeries")) x = timeSeries(x) # Add control atrribute: if (fake) { attr(x, "control") <- method } # Return Value: x } # ------------------------------------------------------------------------------ .garchOptimizerControl <- function(algorithm, cond.dist) # function(algorithm, cond.dist) { # A function implemented by Diethelm Wuertz # Description: # Sets default values for Garch Optimizer # Arguments: # none # FUNCTION: # Check llh for the standardized NIG Distribution: llh = "internal" if (cond.dist == "snig") llh = "filter" # Generate Control List with Default Settings: con <- list( # In General: fscale = TRUE, xscale = TRUE, algorithm = algorithm, llh = llh, # BFGS - NLMINB Algorithm: tol1 = 1, tol2 = 1, # SQP Algorithm: MIT = 2000, # maximum number of iterations (200) MFV = 5000, # maximum number of function evaluations (500) MET = 5, # specifies scaling strategy: # MET=1 - no scaling # MET=2 - preliminary scaling in 1st iteration (default) # MET=3 - controlled scaling # MET=4 - interval scaling # MET=5 - permanent scaling in all iterations MEC = 2, # correction for negative curvature: # MEC=1 - no correction # MEC=2 - Powell correction (default) MER = 1, # restarts after unsuccessful variable metric updates: # MER=0 - no restarts # MER=1 - standard restart MES = 4, # interpolation method selection in a line search: # MES=1 - bisection # MES=2 - two point quadratic interpolation # MES=3 - three point quadratic interpolation # MES=4 - three point cubic interpolation (default) XMAX = 1.0e3, TOLX = 1.0e-10, TOLC = 1.0e-6, TOLG = 1.0e-6, TOLD = 1.0e-6, TOLS = 1.0e-4, RPF = 1.0e-2) # 1.0e-4) # Return Value: con } # ------------------------------------------------------------------------------ .garchNames <- function(object) { # A function implemented by Diethelm Wuertz # Description: # Print slot names, @fit slot, parameters and controls # Arguments: # object - an object of class 'fGARCH' # FUNCTION: # Slot Names: cat("\nNames - @ \n") print(slotNames(object)) # @fit Slot: cat("\nNames - @fit \n") print(names(object@fit)) # Parameters: cat("\nNames - @fit$params \n") print(names(object@fit$params)) # Control: cat("\nNames - @fit$params$control \n") print(names(object@fit$params$control)) # Return Value: invisible() } ################################################################################ fGarch/R/garch-Solver.R0000644000176200001440000001233215104730075014327 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: SOLVER: # .garchRnlminb R coded solver nlmin # .garchRlbgfsb R coded solver optim using method lbgfsb # .garchRnm R coded solver nm as hybrid addon ################################################################################ .garchRnlminb <- function(.params, .series, .garchLLH, trace) { # A function implemented by Diethelm Wuertz # Description: # Port3 nlminb R-code Solver # Arguments: # FUNCTION: # Port3 nlminb R-code Solver: if(trace) cat("\nR coded nlminb Solver: \n\n") # Scale Function and Parameters: INDEX = .params$index parscale = rep(1, length = length(INDEX)) names(parscale) = names(.params$params[INDEX]) parscale["omega"] = var(.series$x)^(.params$delta/2) parscale["mu"] = abs(mean(.series$x)) # Control: TOL1 = .params$control$tol1 # Fit Parameters - par | objective: fit <- nlminb( start = .params$params[INDEX], objective = .garchLLH, lower = .params$U[INDEX], upper = .params$V[INDEX], scale = 1/parscale, control = list( eval.max = 2000, iter.max = 1500, rel.tol = 1.0e-14 * TOL1, x.tol = 1.0e-14 * TOL1, trace = as.integer(trace)), fGarchEnv = FALSE) # to speed up .garchLLH fit$value <- fit.llh <- fit$objective names(fit$par) = names(.params$params[INDEX]) # make sure to save new h and z (important to speed up code) .garchLLH(fit$par, trace = FALSE, fGarchEnv = TRUE) # Result: fit$coef <- fit$par fit$llh <- fit$objective # Return Value: fit } # ------------------------------------------------------------------------------ .garchRlbfgsb <- function(.params, .series, .garchLLH, trace) { # A function implemented by Diethelm Wuertz # Description: # optim[L-BFGS-B] Solver # Arguments: # FUNCTION: # optim[L-BFGS-B] Solver: if(trace) cat("\nR coded optim[L-BFGS-B] Solver: \n\n") # Scale Function and Parameters: INDEX = .params$index parscale = rep(1, length = length(INDEX)) names(parscale) = names(.params$params[INDEX]) parscale["omega"] = var(.series$x)^((.params$params["delta"])/2) # Control: TOL1 = .params$control$tol1 # Fit Parameters - par, value: fit <- optim( par = .params$params[INDEX], fn = .garchLLH, lower = .params$U[INDEX], upper = .params$V[INDEX], method = "L-BFGS-B", control = list( parscale = parscale, lmm = 20, pgtol = 1.0e-11 * TOL1, factr = 1.0 * TOL1, trace = as.integer(trace)), fGarchEnv = FALSE) # to speed up .garchLLH names(fit$par) = names(.params$params[INDEX]) # make sure to save new h and z (important to speed up code) .garchLLH(fit$par, trace = FALSE, fGarchEnv = TRUE) # Print Hessian Matrix: # print(fit$hessian) # Add to Result: fit$coef = fit$par fit$llh = fit$value # Return Value: fit } # ------------------------------------------------------------------------------ .garchRnm <- function(.params, .series, .garchLLH, trace) { # A function implemented by Diethelm Wuertz # Description: # Nelder-Mead as Hybrid Solver # Arguments: # FUNCTION: # Nelder-Mead as Hybrid Solver: if(trace) cat("\nR coded Nelder-Mead Hybrid Solver: \n\n") # Scale Function and Parameters: INDEX = .params$index fnscale = abs(.params$llh) parscale = abs(.params$params[INDEX]) # Control: TOL2 = .params$control$tol2 # Fit Parameters: fit = optim( par = .params$params[INDEX], fn = .garchLLH, method = "Nelder-Mead", control = list( ndeps = rep(1e-14*TOL2, length = length(INDEX)), maxit = 10000, reltol = 1.0e-11 * TOL2, fnscale = fnscale, parscale = c(1, abs((.params$params[INDEX])[-1])), trace = as.integer(trace)), hessian = TRUE, fGarchEnv = FALSE) # to speed up .garchLLH names(fit$par) = names(.params$params[INDEX]) # Make sure to save new h and z: (important to speed up code) .garchLLH(fit$par, trace = FALSE, fGarchEnv = TRUE) # Result: fit$coef = fit$par fit$llh = fit$value # Return Value: fit } ################################################################################ fGarch/R/dist-ged.R0000644000176200001440000000727115104730075013501 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: GED DISTRIBUTION: # dged Density for the Generalized Error Distribution # pged Probability function for the GED # qged Quantile function for the GED # rged Random Number Generator for the GED ################################################################################ dged <- function(x, mean = 0, sd = 1, nu = 2, log = FALSE) { # A function imlemented by Diethelm Wuertz # Description: # Compute the density for the # generalized error distribution. # FUNCTION: # Params: if (length(mean) == 3) { nu = mean[3] sd = mean[2] mean = mean[1] } # Compute Density: z = (x - mean ) / sd lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) g = nu / ( lambda * (2^(1+1/nu)) * gamma(1/nu) ) result = g * exp (-0.5*(abs(z/lambda))^nu) / sd # Log: if(log) result = log(result) # Return Value result } # ------------------------------------------------------------------------------ pged <- function(q, mean = 0, sd = 1, nu = 2) { # A function implemented by Diethelm Wuertz # Description: # Compute the probability for the # generalized error distribution. # FUNCTION: # Compute Probability: q = (q - mean ) / sd lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) g = nu / ( lambda * (2^(1+1/nu)) * gamma(1/nu) ) h = 2^(1/nu) * lambda * g * gamma(1/nu) / nu s = 0.5 * ( abs(q) / lambda )^nu result = 0.5 + sign(q) * h * pgamma(s, 1/nu) # Return Value: result } # ------------------------------------------------------------------------------ qged <- function(p, mean = 0, sd = 1, nu = 2) { # A function implemented by Diethelm Wuertz # Description: # Compute the quantiles for the # generalized error distribution. # FUNCTION: # Compute Quantiles: lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) q = lambda * (2*qgamma((abs(2*p-1)), 1/nu))^(1/nu) result = q*sign(2*p-1) * sd + mean # Return Value: result } # ------------------------------------------------------------------------------ rged <- function(n, mean = 0, sd = 1, nu = 2) { # A function implemented by Diethelm Wuertz # Description: # Generate GED random deviates. The function uses the # method based on the transformation of a Gamma random # variable. # FUNCTION: # Generate Random Deviates: lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) # print(lambda) r = rgamma(n, 1/nu) z = lambda * (2*r)^(1/nu) * sign(runif(n)-1/2) result = z * sd + mean # Return Value: result } ################################################################################ fGarch/R/fGarchEnv.R0000644000176200001440000000357515104730075013647 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .fGarchEnv Create GARCH Environment # .setfGarchEnv Set GARCH Environment # .getfGarchEnv Get GARCH Environment ################################################################################ .fGarchEnv <- new.env(hash = TRUE) # ------------------------------------------------------------------------------ .setfGarchEnv <- function(...) { x <- list(...) nm <- names(x) if (is.null(nm) || "" %in% nm) stop("all arguments must be named") sapply(nm, function(nm) assign(nm, x[[nm]], envir = .fGarchEnv)) invisible() } # ------------------------------------------------------------------------------ .getfGarchEnv <- function(x = NULL, unset = "") { if (is.null(x)) x <- ls(all.names = TRUE, envir = .fGarchEnv) ### unlist(mget(x, envir = .fGarchEnv, mode = "any", ### ifnotfound = as.list(unset)), recursive = FALSE) get(x, envir = .fGarchEnv, mode = "any") } ################################################################################ fGarch/R/dist-sstdSlider.R0000644000176200001440000000716015104730075015057 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # sstdSlider Displays Variance-1 Student-t Distribution and RVS ################################################################################ sstdSlider <- function(type = c("dist", "rand")) { # A function implemented by Diethelm Wuertz # Description: # Displays interactively skew Student-t distribution # Note: # dsstd(x, mean = 0, sd = 1, nu = 5, xi = 1.5) # FUNCTION: # Internal Function: refresh.code = function(...) { # Sliders: N = .sliderMenu(no = 1) mean = .sliderMenu(no = 2) sd = .sliderMenu(no = 3) nu = .sliderMenu(no = 4) xi = .sliderMenu(no = 5) invert = .sliderMenu(no = 6) # Compute Data: if (invert == 1) xi = round(1/xi, digits = 4) xmin = round(qsstd(0.01, mean, sd, nu, xi), digits = 2) xmax = round(qsstd(0.99, mean, sd, nu, xi), digits = 2) s = seq(xmin, xmax, length = N) y1 = dsstd(s, mean, sd, nu, xi) y2 = psstd(s, mean, sd, nu, xi) main1 = paste("Skew Student-t Density\n", "mean = ", as.character(mean), " | ", "sd = ", as.character(sd), " | ", "nu = ", as.character(nu), " | ", "xi = ", as.character(xi) ) main2 = paste("Skew Student-t Probability\n", "xmin [0.01] = ", as.character(xmin), " | ", "xmax [0.99] = ", as.character(xmax) ) # Random Numbers: if (type[1] == "rand") { x = rsstd(N, mean, sd, nu, xi) } # Frame: par(mfrow = c(2, 1), cex = 0.7) # Density: if (type[1] == "rand") { hist(x, probability = TRUE, col = "steelblue", border = "white", breaks = "FD", xlim = c(xmin, xmax), ylim = c(0, 1.1*max(y1)), main = main1 ) lines(s, y1, col = "orange") } else { plot(s, y1, type = "l", xlim = c(xmin, xmax), col = "steelblue") abline (h = 0, lty = 3) title(main = main1) grid() } # Probability: plot(s, y2, type = "l", xlim = c(xmin, xmax), ylim = c(0, 1), col = "steelblue" ) abline (h = 0, lty = 3) title(main = main2) grid() # Frame: par(mfrow = c(1, 1), cex = 0.7) } # Open Slider Menu: .sliderMenu(refresh.code, names = c( "N", "mean", "sd", "nu", "xi", "xi.inv"), minima = c( 10, -5.0, 0.1, 2.1, 1.0, 0 ), maxima = c( 500, +5.0, 5.0, 10.0, 10.0, 1 ), resolutions = c( 10, 0.1, 0.1, 0.1, 0.1, 1 ), starts = c( 100, 0.0, 1.0, 5.0, 1.0, 0 ) ) } ################################################################################ fGarch/R/loglik.R0000644000176200001440000001703715104730075013263 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .garchLLH Computes log-likelihood function # .garchOptimizeLLH Opimizes log-likelihood function ################################################################################ .garchLLH <- function(params, trace = TRUE, fGarchEnv = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Compute Log-Likelihood Function # Arguments: # params - a named numeric vector with the model parameters # to be optimized # Value: # Returns the value of the max log-likelihood function. # Note: # The variables '.series' and '.params' must be global available # FUNCTION: # DEBUG: DEBUG = FALSE if (DEBUG) print("Entering Function .garchLLH") # Get Global Variables: .series <- .getfGarchEnv(".series") .params <- .getfGarchEnv(".params") .garchDist <- .getfGarchEnv(".garchDist") .llh <- .getfGarchEnv(".llh") # How to calculate the LLH Function? if (DEBUG) print(.params$control$llh) if(.params$control$llh == "internal") { if (DEBUG) print("internal") return(.aparchLLH.internal(params, trace = trace, fGarchEnv = fGarchEnv)) } else if (.params$control$llh == "filter") { if (DEBUG) print("filter") return(.aparchLLH.filter(params, trace = trace, fGarchEnv = fGarchEnv)) } else if (.params$control$llh == "testing") { if (DEBUG) print("testing") return(.aparchLLH.testing(params, trace = trace, fGarchEnv = fGarchEnv)) } else { stop("LLH is neither internal, testing, nor filter!") } } # ------------------------------------------------------------------------------ ## Called from .garchFit() in ./garch-FitInternal.R -- itself called from garchFit() and .ugarchFit() .garchOptimizeLLH <- function(hessian = hessian, robust.cvar, trace) { # A function implemented by Diethelm Wuertz # Description: # Opimizes the Log-Likelihood Function # Arguments: # hessian - the Hessian matrix # robust.cvar - a logical # trace - a logical # FUNCTION: # DEBUG: DEBUG = FALSE if (DEBUG) print("Entering Function .garchOptimizeLLH") # get global variables .series <- .getfGarchEnv(".series") .params <- .getfGarchEnv(".params") # Initialization: INDEX = .params$index # Algorithm: algorithm = .params$control$algorithm[1] TOL1 = .params$control$tol1 TOL2 = .params$control$tol2 if(trace) { cat("\n\n--- START OF TRACE ---") cat("\nSelected Algorithm:", algorithm, "\n") } # First Method: # Two Step Apparoach > Trust Region + Nelder-Mead Simplex if(algorithm == "nlminb" | algorithm == "nlminb+nm") { fit <- .garchRnlminb(.params, .series, .garchLLH, trace) .params$llh = fit$llh .params$params[INDEX] = fit$par .setfGarchEnv(.params = .params) } if(algorithm == "nlminb+nm") { fit <- .garchRnm(.params, .series, .garchLLH, trace) .params$llh = fit$llh .params$params[INDEX] = fit$par .setfGarchEnv(.params = .params) } # Second Method: # Two Step Approach > BFGS + Nelder-Mead Simplex if(algorithm == "lbfgsb" | algorithm == "lbfgsb+nm") { fit <- .garchRlbfgsb(.params, .series, .garchLLH, trace) .params$llh = fit$llh .params$params[INDEX] = fit$par .setfGarchEnv(.params = .params) } if(algorithm == "lbfgsb+nm") { fit <- .garchRnm(.params, .series, .garchLLH, trace) .params$llh = fit$llh .params$params[INDEX] = fit$par .setfGarchEnv(.params = .params) } # Save parameters: .params$llh = fit$llh .params$params[INDEX] = fit$par .setfGarchEnv(.params = .params) # Compute the Hessian: if (hessian == "ropt") { fit$hessian <- - .garchRoptimhess(par = fit$par, .params = .params, .series = .series) titleHessian = "R-optimhess" } else if (hessian == "rcd") { fit$hessian <- - .garchRCDAHessian(par = fit$par, .params = .params, .series = .series) titleHessian = "Central" } else if (hessian == "rts") { fit$hessian <- - .garchTSHessian(par = fit$par, .params = .params, .series = .series) titleHessian = "Two Sided" } # Rescale Parameters: if (.params$control$xscale) { .series$x <- .series$x * .series$scale if (.params$include["mu"]) fit$coef["mu"] <- fit$par["mu"] <- .params$params["mu"] <- .params$params["mu"]*.series$scale if (.params$include["omega"]) fit$coef["omega"] <- fit$par["omega"] <- .params$params["omega"] <- .params$params["omega"]*.series$scale^(.params$params["delta"]) # save changes .setfGarchEnv(.params = .params) .setfGarchEnv(.series = .series) } # Rescale Hessian Matrix: if (.params$control$xscale) { if (.params$include["mu"]) { fit$hessian[,"mu"] <- fit$hessian[,"mu"] / .series$scale fit$hessian["mu",] <- fit$hessian["mu",] / .series$scale } if (.params$include["omega"]) { fit$hessian[,"omega"] <- fit$hessian[,"omega"] / .series$scale^(.params$params["delta"]) fit$hessian["omega",] <- fit$hessian["omega",] / .series$scale^(.params$params["delta"]) } } # Recalculate llh, h, z with Rescaled Parameters: .llh <- fit$llh <- fit$value <- .garchLLH(fit$par, trace = FALSE, fGarchEnv = TRUE) .series <- .getfGarchEnv(".series") # Compute the Gradient: # YC: needs to be after the calculation of h, z ! if (robust.cvar) fit$gradient <- - .garchRCDAGradient( par = fit$par, .params = .params, .series = .series) # Compute Information Criterion Statistics: N = length(.series$x) NPAR = length(fit$par) fit$ics = c( AIC = c((2*fit$value)/N + 2 * NPAR/N), BIC = (2*fit$value)/N + NPAR * log(N)/N, SIC = (2*fit$value)/N + log((N+2*NPAR)/N), HQIC = (2*fit$value)/N + (2*NPAR*log(log(N)))/N ) names(fit$ics) <- c("AIC", "BIC", "SIC", "HQIC") # Print LLH if we trace: if(trace) { cat("\nFinal Estimate of the Negative LLH:\n") cat(" LLH: ", .llh, " norm LLH: ", .llh/N, "\n") print(fit$par) } # Print Hessian Matrix if we trace: if(trace) { cat("\n", titleHessian, " Difference Approximated Hessian Matrix:\n", sep = "") print(fit$hessian) cat("\n--- END OF TRACE ---\n\n") } # Return Value: if (DEBUG) print("Entering Function .garchOptimizeLLH") fit } ################################################################################ fGarch/R/dist-sged.R0000644000176200001440000001550415104730075013662 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # dsged Density for the skewed GED # psged Probability function for the skewed GED # qsged Quantile function for the skewed GED # rsged Random Number Generator for the skewed GED # FUNCTION: DESCRIPTION: # .dsged Internal, density for the skewed GED # .psged Internal, probability function for the skewed GED # .qsged Internal, quantile function for the skewed GED # .rsged Internal, random Number Generator for the skewed GED ################################################################################ dsged <- function(x, mean = 0, sd = 1, nu = 2, xi = 1.5, log = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Compute the density function of the # skewed generalized error distribution # FUNCTION: # Params: if (length(mean) == 4) { xi = mean[4] nu = mean[3] sd = mean[2] mean = mean[1] } # Shift and Scale: result = .dsged(x = (x-mean)/sd, nu = nu, xi = xi) / sd # Log: if(log) result = log(result) # Return Value: result } # ------------------------------------------------------------------------------ psged <- function(q, mean = 0, sd = 1, nu = 2, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Compute the distribution function of the # skewed generalized error distribution # FUNCTION: # Shift and Scale: result = .psged(q = (q-mean)/sd, nu = nu, xi = xi) # Return Value: result } # ------------------------------------------------------------------------------ qsged <- function(p, mean = 0, sd = 1, nu = 2, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Compute the quantile function of the # skewed generalized error distribution # FUNCTION: # Shift and Scale: result = .qsged(p = p, nu = nu, xi = xi) * sd + mean # Return Value: result } # ------------------------------------------------------------------------------ rsged <- function(n, mean = 0, sd = 1, nu = 2, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Generate random deviates from the # skewed generalized error distribution # FUNCTION: # Shift and Scale: result = .rsged(n = n, nu = nu, xi = xi) * sd + mean # Return Value: result } ################################################################################ .dsged <- function(x, nu, xi) { # A function implemented by Diethelm Wuertz # Description: # Internal Function # FUNCTION: # Standardize: lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) g = nu / ( lambda * (2^(1+1/nu)) * gamma(1/nu) ) m1 = 2^(1/nu) * lambda * gamma(2/nu) / gamma(1/nu) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) z = x*sigma + mu # Compute: Xi = xi^sign(z) g = 2 / (xi + 1/xi) Density = g * dged(x = z/Xi, nu=nu) # Return Value: Density * sigma } # ------------------------------------------------------------------------------ .psged <- function(q, nu, xi) { # A function implemented by Diethelm Wuertz ## ## fixed by GNB, see section 'CHANGES in fGarch VERSION 4021.87, 2022-08-06', subsection ## 'BUG fixes' in NEWS.Rd. # Description: # Internal Function # FUNCTION: # Standardize: lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) g = nu / ( lambda * (2^(1+1/nu)) * gamma(1/nu) ) m1 = 2^(1/nu) * lambda * gamma(2/nu) / gamma(1/nu) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) z = q*sigma + mu # Compute: sig <- ifelse(z >= 0, 1, -1) # note: 1 for z = 0; was sign(z) Xi = xi^sig g = 2 / (xi + 1/xi) ## was Probability = Heaviside(z) - sign(z) * g * Xi * pged(q = -abs(z)/Xi, nu=nu) Probability = ifelse(z >= 0, 1, 0) - sig * g * Xi * pged(q = -abs(z)/Xi, nu=nu) # Return Value: Probability } # ------------------------------------------------------------------------------ .qsged <- function(p, nu, xi) { # A function implemented by Diethelm Wuertz ## ## fixed by GNB, see section 'CHANGES in fGarch VERSION 4021.87, 2022-08-06', subsection ## 'BUG fixes' in NEWS.Rd. # Description: # Internal Function # FUNCTION: # Standardize: lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) g = nu / ( lambda * (2^(1+1/nu)) * gamma(1/nu) ) m1 = 2^(1/nu) * lambda * gamma(2/nu) / gamma(1/nu) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) # Compute: g = 2 / (xi + 1/xi) pxi <- p - (1 / (1 + xi^2)) # not p - 1/2 sig <- sign(pxi) # not p - 1/2 Xi = xi^sig p = (Heaviside(pxi) - sig * p) / (g * Xi) # pxi, not p - 1/2 Quantile = (-sig*qged(p=p, sd=Xi, nu=nu) - mu ) / sigma # Return Value: Quantile } # ------------------------------------------------------------------------------ .rsged <- function(n, nu, xi) { # A function implemented by Diethelm Wuertz # Description: # Internal Function # FUNCTION: # Generate Random Deviates: weight = xi / (xi + 1/xi) z = runif(n, -weight, 1-weight) Xi = xi^sign(z) Random = -abs(rged(n, nu=nu))/Xi * sign(z) # Scale: lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) g = nu / ( lambda * (2^(1+1/nu)) * gamma(1/nu) ) m1 = 2^(1/nu) * lambda * gamma(2/nu) / gamma(1/nu) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) Random = (Random - mu ) / sigma # Return value: Random } ################################################################################ fGarch/R/dist-sgedFit.R0000644000176200001440000001023215104730075014316 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # sgedFit Fit the parameters for a skew GED distribution ################################################################################ .sgedFit <- function(x, mean = 0, sd = 1, nu = 2, xi = 1.5, scale = NA, doplot = TRUE, add = FALSE, span = "auto", trace = TRUE, title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fits parameters of skewed GED using maximum log-likelihood # Example: # set.seed(4711); x = rsged(500); .sgedFit(x)@fit$estimate # FUNCTION: # Settings: dist = dsged model = "SGED Parameter Estimation" scale = "not used" x = x.orig = as.vector(x) # Parameter Estimation: obj = function(x, y = x, trace) { f <- tryCatch(-sum(log(dist(y, x[1], x[2], x[3], x[4]))), error=identity) if (is.na(f) || inherits(f, "error")) return(1e9) # Print Iteration Path: if (trace) { cat("\n Objective Function Value: ", -f) cat("\n Parameter Estimates: ", x, "\n") } f } r = nlminb( start = c(mean = 0, sd = 1, nu = 2, xi = 1.5), objective = obj, lower = c(-Inf, 0, 0, 0), upper = c( Inf, Inf, Inf, Inf), y = x, trace = trace) names(r$par) <- c("mean", "sd", "nu", "xi") # Add Title and Description: if (is.null(title)) title = model if (is.null(description)) description = description() # Result: fit = list(estimate = r$par, minimum = -r$objective, code = r$convergence) # Optional Plot: if (doplot) { x = as.vector(x.orig) if (span == "auto") span = seq(min(x), max(x), length = 501) z = density(x, n = 100, ...) x = z$x[z$y > 0] y = z$y[z$y > 0] y.points = dist(span, r$par[1], r$par[2], r$par[3], r$par[4]) ylim = log(c(min(y.points), max(y.points))) if (add) { lines(x = span, y = log(y.points), col = "steelblue") } else { plot(x, log(y), xlim = c(span[1], span[length(span)]), ylim = ylim, type = "p", xlab = "x", ylab = "log f(x)", ...) title(main = model) lines(x = span, y = log(y.points), col = "steelblue") } } # Return Value: new("fDISTFIT", call = match.call(), model = model, data = as.data.frame(x.orig), fit = fit, title = title, description = description() ) } # ------------------------------------------------------------------------------ sgedFit <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Fit the parameters for a skew Normal distribution # FUNCTION: # Start Value: start = c(mean = mean(x), sd = sqrt(var(x)), nu = 2, xi = 1) # Log-likelihood Function: loglik = function(x, y = x){ f = -sum(log(dsged(y, x[1], x[2], x[3], x[4]))) f } # Minimization: fit = nlminb( start = start, objective = loglik, lower = c(-Inf, 0, 0, 0), upper = c( Inf, Inf, Inf, Inf), y = x, ...) # Add Names to $par names(fit$par) = c("mean", "sd", "nu", "xi") # Return Value: fit } ################################################################################ fGarch/R/garch-Distribution.R0000644000176200001440000001327215104730075015540 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .garchSetCondDist Selects conditional density function # .garchDist Defines conditional density function # .normCondDist Normal Distribution # .QMLECondDist QMLE with Normal Distribution # .snormCondDist Skew Normal Distribution # .stdCondDist Student-t Distribution # .sstdCondDist Skew Student-t Distribution # .gedCondDist Generalized Error Distribution # .sgedCondDist Skew Generalized Error Distribution # .snigCondDist Normal Inverse Gaussian Distribution # .setfGarchEnv Set fGarch environment for conditional distribution ################################################################################ .garchSetCondDist <- function(cond.dist = "norm") { # A function implemented by Diethelm Wuertz # Description: # Select Conditional Density Function # Arguments: # cond.dist - a character string with the name of the # conditional distribution function. Valid strings are: # "norm", "snorm", "std", "sstd", "ged", "sged", "snig". # Value: # Returns the selection conditional distribution function # named uniquely '.garchDist'. # Details: # Implemented Distributions: # norm - Normal Distribution: nothing to estimate # snorm - Skew Normal Distribution: xi may be estimated # std - Student-t Distribution: nu may be estimated # sstd - Skew Student-t Distribution: nu and xi may be estimated # ged - Generalized Error Distribution: nu may be estimated # sged - Skew Generalized Error Distribution: nu and xi may be estimated # FUNCTION: # Compose Function: fun = paste(".", cond.dist, "CondDist", sep = "") .garchDist = match.fun(fun) # Trace the Result: if(FALSE) { cat("\n Distribution: ", cond.dist, "\n .garchDist = ") print(.garchDist) } # Return Value: .garchDist } # ------------------------------------------------------------------------------ .normCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Normal Distribution: # Use base::dnorm dnorm(x = z/hh, mean = 0, sd = 1) / hh } # ------------------------------------------------------------------------------ .QMLECondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Normal Distribution: # Use base::dnorm dnorm(x = z/hh, mean = 0, sd = 1) / hh } # ------------------------------------------------------------------------------ .snormCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Skew Normal Distribution: # Use fGarch::dsnorm dsnorm(x = z/hh, mean = 0, sd = 1, xi = skew) / hh } # ------------------------------------------------------------------------------ .stdCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Standardized Student-t Distribution: # Use fGarch::dstd dstd(x = z/hh, mean = 0, sd = 1, nu = shape) / hh } # ------------------------------------------------------------------------------ .sstdCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Skew Standardized Student-t Distribution: # Use fGarch::dsstd dsstd(x = z/hh, mean = 0, sd = 1, nu = shape, xi = skew) / hh } # ------------------------------------------------------------------------------ .gedCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Generalized Error Distribution: # Use fGarch::dged dged(x = z/hh, mean = 0, sd = 1, nu = shape) / hh } # ------------------------------------------------------------------------------ .sgedCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # Skew Generalized Error Distribution: # Use fGarch::dsged dsged(x = z/hh, mean = 0, sd = 1, nu = shape, xi = skew) / hh } # ------------------------------------------------------------------------------ .snigCondDist <- function(z, hh, skew, shape) { # A function implemented by Diethelm Wuertz # FUNCTION: # (Skew) Normal Inverse Gaussian Distribution: # Use fBasics::dsnig dsnig(x = z/hh, zeta = shape, rho = skew) / hh } # ------------------------------------------------------------------------------ .setfGarchEnv(.garchDist = .garchSetCondDist("norm")) ################################################################################ fGarch/R/dist-snorm.R0000644000176200001440000002136215104730075014075 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # dsnorm Density for the skew normal Distribution # psnorm Probability function for the skew NORM # qsnorm Quantile function for the skew NORM # rsnorm Random Number Generator for the skew NORM # FUNCTION: DESCRIPTION: # .dsnorm Internal, density for the skew normal Distribution # .psnorm Internal, probability function for the skew NORM # .qsnorm Internal, quantile function for the skew NORM # .rsnorm Internal, random Number Generator for the skew NORM ################################################################################ dsnorm <- function(x, mean = 0, sd = 1, xi = 1.5, log = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Compute the density function of the skew normal distribution # Arguments: # x - a numeric vector of quantiles. # mean, sd, xi - location parameter, scale parameter, and # skewness parameter. # FUNCTION: # Params: if (length(mean) == 3) { xi = mean[3] sd = mean[2] mean = mean[1] } # Shift and Scale: result = .dsnorm(x = (x-mean)/sd, xi = xi) / sd # Log: if(log) result = log(result) # Return Value: result } # ------------------------------------------------------------------------------ psnorm <- function(q, mean = 0, sd = 1, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Compute the distribution function of the # skew normal distribution # Arguments: # q - a numeric vector of quantiles. # mean, sd, xi - location parameter, scale parameter, and # skewness parameter. # FUNCTION: # Shift and Scale: result = .psnorm(q = (q-mean)/sd, xi = xi) # Return Value: result } # ------------------------------------------------------------------------------ qsnorm <- function(p, mean = 0, sd = 1, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Compute the quantile function of the # skew normal distribution # Arguments: # p - a numeric vector of probabilities. # mean, sd, xi - location parameter, scale parameter, and # skewness parameter. # FUNCTION: # Shift and Scale: result = .qsnorm(p = p, xi = xi) * sd + mean # Return Value: result } # ------------------------------------------------------------------------------ rsnorm <- function(n, mean = 0, sd = 1, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Generate random deviates from the # skew normal distribution # Arguments: # n - an integer value giving the number of observation. # mean, sd, xi - location parameter, scale parameter, and # skewness parameter. # FUNCTION: # Shift and Scale: result = .rsnorm(n = n, xi = xi) * sd + mean # Return Value: result } ################################################################################ .dsnorm <- function(x, xi) { # A function implemented by Diethelm Wuertz # Description: # Compute the density function of the "normalized" skew # normal distribution # FUNCTION: # Standardize: m1 = 2/sqrt(2*pi) mu = m1 * (xi - 1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) z = x*sigma + mu # Compute: Xi = xi^sign(z) g = 2 / (xi + 1/xi) Density = g * dnorm(x = z/Xi) # Return Value: Density * sigma } # ------------------------------------------------------------------------------ .psnorm <- function(q, xi) { # A function implemented by Diethelm Wuertz ## ## fixed by GNB, see section 'CHANGES in fGarch VERSION 4021.87, 2022-08-06', subsection ## 'BUG fixes' in NEWS.Rd. # Description: # Internal Function # FUNCTION: # Standardize: m1 = 2/sqrt(2*pi) mu = m1 * (xi - 1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) z = q*sigma + mu # Compute: sig <- ifelse(z >= 0, 1, -1) # note: 1 for z = 0; was sign(z) Xi = xi^sig # not sign(z) g = 2 / (xi + 1/xi) ## was: Probability = Heaviside(z) - sig * g * Xi * pnorm(q = -abs(z)/Xi) Probability = ifelse(z >= 0, 1, 0) - sig * g * Xi * pnorm(q = -abs(z)/Xi) # Return Value: Probability } .qsnorm <- function(p, xi) { ## A function implemented by Diethelm Wuertz ## ## Corrected at the centre part by Georgi N. Boshnakov on 2022-07-27 to fix ## bug [#6061], see section 'CHANGES in fGarch VERSION 4021.87, 2022-08-06', ## subsection 'BUG fixes' in NEWS.Rd. ## ## The old version of this and similar functions were temporarilly kept with ## suffix '_orig' but removed after the release of 4022.89, due to lack of ## (reported) problems with the fix. The examples below are kept for reference. ## ## ## Compare ## plot(function(p) .qsnorm(p, xi = 1.5), from = 0, to = 1) ## plot(function(p) .qsnorm_orig(p, xi = 1.5), from = 0, to = 1, ## col = "blue", add = TRUE) ## ## Create a quantile function by numerically inverting psnorm: ## f <- function(x, ...){ sapply(x, function(p) ## gbutils::cdf2quantile(p, cdf = psnorm, ...))} ## It agrees with the fixed qsnorm (the 2nd is right over the first, 3rd is the orig.): ## plot(function(p) .qsnorm(p, xi = 1.5), from = 0.49, to = 0.51) ## plot(f, from = 0.49, to = 0.51, add = TRUE, col = "red") ## plot(function(p) .qsnorm_orig(p, xi = 1.5), from = 0.49, to = 0.51, add = TRUE) ## ## plot(function(p) .qsnorm(p, xi = 1.5), from = 0, to = 1) ## plot(f, from = 0, to = 1, add = TRUE, col = "red") ## plot(function(p) .qsnorm_orig(p, xi = 1.5), from = 0, to = 1, add = TRUE) ## Description: ## Internal Function ## FUNCTION: ## Standardize: m1 = 2/sqrt(2*pi) mu = m1 * (xi - 1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) ## Compute: g = 2 / (xi + 1/xi) pxi <- p - (1 / (1 + xi^2)) # not p - 1/2 sig <- sign(pxi) # not p - 1/2 Xi = xi^sig p = (Heaviside(pxi) - sig * p) / (g * Xi) # pxi, not p - 1/2 ## GNB: ## Fixed: BUG [#6061] fGarch::qsnorm() incorrect around p=0.5 ## ## This has, in general, discontinuity for p = 1/2, since then sig = 0. ## Note that the original p = 1/2 is transformed above to 1/(2*g*Xi), ## so qnorm() doesn't necessarilly give 1/2 when p = 1/2. ## ## Note also that p can be a vector. ## ## Further note: the issue at p = 0.5 is a separate problem. Zooming in ## shows that the quantile is not continuous at p = 0.5 and to the right of ## 0.5 the values are smaller than just to the left of 0.5 up to around 0.51. ## ## SOLUTION(?): The error seems to be that sign() and Heaviside should compare to ## 1/(1+1/xi^2), not 0.5 which is correct only for xi = 1. ## Quantile = (-sig * qnorm(p = p, sd = Xi) - mu ) / sigma ## Return Value: Quantile } # ------------------------------------------------------------------------------ .rsnorm <- function(n, xi) { # A function implemented by Diethelm Wuertz # Description: # Internal Function # FUNCTION: # Generate Random Deviates: weight = xi / (xi + 1/xi) z = runif(n, -weight, 1-weight) Xi = xi^sign(z) Random = -abs(rnorm(n))/Xi * sign(z) # Scale: m1 = 2/sqrt(2*pi) mu = m1 * (xi - 1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) Random = (Random - mu ) / sigma # Return value: Random } ################################################################################ fGarch/R/dist-sstdFit.R0000644000176200001440000001043615104730075014357 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # sstdFit Fit the parameters for a skew Sudent-t distribution ################################################################################ .sstdFit <- function(x, mean = 0, sd = 1, xi = 1.5, scale = NA, doplot = TRUE, add = FALSE, span = "auto", trace = TRUE, title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fits parameters of a Skew Student-t using maximum log-likelihood # Example: # set.seed(4711); x = rsnorm(500); .snormFit(x)@fit$estimate # FUNCTION: # Settings: dist = dsstd model = "SSTD Parameter Estimation" scale = "not used" x = x.orig = as.vector(x) # Parameter Estimation: obj = function(x, y = x, trace) { f <- tryCatch(-sum(log(dist(y, x[1], x[2], x[3], x[4]))), error=identity) if (is.na(f) || inherits(f, "error")) return(1e9) # Print Iteration Path: if (trace) { cat("\n Objective Function Value: ", -f) cat("\n Parameter Estimates: ", x, "\n") } f } r = nlminb( start = c(mean = 0, sd = 1, nu = 5, xi = 1.5), objective = obj, lower = c(-Inf, 0, 2, 0), upper = c( Inf, Inf, Inf, Inf), y = x, trace = trace) names(r$par) <- c("mean", "sd", "nu", "xi") # Add Title and Description: if (is.null(title)) title = model if (is.null(description)) description = description() # Result: fit = list(estimate = r$par, minimum = -r$objective, code = r$convergence) # Optional Plot: if (doplot) { x = as.vector(x.orig) if (span == "auto") span = seq(min(x), max(x), length = 501) z = density(x, n = 100, ...) x = z$x[z$y > 0] y = z$y[z$y > 0] y.points = dist(span, r$par[1], r$par[2], r$par[3], r$par[4]) ylim = log(c(min(y.points), max(y.points))) if (add) { lines(x = span, y = log(y.points), col = "steelblue") } else { plot(x, log(y), xlim = c(span[1], span[length(span)]), ylim = ylim, type = "p", xlab = "x", ylab = "log f(x)", ...) title(main = model) lines(x = span, y = log(y.points), col = "steelblue") } } # Return Value: new("fDISTFIT", call = match.call(), model = model, data = as.data.frame(x.orig), fit = fit, title = title, description = description() ) } # ------------------------------------------------------------------------------ sstdFit <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Fit the parameters for a skew Sudent-t distribution # with unit variance # FUNCTION: # For S-Plus compatibility: if (!exists("nlm")) nlm = function (f, p, ...) nlminb(start = p, objective = f, ...) # Start Value: p = c(mean = mean(x), sd = sqrt(var(x)), nu = 4, xi = 1) # Log-likelihood Function: loglik = function(x, y = x){ f = -sum(log(dsstd(y, x[1], x[2], x[3], x[4]))) f } # Minimization: fit = nlm( f = loglik, p = p, y = x, ...) Names = c("mean", "sd", "nu", "xi") names(fit$estimate) = Names names(fit$gradient) = Names # Return Value: fit } ################################################################################# ------------------------------------------------------------------------------ fGarch/R/garch-Sim.R0000644000176200001440000001142015104730075013602 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: SIMULATION: # garchSim Simulates a GARCH/APARCH process ################################################################################ garchSim <- function(spec = garchSpec(), n = 100, n.start = 100, extended = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Simulates a time series process from the GARCH family # Arguments: # model - a specification object of class 'fGARCHSPEC' as # returned by the function \code{garchSpec}: # ar - a vector of autoregressive coefficients of # length m for the ARMA specification, # ma - a vector of moving average coefficients of # length n for the ARMA specification, # omega - the variance value for GARCH/APARCH # specification, # alpha - a vector of autoregressive coefficients # of length p for the GARCH/APARCH specification, # gamma - a vector of leverage coefficients of # length p for the APARCH specification, # beta - a vector of moving average coefficients of # length q for the GARCH/APARCH specification, # mu - the intercept for ARMA specification (mean=mu/(1-sum(ar))), # delta - the exponent value used in the variance # equation. # skew - a numeric value for the skew parameter. # shape - a numeric value for the shape parameter. # n - an integer, the length of the series # n.start - the length of the warm-up sequence to reduce the # effect of initial conditions. # FUNCTION: # Specification: stopifnot(inherits(spec, "fGARCHSPEC")) model = spec@model # Random Seed: if (spec@rseed != 0) set.seed(spec@rseed) # Enlarge Series: n = n + n.start # Create Innovations: if (spec@distribution == "norm") z = rnorm(n) if (spec@distribution == "ged") z = rged(n, nu = model$shape) if (spec@distribution == "std") z = rstd(n, nu = model$shape) if (spec@distribution == "snorm") z = rsnorm(n, xi = model$skew) if (spec@distribution == "sged") z = rsged(n, nu = model$shape, xi = model$skew) if (spec@distribution == "sstd") z = rsstd(n, nu = model$shape, xi = model$skew) # Expand to whole Sample: delta = model$delta z = c(rev(spec@presample[, 1]), z) h = c(rev(spec@presample[, 2]), rep(NA, times = n)) y = c(rev(spec@presample[, 3]), rep(NA, times = n)) m = length(spec@presample[, 1]) names(z) = names(h) = names(y) = NULL # Determine Coefficients: mu = model$mu ar = model$ar ma = model$ma omega = model$omega alpha = model$alpha gamma = model$gamma beta = model$beta deltainv = 1/delta # Determine Orders: order.ar = length(ar) order.ma = length(ma) order.alpha = length(alpha) order.beta = length(beta) # Iterate GARCH / APARCH Model: eps = h^deltainv*z for (i in (m+1):(n+m)) { h[i] = omega + sum(alpha*(abs(eps[i-(1:order.alpha)]) - gamma*(eps[i-(1:order.alpha)]))^delta) + sum(beta*h[i-(1:order.beta)]) eps[i] = h[i]^deltainv * z[i] y[i] = mu + sum(ar*y[i-(1:order.ar)]) + sum(ma*eps[i-(1:order.ma)]) + eps[i] } # Sample: data = cbind( z = z[(m+1):(n+m)], sigma = h[(m+1):(n+m)]^deltainv, y = y[(m+1):(n+m)]) rownames(data) = as.character(1:n) data = data[-(1:n.start),] # Return Values: from <- timeDate(format(Sys.time(), format = "%Y-%m-%d")) - NROW(data)*24*3600 charvec <- timeSequence(from = from, length.out = NROW(data)) ans <- timeSeries(data = data[, c(3,2,1)], charvec = charvec) colnames(ans) <- c("garch", "sigma", "eps") ans <- if (extended) ans else ans[,"garch"] attr(ans, "control") <- list(garchSpec = spec) # Return Value: ans } ################################################################################ fGarch/R/cvar-VaR.R0000644000176200001440000000253115104730075013414 0ustar liggesusers## GNB TODO: this is to get thing going qfun_fGarch <- function(dist, parameters){ skew <- parameters["skew"] shape <- parameters["shape"] switch(dist, norm = qnorm, snorm = function(p, ...) qsnorm(p, xi = skew, ...), # TODO: do we need '...'? ged = function(p, ...) qged(p, nu = shape, ...), sged = function(p, ...) qsged(p, nu = shape, xi = skew, ...), std = function(p, ...) qstd(p, nu = shape, ...), sstd = function(p, ...) qsstd(p, nu = shape, xi = skew, ...), snig = function(p, ...) qsnig(p, zeta = shape, rho = skew, ...), ## default stop("distribution 'dist' not implemented here") ) } VaR.fGARCH <- function(dist, p_loss = 0.05, ..., tol = .Machine$double.eps^0.5) { stopifnot(inherits(dist, "fGARCH")) mu_t <- dist@fitted sigma_t <- dist@sigma.t cond_dist <- dist@fit$params$cond.dist qf <- qfun_fGarch(cond_dist, coef(dist)) cvar::VaR_qf(qf, p_loss, intercept = mu_t, slope = sigma_t, tol = tol) } ES.fGARCH <- function (dist, p_loss = 0.05, ...) { stopifnot(inherits(dist, "fGARCH")) mu_t <- dist@fitted sigma_t <- dist@sigma.t cond_dist <- dist@fit$params$cond.dist qf <- qfun_fGarch(cond_dist, coef(dist)) cvar::ES(qf, p_loss, intercept = mu_t, slope = sigma_t) } fGarch/R/garch-Hessian.R0000644000176200001440000001334715116747657014477 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # .garchRoptimhess Uses R internal optimhess function # .garchRCDAHessian Computes R coded CDA Hessian matrix # .garchRTSHessian Computes R coded Two Sided Hessian matrix # .hessian2sided Function called from .garchRTSHessian # REQUIRED: # Matrix ################################################################################ ## These are called from .garchOptimizeLLH() -->> ./loglik.R .garchRoptimhess <- function(par, .params, .series, eps = 1.0e-4) { # A function implemeted by Diethelm Wuertz # Description: # Compute Hessian via R's function optimHess() # Arguments: # par - # .params - # .series - # eps - # FUNCTION: # Take Time: .StartHessian <- Sys.time() # Compute Hessian: H <- optimHess(par, .garchLLH) H <- 0.5 * (H + t(H)) nm <- names(par) dimnames(H) <- list(nm, nm) # Elapsed Time: time = Sys.time() - .StartHessian attr(H, "time") = time # Return Value: H } # ------------------------------------------------------------------------------ .garchRCDAHessian <- function(par, .params, .series, eps = 1.0e-4) { # A function implemented by Diethelm Wuertz # Description: # Compute CDA (central difference approximated) Hessian # Arguments: # par - # .params - # .series - # eps - # Reference: # http://status.sph.umich.edu/computing/manuals/sas8/stat/chap46/sect26.htm # FUNCTION: # Take start time .StartHessian <- Sys.time() # Algorithm: algorithm = .params$control$algorithm[1] .trace = FALSE # Compute Hessian: eps = eps * par n = length(par) H = matrix(0, ncol = n, nrow = n) for (i in 1:n) { for (j in 1:n) { x1 = x2 = x3 = x4 = par x1[i] = x1[i] + eps[i] x1[j] = x1[j] + eps[j] x2[i] = x2[i] + eps[i] x2[j] = x2[j] - eps[j] x3[i] = x3[i] - eps[i] x3[j] = x3[j] + eps[j] x4[i] = x4[i] - eps[i] x4[j] = x4[j] - eps[j] H[i, j] = ( .garchLLH(x1, .trace) - .garchLLH(x2, .trace) - .garchLLH(x3, .trace) + .garchLLH(x4, .trace) ) / (4*eps[i]*eps[j]) } } colnames(H) = rownames(H) = names(par) # Attribute execution time: time = Sys.time() - .StartHessian attr(H, "time") = time # Return Value: H } # ------------------------------------------------------------------------------ .garchTSHessian <- function(par, .params, .series, eps = NA) { # A function implemented by Diethelm Wuertz # Description: # Compute two sided (TS) approximated Hessian # Arguments: # par - # .params - # .series - # eps - not used # FUNCTION: # Take start time .StartHessian <- Sys.time() # Algorithm: algorithm = .params$control$algorithm[1] # Compute Hessian: H <- .hessian2sided(f = .garchLLH, x = par, trace = FALSE, fGarchEnv = FALSE) colnames(H) = rownames(H) = names(par) # Attribute execution time: time = Sys.time() - .StartHessian attr(H, "time") = time # Return Value: H } # ------------------------------------------------------------------------------ .hessian2sided <- function(f, x, ...) { # A function adapted from Kevin Sheppard's Matlab garch toolbox # ... implemented by Alexios Ghalanos in his rgarch package # ... R port for Rmetrics' fGarch by Diethelm Wuertz # Description: # Computes two sided (TS) approximated Hessian # Arguments: # f - # x - # Notes: # requires package Matrix (added as suggestion) # FUNCTION: # Settings: n <- length(x) fx <- f(x, ...) eps <- .Machine$double.eps # Compute the stepsize (h) h = eps^(1/3) * apply( as.data.frame(x), 1, FUN = function(z) max(abs(z), 1.0e-2)) xh = x + h h = xh - x ee <- Matrix::Matrix(diag(h), sparse = TRUE) # Compute forward and backward steps: gm <- gp <- numeric(n) for(i in 1:n) { e.i <- ee[,i] gp[i] <- f(x + e.i, ...) gm[i] <- f(x - e.i, ...) } H = h %*% t(h) Hm = H Hp = H # Compute "double" forward and backward steps: for(i in 1:n){ ## FIXME (speedup!) -- vectorize or even work with FULL n x n matrices H, Hp, Hm e.i <- ee[,i] for(j in i:n){ e.j <- ee[,j] Hp[j, i] <- Hp[i, j] <- f(x + e.i + e.j, ...) Hm[j, i] <- Hm[i, j] <- f(x - e.i - e.j, ...) } } # Compute the hessian: for(i in 1:n) { ## FIXME (speedup!) -- vectorize or even work with FULL n x n matrices H, Hp, Hm for(j in i:n) { ## 1 <= i <= j <= n H[j, i] = H[i, j] = .5* ((Hp[i, j] - gp[i] - gp[j] + fx + fx - gm[i] - gm[j] + Hm[i, j]) / H[i, j]) } } # Return the Hessian matrix: H } fGarch/R/garch-GlobalVars.R0000644000176200001440000000274115104730075015114 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .setfGarchEnv Set Global Vars # .garchArgsParser Parses formula and data for garchFit # .garchOptimizerControl Sets default values for Garch Optimizer # .garchFit ... old Version, still in use by garchFit() # .garchNames Slot names, @fit slot, parameters and controls ################################################################################ .setfGarchEnv(.llh = 1e99) .setfGarchEnv(.garchDist = NA) .setfGarchEnv(.params = NA) .setfGarchEnv(.series = NA) .setfGarchEnv(.trace = NA) ################################################################################ fGarch/R/stats-tsdiag.R0000644000176200001440000002214615104730075014406 0ustar liggesusers## Author: Georgi Boshnakov ## based on tsdiag.Sarima from package 'sarima' .tsdiag_choices <- c( ## ## "classic (std. residuals, acf, portmanteau p-values)", ## "residuals", ## "acf of residuals", ## "p values for Ljung-Box statistic", ## "p values for Li-McLeod statistic", ## "p values for Box-Pierce statistic", ## "pacf of residuals" ## use 7-13; for consistency with the plot method we would like to keep the same numbers ## but this seems not possible with menu(). ## ## .plot.garch.1 Plot Time Series ## .plot.garch.2 Plot Conditional SD ## .plot.garch.3 Plot Series with 2 Conditional SD Superimposed ## .plot.garch.4 Plot ACF of Observations ## .plot.garch.5 Plot ACF of Squared Observations ## .plot.garch.6 Plot Cross Correlation "Residuals", # .plot.garch.7 "Conditional SDs", # .plot.garch.8 "Standardized Residuals", # .plot.garch.9 "ACF of Standardized Residuals", # .plot.garch.10 "ACF of Squared Standardized Residuals", # .plot.garch.11 "Cross Correlation between r^2 and r", # .plot.garch.12 "QQ-Plot of Standardized Residuals" # .plot.garch.13 ## TODO: pacf of r and r^2 ) ## tsdiag.Sarima: ## ## { # 1: "residuals", ## plot(stdres, type = "h", main = "Standardized Residuals", ylab = "") ## abline(h = 0) ## #acf(err, main = "ACF of residuals from model", lag.max = lag.max) ## #pacf(err, main = "PACF of residuals from model", lag.max = lag.max) ## }, ## { # 2: "ACF of residuals" ## ## acf ## acf(err, plot = TRUE, main = "ACF of Residuals", lag.max = lag.max, na.action = na.pass) ## # acf(cdf, main = "", lag.max = lag.max) ## # title("ACF of" ~U[t]) ## # pacf(cdf, main = "", lag.max = lag.max) ## # title("PACF of" ~U[t]) ## }, ## { # 3: "Ljung-Box p-values" ## acftest <- acfIidTest(sacf, npar = fitdf, nlags = 1:nlag, method = "LjungBox", ## interval = NULL) ## res[["LjungBox"]] <- acftest ## }, ## { # 4: "Li-McLeod p-values" ## acftest <- acfIidTest(sacf, npar = fitdf, nlags = 1:nlag, method = "LiMcLeod", ## interval = NULL) ## res[["LiMcLeod"]] <- acftest ## }, ## { # 5: "Box-Pierce p-values" ## acftest <- acfIidTest(sacf, npar = fitdf, nlags = 1:nlag, method = "BoxPierce", ## interval = NULL) ## res[["BoxPierce"]] <- acftest ## }, ## { # 6: "PACF of residuals" ## ## acf ## pacf(err, plot = TRUE, main = "PACF of Residuals", lag.max = lag.max, na.action = na.pass) ## }, ## # { # 4: "ACF/Histogram of tau_residuals" ## # acf(err2, main = "ACF of tau_residuals", lag.max = lag.max) ## # hist(err2, freq = FALSE, main = "Histogram of tau_residuals", xlab = "", ## # ylim = c(0, 0.5)) ## # lines(seq(-5, 5, .01), dnorm(seq(-5, 5, .01)), col = "red") ## # } tsdiag.fGARCH <- function(object, gof.lag = NULL, ask = FALSE, ..., plot = c(4L, 5L, 7L), layout = NULL) { ## Georgi Boshnakov n_per_page <- if(is.null(layout)) 3 else ## length(layout[[1]]) do.call("layout", layout) if(is.null(gof.lag)) gof.lag <- 20 # :TODO: NOTE: arbitrary value else if(!is.numeric(gof.lag)) stop("'gof.lag' must be numeric and contain positive integers") lag.max <- max(gof.lag) sres <- residuals(object, standardize = TRUE) sres2 <- sres^2 choices <- .tsdiag_choices chnum <- 1:length(choices) if(!isTRUE(plot)){ # plot is typically numeric index here; choices <- choices[plot] # FALSE or NULL give zero length result, so no plots chnum <- chnum[plot] if(anyNA(choices)){ warning("'plot' should be TRUE/FALSE or vector of positive integers <= ", length(.tsdiag_choices), ",\n", "ignoring non-existent values") chnum <- chnum[!is.na(choices)] choices <- choices[!is.na(choices)] } } if(length(choices) > 0){ old.par <- par(no.readonly = TRUE) on.exit(par(old.par)) # restore graphics parameters before exiting. ask_user <- interactive() && (ask || length(choices) > n_per_page) ## adjust n_per_page if 'layout' is missing if(is.null(layout)) { n_per_page <- if(ask_user) ## was: layout(matrix(1:3, ncol = 1)) layout(matrix(1:min(3, length(choices)), ncol = 1)) else layout(matrix(1:min(3, length(choices)), ncol = 1)) } choice_title <- "Select a plot number or 0 to exit" ch_index <- if(length(choices) == 1) 1 else if(ask) menu(choices, title = choice_title) else if(!identical(plot, FALSE)) 1 else integer(0) choice <- chnum[ch_index] ## ## precompute common stuff for portmanteau tests ## nlag <- gof.lag ## pval <- numeric(nlag) ## fitdf <- if(inherits(object, "Sarima")) ## length(object$internal$nonfixed) ## else if(inherits(object, "Arima")) ## sum(object$arma[1:4]) # object$arma is: p, q, p_s. q_s, s, d, d_s ## else ## 0 ## # for(i in 1L:nlag) ## # pval[i] <- Box.test(err, i, type="Ljung-Box", ## # fitdf = ifelse(i > fitdf, fitdf, i - 1))$p.value ## sacf <- autocorrelations(err, maxlag = nlag) # deal with NA's? res <- list(residuals = sres) while(length(choice) != 0){ switch(choice, .plot.garch.7 (object), # "Residuals", .plot.garch.8 (object), # "Conditional SDs", .plot.garch.9 (object), # "Standardized Residuals", .plot.garch.10(object), # "ACF of Standardized Residuals", .plot.garch.11(object), # "ACF of Squared Standardized Residuals", .plot.garch.12(object), # "Cross Correlation between r^2 and r", .plot.garch.13(object) # "QQ-Plot of Standardized Residuals" ) if(length(chnum) == 1) # length(choices) == 1 break if(ask_user) { # was: interactive() && (ask || length(choices) > n_per_page) ch_index <- menu(choices, title = choice_title) choice <- chnum[ch_index] } else{ ## just plot the next one ## Note: this doesn't update ch_index chnum <- chnum[-1] choice <- chnum[1] } } } .f <- function(x) c(statistic = as.vector(x$statistic), p.value = x$p.value) if(requireNamespace("goftest", quietly = TRUE)) { gofargs <- .resid_with_dist(object) res$gof <- rbind( "Anderson-Darling" = .f(do.call(goftest::ad.test, gofargs)), "Cramer-vonMises" = .f(do.call(goftest::cvm.test, gofargs)) ) gofargs$estimated <- FALSE res$gof_composite <- rbind( "Anderson-Darling" = .f(do.call(goftest::ad.test, gofargs)), "Cramer-vonMises" = .f(do.call(goftest::cvm.test, gofargs)) ) } else{ message("Please install package 'goftest' for additional tests") } class(res) <- "tsdiag_fGARCH" invisible(res) } print.tsdiag_fGARCH <- function(x, ...){ ## for now just drop the values of the residuals x <- x[names(x) != "residuals"] for(s in names(x)) { cat(paste0( "\n", s, ":", "\n")) print(x[[s]]) } } ## GNB, based on .plot.garch.13 ## for tests in 'goftest' .resid_with_dist <- function(x) { sres <- residuals(x, standardize = TRUE) cond_dist <- x@fit$params$cond.dist cond_cdf <- paste("p", cond_dist, sep = "") parNames <- names(x@fit$par) skew <- if ("skew" %in% parNames) x@fit$par["skew"] else x@fit$params$skew shape <- if ("shape" %in% parNames) x@fit$par["shape"] else x@fit$params$shape res <- list(x = sres) res$null <- if (cond_dist == "QMLE") "pnorm" else cond_cdf if (cond_dist == "std" || cond_dist == "ged") res$nu <- shape else if (cond_dist == "snorm") res$xi <- skew else if (cond_dist == "sstd" || cond_dist == "sged") { res$xi <- skew res$nu <- shape } else if (cond_dist == "snig") { res$rho <- skew res$zeta <- shape } res$estimated <- TRUE res$nullname <- cond_dist res } fGarch/R/loglik-aparch.R0000644000176200001440000004107115104730075014512 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .aparchLLH.internal Internal ARMA-APARCH recursion done by Fortran Code # .aparchLLH.filter Fast approach using the filter function in R # .aparchLLH.testing Simple double loops over time and order in R ################################################################################ .aparchLLH.internal <- function(params, trace = TRUE, fGarchEnv = TRUE) { # A function implemented by Diethelm Wuertz # Description: # Internal ARMA-APARCH recursion done by Fortran Code # Arguments: # params - a named numeric vector with the model parameters # to be optimized # trace - # fGarchEnv - # Value: # Returns the value of the max log-likelihood function. # Note: # The variables '.series' and '.params' must be global available # FUNCTION: # DEBUG: DEBUG = FALSE if (DEBUG) print("Entering Function .garchLLH.internal") # Get Global Variables: .series <- .getfGarchEnv(".series") .params <- .getfGarchEnv(".params") .garchDist <- .getfGarchEnv(".garchDist") .llh <- .getfGarchEnv(".llh") # How to calculate the LLH Function? if (DEBUG) print(.params$control$llh) if(.params$control$llh == "internal") { INDEX <- .params$index MDIST <- c(norm = 10, QMLE = 10, snorm = 11, std = 20, sstd = 21, ged = 30, sged = 31)[.params$cond.dist] if(.params$control$fscale) NORM <- length(.series$x) else NORM = 1 REC <- 1 if(.series$init.rec == "uev") REC <- 2 MYPAR <- c( REC = REC, # How to initialize LEV = as.integer(.params$leverage), # Include Leverage 0|1 MEAN = as.integer(.params$includes["mu"]), # Include Mean 0|1 DELTA = as.integer(.params$includes["delta"]),# Include Delta 0|1 SKEW = as.integer(.params$includes["skew"]), # Include Skew 0|1 SHAPE = as.integer(.params$includes["shape"]),# Include Shape 0|1 ORDER = .series$order, # Order of ARMA-GARCH NORM = as.integer(NORM)) # Now Estimate Parameters: MAX <- max(.series$order) NF <- length(INDEX) N <- length(.series$x) DPARM <- c(.params$delta, .params$skew, .params$shape) fit <- .Fortran( "garchllh", N = as.integer(N), Y = as.double(.series$x), # Z = as.double(rep(2, times = N)), # H = as.double(rep(0, times = N)), Z = as.double(.series$z), H = as.double(.series$h), NF = as.integer(NF), X = as.double(params), DPARM = as.double(DPARM), MDIST = as.integer(MDIST), MYPAR = as.integer(MYPAR), F = as.double(0), PACKAGE = "fGarch") llh <- fit[[10]] if(is.na(llh)) llh = .llh + 0.1*(abs(.llh)) if(!is.finite(llh)) llh = .llh + 0.1*(abs(.llh)) .setfGarchEnv(.llh = llh) if (fGarchEnv) { # Save h and z: .series$h <- fit[[4]] .series$z <- fit[[3]] .setfGarchEnv(.series = .series) } } else { stop("LLH is not internal!") } # Return Value: c(LogLikelihood = llh) } # ------------------------------------------------------------------------------ .aparchLLH.filter <- function(params, trace = TRUE, fGarchEnv = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Fast approach using the filter function in R for ARMA-APARCH models # Arguments: # params - a named numeric vector with the model parameters # to be optimized # trace - a logical, should the frunction output be traced ? # fGarchEnv - # Value: # Returns the value of the max log-likelihood function. # Note: # The variables '.series' and '.params' must be global available # FUNCTION: # DEBUG: DEBUG = FALSE if (DEBUG) print("Entering Function .garchLLH.filter") # Get Global Variables: .series <- .getfGarchEnv(".series") .params <- .getfGarchEnv(".params") .garchDist <- .getfGarchEnv(".garchDist") .llh <- .getfGarchEnv(".llh") # Which conditional distribution function should be used ? if(DEBUG) print(.garchDist) # How to calculate the LLH Function? if (DEBUG) print(c("testing ?", .params$control$llh)) if(.params$control$llh == "filter") { # Retrieve From Initialized Series: x = .series$x # Get Order: u = .series$order[1] v = .series$order[2] p = .series$order[3] q = .series$order[4] max.order = max(u, v, p, q) # Get Start Conditions: h.start = .series$h.start llh.start = .series$llh.start # Get the Index Values and Add Names - Just to be Sure: index = .params$index names(params) = names(.params$params[index]) Names = names(params) # Retrieve From Initialized Parameters: cond.dist = .params$cond.dist # Extracting the parameters by name ... alpha <- beta <- NULL mu = c(mu = .params$mu) delta = c(delta = .params$delta) skew = c(skew = .params$skew) shape = c(shape = .params$shape) leverage = c(leverage = .params$leverage) if(.params$includes["mu"]) mu = params["mu"] if(u > 0) ar = params[substr(Names, 1, 2) == "ar"] if(v > 0) ma = params[substr(Names, 1, 2) == "ma"] omega = params[substr(Names, 1, 5) == "omega"] if(p > 0) alpha = params[substr(Names, 1, 5) == "alpha"] if(p > 0 & leverage) gamma = params[substr(Names, 1, 5) == "gamma"] if(p > 0 & !leverage) gamma = rep(0, times = p) if(q > 0) beta = params[substr(Names, 1, 4) == "beta"] if(.params$includes["delta"]) delta = params["delta"] if(.params$includes["skew"]) skew = params["skew"] if(.params$includes["shape"]) shape = params["shape"] if(DEBUG) print(params) # Iterate z: N = length(x) z = rep(0, N) if(u > 0 & v > 0) for (i in (h.start):N) z[i] = x[i] - mu - sum(ar*x[i-(1:u)]) - sum(ma*z[i-(1:v)]) if(u > 0 & v == 0) for (i in (h.start):N) z[i] = x[i] - mu - sum(ar*x[i-(1:u)]) if(u == 0 & v > 0) for (i in (h.start):N) z[i] = x[i] - mu - sum(ma*z[i-(1:v)]) if(u == 0 & v == 0) z = x - mu # Initialize Variance Equation: deltainv = 1/delta if(.series$model[2] == "garch") { persistence = sum(alpha) + sum(beta) } else if(.series$model[2] == "aparch") { persistence = sum(beta) for (i in 1:p) persistence = persistence + alpha[i]*garchKappa(cond.dist, gamma[i], delta, skew, shape) } names(persistence) = "persistence" attr(persistence, "control") = NULL attr(persistence, "cond.dist") = NULL .params$persistence <- persistence .setfGarchEnv(.params = .params) mvar = mean(z^2) h = rep(omega + persistence*mvar, N) # Iterate Conditional Variances h: if(p == 0) { alpha = 0 p = 1 } if(q == 0) { beta = 0 q = 1 } # R Filter Representation: # Entirely written in S, and very effective ... # own filter method because as.ts and tsp time consuming... # Note, sometimes one of the beta's can become undefined # during optimization. if(!.params$leverage) gamma = rep(0, p) pq = max(p, q) edeltat = 0 for (j in 1:p) { Filter = rep(0, length = p+1) Filter[j+1] = alpha[j] edelta = (abs(z) - gamma[j]*z)^delta edelta = as.vector(filter(edelta, filter = Filter, sides = 1)) edeltat = edeltat + edelta } c.init = omega/(1-sum(beta)) h <- c(h[1:pq], c.init + as.vector(filter(edeltat[-(1:pq)], filter = beta, method = "recursive", init = h[q:1]-c.init))) ### ? remove ? ### DW: May be not . if( sum(is.na(h)) > 0 ) { # We use the testing Version ... warning("Problems in Filter Representation") if(!.params$leverage) { for (i in (h.start):N) { h[i] = omega + sum(alpha * ( abs(z[i-(1:p)])) ^ delta ) + sum(beta*h[i-(1:q)]) } } else { for (i in (h.start):N) { h[i] = omega + sum(alpha * ( abs(z[i-(1:p)]) - gamma * z[i-(1:p)])^delta ) + sum(beta*h[i-(1:q)]) } } } # Calculate Log Likelihood: hh = (abs(h[(llh.start):N]))^deltainv zz = z[(llh.start):N] llh = -sum(log(.garchDist(z = zz, hh = hh, skew = skew, shape = shape))) if(DEBUG) cat("DEBUG - LLH: ", llh, "\n") names(params) = names(.params$params[.params$index]) if(is.na(llh)) llh = .llh + 0.1*(abs(.llh)) if(!is.finite(llh)) llh = .llh + 0.1*(abs(.llh)) # Print if LLH has Improved: if(llh < .llh) { diff = (.llh - llh)/llh if(trace & diff > 1e-2) { # cat(" LLH: ", llh, " norm LLH: ", llh/N, "\n") # print(params) if(persistence > 1) cat("Warning - Persistence:", persistence, "\n") } .setfGarchEnv(.llh = llh) } if (fGarchEnv) { # Save h and z: .series$h <- h .series$z <- z .setfGarchEnv(.series = .series) } } else { stop("LLH is not filter!") } # Return Value: if (DEBUG) print("Entering Function .garchLLH.filter") c(LogLikelihood = llh) } # ------------------------------------------------------------------------------ .aparchLLH.testing <- function(params, trace = TRUE, fGarchEnv = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Compute Log-Likelihood Function for ARMA-APARCH models # Arguments: # params - a named numeric vector with the model parameters # to be optimized # trace - # fGarchEnv - # Value: # Returns the value of the max log-likelihood function. # Note: # The variables '.series' and '.params' must be global available # FUNCTION: # DEBUG: DEBUG = FALSE if (DEBUG) print("Entering Function .garchLLH.testing") # Get Global Variables: .series <- .getfGarchEnv(".series") .params <- .getfGarchEnv(".params") .garchDist <- .getfGarchEnv(".garchDist") .llh <- .getfGarchEnv(".llh") if(DEBUG) print(.garchDist) # How to calculate the LLH Function? if (DEBUG) print(.params$control$llh) if(.params$control$llh == "testing") { # Retrieve From Initialized Series: x = .series$x # Get Order: u = .series$order[1] v = .series$order[2] p = .series$order[3] q = .series$order[4] max.order = max(u, v, p, q) # Get Start Conditions: h.start = .series$h.start llh.start = .series$llh.start # Get the Index Values and Add Names - Just to be Sure: index = .params$index names(params) = names(.params$params[index]) Names = names(params) # Retrieve From Initialized Parameters: cond.dist = .params$cond.dist if(DEBUG) print(paste("Conditional Distribution:", cond.dist)) # Extracting the parameters by name ... alpha <- beta <- NULL mu = c(mu = .params$mu) delta = c(delta = .params$delta) skew = c(skew = .params$skew) shape = c(shape = .params$shape) leverage = c(leverage = .params$leverage) if(.params$includes["mu"]) mu = params["mu"] if(u > 0) ar = params[substr(Names, 1, 2) == "ar"] if(v > 0) ma = params[substr(Names, 1, 2) == "ma"] omega = params[substr(Names, 1, 5) == "omega"] if(p > 0) alpha = params[substr(Names, 1, 5) == "alpha"] if(p > 0 & leverage) gamma = params[substr(Names, 1, 5) == "gamma"] if(p > 0 & !leverage) gamma = rep(0, times = p) if(q > 0) beta = params[substr(Names, 1, 4) == "beta"] if(.params$includes["delta"]) delta = params["delta"] if(.params$includes["skew"]) skew = params["skew"] if(.params$includes["shape"]) shape = params["shape"] if(DEBUG) print(params) # Iterate z: N = length(x) z = rep(0, N) if(u > 0 & v > 0) for (i in (h.start):N) z[i] = x[i] - mu - sum(ar*x[i-(1:u)]) - sum(ma*z[i-(1:v)]) if(u > 0 & v == 0) for (i in (h.start):N) z[i] = x[i] - mu - sum(ar*x[i-(1:u)]) if(u == 0 & v > 0) for (i in (h.start):N) z[i] = x[i] - mu - sum(ma*z[i-(1:v)]) if(u == 0 & v == 0) z = x - mu # Initialize Variance Equation: deltainv = 1/delta if(.series$model[2] == "garch") { persistence = sum(alpha) + sum(beta) } else if(.series$model[2] == "aparch") { persistence = sum(beta) for (i in 1:p) persistence = persistence + alpha[i]*garchKappa(cond.dist, gamma[i], delta, skew, shape) } names(persistence) = "persistence" attr(persistence, "control") = NULL attr(persistence, "cond.dist") = NULL .params$persistence <- persistence .setfGarchEnv(.params = .params) mvar = mean(z^2) h = rep(omega + persistence*mvar, N) # Initial Values to Iterate Conditional Variances h: if(p == 0) { alpha = 0 p = 1 } if(q == 0) { beta = 0 q = 1 } # Test Version Just a Simple Double 'for' Loop: # As You Can Imagine, Slow Version But Very Useful for Testing: if(!.params$leverage) { for (i in (h.start):N) { h[i] = omega + sum(alpha * ( abs(z[i-(1:p)])) ^ delta ) + sum(beta*h[i-(1:q)]) } } else { for (i in (h.start):N) { h[i] = omega + sum(alpha * ( abs(z[i-(1:p)]) - gamma * z[i-(1:p)])^delta ) + sum(beta*h[i-(1:q)]) } } # Calculate Log Likelihood: hh = (abs(h[(llh.start):N]))^deltainv zz = z[(llh.start):N] llh = -sum(log(.garchDist(z = zz, hh = hh, skew = skew, shape = shape))) if(DEBUG) cat("DEBUG - LLH: ", llh, "\n") names(params) = names(.params$params[.params$index]) if(is.na(llh)) llh = .llh + 0.1*(abs(.llh)) if(!is.finite(llh)) llh = .llh + 0.1*(abs(.llh)) # Print if LLH has Improved: if(llh < .llh) { diff = (.llh - llh)/llh if(trace & diff > 1e-2) { # cat(" LLH: ", llh, " norm LLH: ", llh/N, "\n") # print(params) if(persistence > 1) cat("Warning - Persistence:", persistence, "\n") } .setfGarchEnv(.llh = llh) } if (fGarchEnv) { # Save h and z: .series$h <- h .series$z <- z .setfGarchEnv(.series = .series) } } else { stop("LLH is not testing!") } # Return Value: if (DEBUG) print("Leaving Function .garchLLH.testing") c(LogLikelihood = llh) } ################################################################################ fGarch/R/zzz.R0000644000176200001440000000175415104730075012636 0ustar liggesusers## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . .onAttach <- function(libname, pkgname) { packageStartupMessage( "NOTE: Packages 'fBasics', 'timeDate', and 'timeSeries' are no longer\n", "attached to the search() path when 'fGarch' is attached.\n\n", "If needed attach them yourself in your R script by e.g.,\n", " require(\"timeSeries\")") } fGarch/R/dist-stdFit.R0000644000176200001440000001003115104730075014163 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # stdFit Fit the parameters for a Sudent-t distribution ################################################################################ .stdFit <- function(x, mean = 0, sd = 1, xi = 1.5, scale = NA, doplot = TRUE, add = FALSE, span = "auto", trace = TRUE, title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fits parameters of a Student-t using maximum log-likelihood # Example: # set.seed(4711); x = rstd(500); .stdFit(x)@fit$estimate # FUNCTION: # Settings: dist = dstd model = "STD Parameter Estimation" scale = "not used" x = x.orig = as.vector(x) # Parameter Estimation: obj = function(x, y = x, trace) { f <- tryCatch(-sum(log(dist(y, x[1], x[2], x[3]))), error=identity) if (is.na(f) || inherits(f, "error")) return(1e9) # Print Iteration Path: if (trace) { cat("\n Objective Function Value: ", -f) cat("\n Parameter Estimates: ", x, "\n") } f } r = nlminb( start = c(mean = 0, sd = 1, nu = 5), objective = obj, lower = c(-Inf, 0, 2), upper = c( Inf, Inf, Inf), y = x, trace = trace) names(r$par) <- c("mean", "sd", "nu") # Add Title and Description: if (is.null(title)) title = model if (is.null(description)) description = description() # Result: fit = list(estimate = r$par, minimum = -r$objective, code = r$convergence) # Optional Plot: if (doplot) { x = as.vector(x.orig) if (span == "auto") span = seq(min(x), max(x), length = 501) z = density(x, n = 100, ...) x = z$x[z$y > 0] y = z$y[z$y > 0] y.points = dstd(span, r$par[1], r$par[2], r$par[3]) ylim = log(c(min(y.points), max(y.points))) if (add) { lines(x = span, y = log(y.points), col = "steelblue") } else { plot(x, log(y), xlim = c(span[1], span[length(span)]), ylim = ylim, type = "p", xlab = "x", ylab = "log f(x)", ...) title(main = model) lines(x = span, y = log(y.points), col = "steelblue") } } # Return Value: new("fDISTFIT", call = match.call(), model = model, data = as.data.frame(x.orig), fit = fit, title = title, description = description() ) } # ------------------------------------------------------------------------------ stdFit <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Fit the parameters for a skew Normal distribution # FUNCTION: # Start Value: start = c(mean = mean(x), sd = sqrt(var(x)), nu = 4) # Log-likelihood Function: loglik = function(x, y = x){ f = -sum(log(dstd(y, x[1], x[2], x[3]))) f } # Minimization: fit = nlminb( start = start, objective = loglik, lower = c(-Inf, 0, 2), upper = c(Inf, Inf, Inf), y = x, ...) # Add Names to $par names(fit$par) = c("mean", "sd", "nu") # Return Value: fit } ################################################################################ fGarch/R/methods-show.R0000644000176200001440000001577615104730075014433 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # show.fGARCH S4 Show method for an object of class 'fGARCH' # show.fGARCHSPEC S4 Show method for an object of class 'fGARCHSPEC' ################################################################################ .prepare_GARCH_show <- function(object) { ## based on the original body of the show method common <- list( title = object@title, call = object@call, formula = object@formula, description = object@description ) wrk <- if(as.character(object@call[1]) == ".gogarchFit") { ## multivariate list( type = "multivariate", cond_dist = object@fit[[1]]@fit$params$cond.dist, number_of_margins = length(object@fit) ) } else { ## univariate list( type = "univariate", cond_dist = object@fit$params$cond.dist, par = object@fit$par, se_method = if (object@fit$params$cond.dist == "QMLE") "robust" else "based on Hessian", matcoef = object@fit$matcoef, loglik = -object@fit$value, normalized_loglik = -object@fit$value / NROW(object@data) ) } c(common, wrk) } .print_title <- function(x) { cat("\nTitle:\n ") cat(x, "\n") invisible(NULL) } .print_call <- function(x) { cat("\nCall:\n ") cat(paste(deparse(x), sep = "\n", collapse = "\n"), "\n") } .print_cond_dist <- function(x) { cat("\nConditional Distribution:\n ") cat(x, "\n") } .print_coef <- function(x) { cat("\nCoefficient(s):\n") digits = max(5, getOption("digits") - 4) print.default(format(x, digits = digits), print.gap = 2, quote = FALSE) } .print_se_method <- function(x) { cat("\nStd. Errors:\n ") if (x == "QMLE") cat("robust", "\n") else cat("based on Hessian", "\n") } .print_error_analysis <- function(x) { digits = max(4, getOption("digits") - 5) signif.stars = getOption("show.signif.stars") cat("\nError Analysis:\n") printCoefmat(x, digits = digits, signif.stars = signif.stars) } .print_loglik <- function(x, nllh) { cat("\nLog Likelihood:\n ") cat(x, " normalized: ", nllh, "\n") } .print_description <- function(x) { cat("\nDescription:\n ") cat(x, "\n") cat("\n") } .print_mean_var_eq <- function(formula) { cat("\nMean and Variance Equation:\n ") Name <- unclass(attr(formula, "data")) Formula <- formula attr(Formula, "data") <- NULL print(Formula) # GNB: TODO: use arg. showEnv? cat(" [", Name, "]\n", sep = "") invisible(NULL) } .show_orig_body <- function(object, prepare = TRUE) { ## A function implemented by Diethelm Wuertz ## refactored and modified by GNB # Description: # Print method for an object of class "fGARCH" # Arguments: # object - an object of class 'fGARCH' # FUNCTION: res <- if(prepare) .prepare_GARCH_show(object) else object .print_title(res$title) .print_call(res$call) .print_mean_var_eq(res$formula) # Univariate or Multivariate Modeling ? if(res$type == "univariate") { # univariate Garch Models .print_cond_dist(res$cond_dist) .print_coef(res$par) .print_se_method(res$se_method) .print_error_analysis(res$matcoef) .print_loglik(res$loglik, res$normalized_loglik) } else { # For multivariate Garch Models ... # extract information from first fitted instrument. object@fit[[1]]@fit$params$cond.dist # Conditional Distribution: cat("\nConditional Distribution:\n ") cat(object@fit[[1]]@fit$params$cond.dist, "\n") # Number of Margins: cat("\nNumber of Margins:\n ") cat(length(object@fit), "\n") } .print_description(res$description) invisible(res) } setMethod("show", "fGARCH", function(object) .show_orig_body(object) ) # ------------------------------------------------------------------------------ setMethod(f = "show", signature(object = "fGARCHSPEC"), definition = function(object) { # A function implemented by Diethelm Wuertz # Description: # S4 Print Method for objects of class 'fGARCHSPEC' # Arguments: # object - Object of class 'fGARCHSPEC' # FUNCTION: # Formula: x = object cat("\nFormula: \n ") cat(as.character(x@formula)) # Model: cat("\nModel:") if (sum(abs(x@model$ar)) != 0) cat("\n ar: ", x@model$ar) if (sum(abs(x@model$ma)) != 0) cat("\n ma: ", x@model$ma) if (x@model$mu != 0) cat("\n mu: ", x@model$mu) if (x@model$omega != 0) cat("\n omega:", x@model$omega) if (sum(abs(x@model$alpha)) != 0) cat("\n alpha:", x@model$alpha) if (sum(abs(x@model$gamma)) != 0) cat("\n gamma:", x@model$gamma) if (sum(abs(x@model$beta)) != 0) cat("\n beta: ", x@model$beta) if (x@model$delta != 2) cat("\n delta:", x@model$delta) # Distribution: cat("\nDistribution: \n ") cat(x@distribution) if (x@distribution != "norm") { if (x@distribution == "snorm") { cat("\nDistributional Parameters: \n") cat(" xi =", x@model$skew) } if (x@distribution == "ged" | x@distribution == "std") { cat("\nDistributional Parameter: \n") cat(" nu =", x@model$shape) } if (x@distribution == "sged" | x@distribution == "sstd") { cat("\nDistributional Parameters: \n") cat(" nu =", x@model$shape, " xi =", x@model$skew) } } # Seed: if (x@rseed != 0) { cat("\nRandom Seed: \n ") cat(x@rseed) } # Presample: cat("\nPresample: \n") n = -(length(x@presample[, 1])-1) time = n:0 print(data.frame(cbind(time, x@presample))) # Return Value: invisible() }) ################################################################################ fGarch/R/dist-gedFit.R0000644000176200001440000001011615104730075014134 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # .gedFit New: Fit the parameters for a GED distribution # gedFit Fit the parameters for a GED distribution ################################################################################ .gedFit <- function(x, mean = 0, sd = 1, nu = 2, scale = NA, doplot = TRUE, add = FALSE, span = "auto", trace = TRUE, title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fits parameters of a NIG using maximum log-likelihood # Example: # set.seed(4711); x = rged(500); .gedFit(x)@fit$estimate # FUNCTION: # Settings: dist = dged model = "GED Parameter Estimation" scale = "not used" x = x.orig = as.vector(x) # Parameter Estimation: obj = function(x, y = x, trace) { f <- tryCatch(-sum(log(dist(y, x[1], x[2], x[3]))), error=identity) if (is.na(f) || inherits(f, "error")) return(1e9) # Print Iteration Path: if (trace) { cat("\n Objective Function Value: ", -f) cat("\n Parameter Estimates: ", x, "\n") } f } r = nlminb( start = c(mean = 0, sd = 1, nu = 2), objective = obj, lower = c(-Inf, 0, 0), upper = c( Inf, Inf, Inf), y = x, trace = trace) names(r$par) <- c("mean", "sd", "nu") # Add Title and Description: if (is.null(title)) title = model if (is.null(description)) description = description() # Result: fit = list(estimate = r$par, minimum = -r$objective, code = r$convergence) # Optional Plot: if (doplot) { x = as.vector(x.orig) if (span == "auto") span = seq(min(x), max(x), length = 501) z = density(x, n = 100, ...) x = z$x[z$y > 0] y = z$y[z$y > 0] y.points = dist(span, r$par[1], r$par[2], r$par[3]) ylim = log(c(min(y.points), max(y.points))) if (add) { lines(x = span, y = log(y.points), col = "steelblue") } else { plot(x, log(y), xlim = c(span[1], span[length(span)]), ylim = ylim, type = "p", xlab = "x", ylab = "log f(x)", ...) title(main = model) lines(x = span, y = log(y.points), col = "steelblue") } } # Return Value: new("fDISTFIT", call = match.call(), model = model, data = as.data.frame(x.orig), fit = fit, title = title, description = description() ) } # ------------------------------------------------------------------------------ gedFit <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Fit the parameters for a generalized error distribution # FUNCTION: # Start Value: start = c(mean = mean(x), sd = sqrt(var(x)), nu = 2) # Log-likelihood Function: loglik = function(x, y = x){ f = -sum(log(dged(y, x[1], x[2], x[3]))) f } # Minimization: fit = nlminb( start = start, objective = loglik, lower = c(-Inf, 0, 0), upper = c( Inf, Inf, Inf), y = x, ...) # Add Names to $par names(fit$par) = c("mean", "sd", "nu") # Return Value: fit } ################################################################################ fGarch/R/dist-gedSlider.R0000644000176200001440000000661515104730075014645 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # gedSlider Displays Generalized Error Distribution and RVS ################################################################################ gedSlider <- function(type = c("dist", "rand")) { # A function implemented by Diethelm Wuertz # Description: # Displays interactively skew GED distribution # Note: # dged(x, mean = 0, sd = 1, nu = 5) # FUNCTION: # Internal Function: refresh.code = function(...) { # Sliders: N = .sliderMenu(no = 1) mean = .sliderMenu(no = 2) sd = .sliderMenu(no = 3) nu = .sliderMenu(no = 4) # Compute Data: xmin = round(qged(0.01, mean, sd, nu), digits = 2) xmax = round(qged(0.99, mean, sd, nu), digits = 2) s = seq(xmin, xmax, length = N) y1 = dged(s, mean, sd, nu) y2 = pged(s, mean, sd, nu) main1 = paste("GED Density\n", "mean = ", as.character(mean), " | ", "sd = ", as.character(sd), " | ", "nu = ", as.character(nu) ) main2 = paste("GED Probability\n", "xmin [0.01] = ", as.character(xmin), " | ", "xmax [0.99] = ", as.character(xmax) ) # Random Numbers: if (type[1] == "rand") { x = rged(N, mean, sd, nu) } # Frame: par(mfrow = c(2, 1), cex = 0.7) # Density: if (type[1] == "rand") { hist(x, probability = TRUE, col = "steelblue", border = "white", breaks = "FD", xlim = c(xmin, xmax), ylim = c(0, 1.1*max(y1)), main = main1 ) lines(s, y1, col = "orange") } else { plot(s, y1, type = "l", xlim = c(xmin, xmax), col = "steelblue") abline (h = 0, lty = 3) title(main = main1) grid() } # Probability: plot(s, y2, type = "l", xlim = c(xmin, xmax), ylim = c(0, 1), col = "steelblue" ) abline (h = 0, lty = 3) title(main = main2) grid() # Frame: par(mfrow = c(1, 1), cex = 0.7) } # Open Slider Menu: .sliderMenu(refresh.code, names = c( "N", "mean", "sd", "nu"), minima = c( 10, -5.0, 0.1, 2.1), maxima = c( 1000, +5.0, 5.0, 10.0), resolutions = c( 10, 0.1, 0.1, 0.1), starts = c( 100, 0.0, 1.0, 5.0) ) } ################################################################################ fGarch/R/garch-FitFromSpec.R0000644000176200001440000002011715104730075015236 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # fUGARCHSPEC Fits the parameters of GARCH process # .ugarchSpec Specifies a univariate GARCH model # .ugarchFit Fits a univariate GARCH model ################################################################################ ## MM: FIXME .ugarchFit() & .ugarchSpec() are entirely ## ===== *un*documented and *un*tested .setfGarchEnv(.llh = 1e99) .setfGarchEnv(.garchDist = NA) .setfGarchEnv(.params = NA) .setfGarchEnv(.series = NA) .setfGarchEnv(.trace = NA) # ------------------------------------------------------------------------------ setClass("fUGARCHSPEC", representation( model = "list", distribution = "list", optimization = "list", documentation = "list") ) # ------------------------------------------------------------------------------ .ugarchSpec <- function( model = list( formula = ~ garch(1,1), mean = 0, include.mean = TRUE, delta = 2, include.delta = NULL, leverage = NULL, recursion = c("internal", "filter", "testing")[1], init.rec = c("mci", "uev")[1]), distribution = list( cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "snig", "QMLE")[1], skew = 1, include.skew = NULL, shape = 4, include.shape = NULL), optimization = list( algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm")[1], hessian = c("ropt", "rcd", "rts")[1], trace = TRUE, control = list(), status = NA), documentation = list( call = match.call(), title = NULL, description = NULL ) ) { # Description: # Specifies a garch model to be fitted # Example: # .garchSpec()) # FUNCTION: # Model Slot: Model = list( formula = ~ garch(1,1), mean = 0, include.mean = TRUE, delta = 2, include.delta = NULL, leverage = NULL, recursion = c("internal", "filter", "testing")[1], init.rec = c("mci", "uev")[1]) Model[(Names <- names(model))] <- model # Distribution Slot: Distribution = list( cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "snig", "QMLE")[1], skew = 1, include.skew = NULL, shape = 4, include.shape = NULL) Distribution[(Names <- names(distribution))] <- distribution # Optimization Slot: Optimization = list( algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm")[1], hessian = c("ropt", "rcd", "rst")[1], trace = TRUE, control = list(), status = NA) Optimization[(Names <- names(optimization))] <- optimization # Documentation Slot: Documentation = list( call = match.call(), title = NULL, description = NULL ) Documentation[(Names <- names(documentation))] <- documentation # Return Value: new("fUGARCHSPEC", model = Model, distribution = Distribution, optimization = Optimization, documentation = Documentation) } # ------------------------------------------------------------------------------ .ugarchFit <- function(data, spec = .ugarchSpec()) { # Description: # Fit parameters to a ARMA-GARCH model by GARCH Specification # Arguments: # data - time series or vector of data # spec - garch specification object # Example: # .ugarchFit(dem2gbp[, 1]) # FUNCTION: DEBUG = FALSE # Set Call: CALL <- spec@documentation$call <- match.call() # Parse Data: Name = capture.output(substitute(data)) if(is.character(data)) { eval(parse(text = paste("data(", data, ")"))) data = eval(parse(text = data)) } data <- as.data.frame(data) # Column Names: if (isUnivariate(data)) { colnames(data) <- "data" } else { # Check unique column Names: uniqueNames = unique(sort(colnames(data))) if (is.null(colnames(data))) { stop("Column names of data are missing.") } if (length(colnames(data)) != length(uniqueNames)) { stop("Column names of data are not unique.") } } # Handle if we have no left-hand-side for the formula ... formula <- spec@model$formula # Note in this case the length of the formula is 2 (else 3): if (length(formula) == 3 && isUnivariate(data) ) formula[2] <- NULL if (length(formula) == 2) { if (isUnivariate(data)) { # Missing lhs -- we substitute the data file name as lhs ... formula = as.formula(paste("data", paste(formula, collapse = " "))) } else { stop("Multivariate data inputs require lhs for the formula.") } } # Robust Formula ? robust.cvar <- (spec@distribution$cond.dist == "QMLE") # Parse Arguments: args = .garchArgsParser(formula = formula, data = data, trace = FALSE) # DEBUG - Print Arguments: if(DEBUG) print(list( formula.mean = args$formula.mean, formula.var = args$formula.var, series = args$series, init.rec = spec@model$init.rec, delta = spec@model$delta, skew = spec@distribution$skew, shape = spec@distribution$shape, cond.dist = spec@distribution$cond.dist, include.mean = spec@model$include.mean, include.delta = spec@model$include.delta, include.skew = spec@distribution$include.skew, include.shape = spec@distribution$include.shape, leverage = spec@model$leverage, trace = spec@optimization$trace, ## recursion = spec@model$recursion, algorithm = spec@optimization$algorithm, hessian = spec@optimization$hessian, robust.cvar = robust.cvar, control = spec@optimization$control, title = spec@documentation$title, description = spec@documentation$description)) # Fit: ans = .garchFit( formula.mean = args$formula.mean, formula.var = args$formula.var, series = args$series, init.rec = spec@model$init.rec, delta = spec@model$delta, skew = spec@distribution$skew, shape = spec@distribution$shape, cond.dist = spec@distribution$cond.dist, include.mean = spec@model$include.mean, include.delta = spec@model$include.delta, include.skew = spec@distribution$include.skew, include.shape = spec@distribution$include.shape, leverage = spec@model$leverage, trace = spec@optimization$trace, ## recursion = spec@model$recursion, algorithm = spec@optimization$algorithm, hessian = spec@optimization$hessian, robust.cvar = robust.cvar, control = spec@optimization$control, title = spec@documentation$title, description = spec@documentation$description) ans@call = CALL attr(formula, "data") <- paste("data = ", Name, sep = "") ans@formula = formula # Return Value: ans } ################################################################################ fGarch/R/methods-update.R0000644000176200001440000000431615104730075014721 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # METHOD: EXTRACTORS: # update,fGARCHSPEC Update Methods # update,fGARCH Update Methods ################################################################################ setMethod("update", "fGARCHSPEC", function(object, ... ) { # A function implemented by Yohan Chalabi # Description: # # Example: # # # FUNCTION: call <- object@call extras <- match.call(expand.dots = FALSE)$... if (length(extras)) { existing <- !is.na(match(names(extras), names(call))) for (a in names(extras)[existing]) call[[a]] <- extras[[a]] if (any(!existing)) { call <- c(as.list(call), extras[!existing]) call <- as.call(call) } } eval(call, parent.frame()) }) # ----------------------------------------------------------------------------- setMethod("update", "fGARCH", function(object, ... ) { # A function implemented by Yohan Chalabi # Description: # # Example: # # # FUNCTION: call <- object@call extras <- match.call(expand.dots = FALSE)$... if (length(extras)) { existing <- !is.na(match(names(extras), names(call))) for (a in names(extras)[existing]) call[[a]] <- extras[[a]] if (any(!existing)) { call <- c(as.list(call), extras[!existing]) call <- as.call(call) } } eval(call, parent.frame()) }) fGarch/R/dist-sgedSlider.R0000644000176200001440000000727415104730075015032 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # sgedSlider Displays Generalized Error Distribution and RVS ################################################################################ sgedSlider <- function(type = c("dist", "rand")) { # A function implemented by Diethelm Wuertz # Description: # Displays interactively skew GED distribution # Note: # dsged(x, mean = 0, sd = 1, nu = 5, xi = 1.5) # FUNCTION: # Internal Function: refresh.code = function(...) { # Sliders: N = .sliderMenu(no = 1) mean = .sliderMenu(no = 2) sd = .sliderMenu(no = 3) nu = .sliderMenu(no = 4) xi = .sliderMenu(no = 5) invert = .sliderMenu(no = 6) # Compute Data: if (invert == 1) xi = round(1/xi, digits = 4) xmin = round(qsged(0.01, mean, sd, nu, xi), digits = 2) xmax = round(qsged(0.99, mean, sd, nu, xi), digits = 2) s = seq(xmin, xmax, length = N) y1 = dsged(s, mean, sd, nu, xi) y2 = psged(s, mean, sd, nu, xi) main1 = paste("Skew GED Density\n", "mean = ", as.character(mean), " | ", "sd = ", as.character(sd), " | ", "nu = ", as.character(nu), " | ", "xi = ", as.character(xi) ) main2 = paste("Skew GED Probability\n", "xmin [0.01] = ", as.character(xmin), " | ", "xmax [0.99] = ", as.character(xmax) ) # Random Numbers: if (type[1] == "rand") { x = rsged(N, mean, sd, nu, xi) } # Frame: par(mfrow = c(2, 1), cex = 0.7) # Density: if (type[1] == "rand") { hist(x, probability = TRUE, col = "steelblue", border = "white", breaks = "FD", xlim = c(xmin, xmax), ylim = c(0, 1.1*max(y1)), main = main1 ) lines(s, y1, col = "orange") } else { plot(s, y1, type = "l", xlim = c(xmin, xmax), col = "steelblue") abline (h = 0, lty = 3) title(main = main1) grid() } # Probability: plot(s, y2, type = "l", xlim = c(xmin, xmax), ylim = c(0, 1), col = "steelblue" ) abline (h = 0, lty = 3) title(main = main2) grid() # Frame: par(mfrow = c(1, 1), cex = 0.7) } # Open Slider Menu: .sliderMenu(refresh.code, names = c( "N", "mean", "sd", "nu", "xi", "xi.inv"), minima = c( 10, -5.0, 0.1, 2.1, 1.0, 0 ), maxima = c( 1000, +5.0, 5.0, 10.0, 10.0, 1 ), resolutions = c( 10, 0.1, 0.1, 0.1, 0.1, 1 ), starts = c( 100, 0.0, 1.0, 5.0, 1.0, 0 ) ) } ################################################################################ fGarch/R/dist-snormFit.R0000644000176200001440000001023115104730075014531 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .snormFit Fit the parameters for a skew Normal distribution # snormFit Fit the parameters for a skew Normal distribution ################################################################################ .snormFit <- function(x, mean = 0, sd = 1, xi = 1.5, scale = NA, doplot = TRUE, add = FALSE, span = "auto", trace = TRUE, title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fits parameters of a NIG using maximum log-likelihood # Example: # set.seed(4711); x = rsnorm(500); .snormFit(x)@fit$estimate # FUNCTION: # Settings: dist = dsnorm model = "SNORM Parameter Estimation" scale = "not used" x = x.orig = as.vector(x) # Parameter Estimation: obj = function(x, y = x, trace) { f <- tryCatch(-sum(log(dist(y, x[1], x[2], x[3]))), error=identity) if (is.na(f) || inherits(f, "error")) return(1e9) # Print Iteration Path: if (trace) { cat("\n Objective Function Value: ", -f) cat("\n Parameter Estimates: ", x, "\n") } f } r = nlminb( start = c(mean = 0, sd = 1, xi = 1.5), objective = obj, lower = c(-Inf, 0, 0), upper = c( Inf, Inf, Inf), y = x, trace = trace) names(r$par) <- c("mean", "sd", "xi") # Add Title and Description: if (is.null(title)) title = model if (is.null(description)) description = description() # Result: fit = list(estimate = r$par, minimum = -r$objective, code = r$convergence) # Optional Plot: if (doplot) { x = as.vector(x.orig) if (span == "auto") span = seq(min(x), max(x), length = 501) z = density(x, n = 100, ...) x = z$x[z$y > 0] y = z$y[z$y > 0] y.points = dist(span, r$par[1], r$par[2], r$par[3]) ylim = log(c(min(y.points), max(y.points))) if (add) { lines(x = span, y = log(y.points), col = "steelblue") } else { plot(x, log(y), xlim = c(span[1], span[length(span)]), ylim = ylim, type = "p", xlab = "x", ylab = "log f(x)", ...) title(main = model) lines(x = span, y = log(y.points), col = "steelblue") } } # Return Value: new("fDISTFIT", call = match.call(), model = model, data = as.data.frame(x.orig), fit = fit, title = title, description = description() ) } # ------------------------------------------------------------------------------ snormFit <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Fit the parameters for a skew Normal distribution # FUNCTION: # Start Value: start = c(mean = mean(x), sd = sqrt(var(x)), xi = 1) # Log-likelihood Function: loglik = function(x, y = x){ f = -sum(log(dsnorm(y, x[1], x[2], x[3]))) f } # Minimization: fit = nlminb( start = start, objective = loglik, lower = c(-Inf, 0, 0), upper = c( Inf, Inf, Inf), y = x, ...) # Add Names to $par names(fit$par) = c("mean", "sd", "xi") # Return Value: fit } ################################################################################ fGarch/R/class-fGARCH.R0000644000176200001440000000263615104730075014076 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # 'fGARCH' fGARCH Class representation ################################################################################ # Class Representation: setClass("fGARCH", representation( call = "call", formula = "formula", method = "character", data = "numeric", fit = "list", residuals = "numeric", fitted = "numeric", h.t = "numeric", sigma.t = "numeric", title = "character", description = "character") ) ################################################################################ fGarch/R/methods-plot.R0000644000176200001440000004124615104730075014420 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # plot Plot method for an object of class 'fGARCH' # .interactiveGarchPlot Plot interactively # .multGarchPlot Arrange multivariate Plots # .plot.garch.1 Plot Time Series # .plot.garch.2 Plot Conditional SD # .plot.garch.3 Plot Series with 2 Conditional SD Superimposed # .plot.garch.4 Plot ACF of Observations # .plot.garch.5 Plot ACF of Squared Observations # .plot.garch.6 Plot Cross Correlation # .plot.garch.7 Plot Residuals # .plot.garch.8 Plot Conditional SDs # .plot.garch.9 Plot Standardized Residuals # .plot.garch.10 Plot ACF of Standardized Residuals # .plot.garch.11 Plot ACF of Squared Standardized Residuals # .plot.garch.12 Plot Cross Correlation between r^2 and r # .plot.garch.13 Plot QQ-Plot of Standardized Residuals" # .qqDist Quantile-Quantile Points # .qqLine Quantile-Quantile Line ################################################################################ setMethod(f = "plot", signature(x = "fGARCH", y = "missing"), definition = function(x, which = "ask", ...) { # A function implemented by Diethelm Wuertz # Description: # Plot method for an object of class 'fGARCH' # Note: # This method can also be used for plotting graphs fitted by # the function 'garch' from the contributed R package 'tseries'. # FUNCTION: if (as.character(x@call[1]) == ".gogarchFit") { # Plot multivariate GO-Garch model: print("GO-Garch Plot Not Yet Implemented") } else { ## Plot univariate Models: choices <- c( "Time Series", "Conditional SD", "Series with 2 Conditional SD Superimposed", "ACF of Observations", "ACF of Squared Observations", "Cross Correlation", "Residuals", "Conditional SDs", "Standardized Residuals", "ACF of Standardized Residuals", "ACF of Squared Standardized Residuals", "Cross Correlation between r^2 and r", "QQ-Plot of Standardized Residuals", ## added by GNB "Series with -VaR Superimposed", "Series with -ES Superimposed", "Series with -VaR & -ES Superimposed" ) .interactiveGarchPlot( x, choices = choices, plotFUN = paste(".plot.garch", 1:length(choices), sep = "."), which = which, ...) } # Return Value: invisible(x) }) # ------------------------------------------------------------------------------ .interactiveGarchPlot <- function(x, choices, plotFUN, which, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # Arguments: # x - an object to be plotted # choices - the character string for the choice menu # plotFUN - the names of the plot functions # which - plot selection, which graph should be # displayed. If a character string named "ask" the # user is interactively asked which to plot, if # a logical vector of length N, those plots which # are set "TRUE" are displayed, if a character string # named "all" all plots are displayed. # FUNCTION: # Some checks: if (length(choices) != length(plotFUN)) stop("Arguments choices and plotFUN must be of same length.") if (length(which) > length(choices)) stop("Arguments which has incorrect length.") if (length(which) > length(plotFUN)) stop("Arguments which has incorrect length.") # Plot: if (is.numeric(which)) { Which = rep(FALSE, times = length(choices)) Which[which] = TRUE } if (which[1] == "all") { Which = rep(TRUE, times = length(choices)) } if (which[1] == "ask") { .multGarchPlot(x, choices, plotFUN, ...) } else { for ( i in 1:length(choices) ) { FUN = match.fun(plotFUN[i]) if (Which[i]) FUN(x) } } # Return Value: invisible(x) } # ------------------------------------------------------------------------------ .multGarchPlot <- function (x, choices, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function pick = 1 while (pick > 0) { pick = menu ( ### choices = paste("plot:", choices), choices = paste(" ", choices), title = "\nMake a plot selection (or 0 to exit):") # up to 19 plot functions ... switch (pick, .plot.garch.1(x), .plot.garch.2(x), .plot.garch.3(x), .plot.garch.4(x), .plot.garch.5(x), .plot.garch.6(x), .plot.garch.7(x), .plot.garch.8(x), .plot.garch.9(x), .plot.garch.10(x), .plot.garch.11(x), .plot.garch.12(x), .plot.garch.13(x)) } } # ------------------------------------------------------------------------------ .plot.garch.1 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 1. Time Series: xseries = x@data plot(xseries, type = "l", col = "steelblue", ylab = "x", main = "Time Series") abline(h = 0, col = "grey", lty = 3) grid() } # ------------------------------------------------------------------------------ .plot.garch.2 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 2. Conditional SD: xcsd = volatility(x, "sigma") plot(xcsd, type = "l", col = "steelblue", ylab = "x", main = "Conditional SD") abline(h = 0, col = "grey", lty = 3) grid() } # ------------------------------------------------------------------------------ .plot.garch.3 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 3. Series with 2 Conditional SD Superimposed: xseries = x@data xcsd = volatility(x, "sigma") ci = 2 plot(xseries, type = "l", col = "steelblue", ylab = "x", main = "Series with 2 Conditional SD Superimposed") lines(mean(xseries) + ci * xcsd, col = "grey") # or simply xseries ? lines(mean(xseries) - ci * xcsd, col = "grey") abline(h = 0, col = "grey", lty = 3) grid() } # ------------------------------------------------------------------------------ .plot.garch.4 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 4. ACF of the Observations: xseries = as.vector(x@data) n = length(xseries) lag.max = as.integer(10*log10(n)) acf(xseries, lag.max = lag.max, xlab = "Lags", col = "steelblue", main = "ACF of Observations", plot = TRUE) } # ------------------------------------------------------------------------------ .plot.garch.5 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 5. ACF of the Squared Observations: xseries = as.vector(x@data) xseries2 = xseries^2 n = length(xseries) lag.max = as.integer(10*log10(n)) acf(xseries2, lag.max = lag.max, xlab = "Lags", col = "steelblue", main = "ACF of Squared Observations", plot = TRUE) } # ------------------------------------------------------------------------------ .plot.garch.6 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 6. Cross Correlation between x^2 and x: xseries = as.vector(x@data) xseries2 = xseries^2 n = length(xseries) lag.max = as.integer(10*log10(n)) ccf(xseries2, xseries, lag.max = lag.max, xlab = "Lags", main = "Cross Correlation", plot = TRUE, col = "steelblue") } # ------------------------------------------------------------------------------ .plot.garch.7 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 7. Residuals: res = residuals(x, standardize = FALSE) plot(res, type = "l", main = "Residuals", col = "steelblue", ...) abline(h = 0, lty = 3) grid() } # ------------------------------------------------------------------------------ .plot.garch.8 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 8. Conditional SDs: xcsd = volatility(x, "sigma") plot(xcsd, type = "l", main = "Conditional SD's", col = "steelblue", ...) abline(h = 0, lty = 3) grid() } # ------------------------------------------------------------------------------ .plot.garch.9 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 9. Standardized Residuals: sres = residuals(x, standardize = TRUE) plot(sres, type = "l", main = "Standardized Residuals", col = "steelblue", ...) abline(h = 0, lty = 3) grid() } # ------------------------------------------------------------------------------ .plot.garch.10 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 10. ACF of Standardized Residuals: sres = as.matrix(residuals(x, standardize = TRUE)) n = length(sres) lag.max = as.integer(10*log10(n)) acf(sres, lag.max = lag.max, xlab = "Lags", col = "steelblue", main = "ACF of Standardized Residuals", plot = TRUE) } # ------------------------------------------------------------------------------ .plot.garch.11 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 11. ACF of Squared Standardized Residuals: sres2 = as.matrix(residuals(x, standardize = TRUE)^2) n = length(sres2) lag.max = as.integer(10*log10(n)) acf(sres2, lag.max = lag.max, xlab = "Lags", col = "steelblue", main = "ACF of Squared Standardized Residuals", plot = TRUE) } # ------------------------------------------------------------------------------ .plot.garch.12 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 12. Cross Correlation between r^2 and r: sres = residuals(x, standardize = FALSE) sres2 = sres^2 n = length(sres) lag.max = as.integer(10*log10(n)) ccf(sres2, sres, lag.max = lag.max, xlab = "Lags", main = "Cross Correlation", plot = TRUE, col = "steelblue") } # ------------------------------------------------------------------------------ .plot.garch.13 <- function(x, ...) { # A function implemented by Diethelm Wuertz # Description: # Internal plot function # 13. QQ-Plot of Standardized Residuals: sres = residuals(x, standardize = TRUE) cond.dist = x@fit$params$cond.dist cond.dist = paste("q", cond.dist, sep = "") nc = nchar(x@fit$params$cond.dist) parNames <- names(x@fit$par) skew <- if ("skew" %in% parNames) x@fit$par["skew"] else x@fit$params$skew shape <- if ("shape" %in% parNames) x@fit$par["shape"] else x@fit$params$shape if (cond.dist == "qnorm" || cond.dist == "qQMLE") .qqDist(sres, dist = "qnorm") if (cond.dist == "qstd" | cond.dist == "qged") .qqDist(sres, dist = cond.dist, nu = shape) if (cond.dist == "qsnorm") .qqDist(sres, dist = cond.dist, xi = skew) if (cond.dist == "qsstd" | cond.dist == "qsged") .qqDist(sres, dist = cond.dist, xi = skew, nu = shape) if (cond.dist == "qsnig") .qqDist(sres, dist = ".qsnigC", rho = skew, zeta = shape) } # ------------------------------------------------------------------------------ .qqDist <- function (y, dist = "qnorm", ylim = NULL, main = paste(dist, "- QQ Plot"), xlab = "Theoretical Quantiles", ylab = "Sample Quantiles", doplot = TRUE, datax = FALSE, ...) { # A function implemented by Diethelm Wuertz # Description # QQ Plot for arbitray distribution # FUNCTION: # print(dist) # Match Function : qDist = match.fun(dist) # Check Arguments: # if (substr(dist, 1, 1) != "q") stop("dist is misspecified") # test = class(test = try(qDist(0.5, ...), silent = TRUE)) # if (test == "try-error") stop("dist does not exist") # Transform to Vector Mode: y = as.vector(y) # Compute Data: if (has.na <- any(ina <- is.na(y))) { yN = y y = y[!ina] } if (0 == (n <- length(y))) stop("y is empty or has only NAs") x <- qDist(ppoints(n,), ...)[order(order(y))] if (has.na) { y = x x = yN x[!ina] = y y = yN } # Create QQ Plot: if (doplot) { if (is.null(ylim)) ylim = range(y) if (datax) { plot(y, x, main = main, xlab = ylab, ylab = xlab, xlim = ylim, col = "steelblue", cex = 0.7) } else { plot(x, y, main = main, xlab = xlab, ylab = ylab, ylim = ylim, col = "steelblue", cex = 0.7) } .qqLine(y = y, dist = dist, datax = datax, ...) grid() } # Return Value: invisible(if (datax) list(x = y, y = x) else list(x = x, y = y)) } # ------------------------------------------------------------------------------ .qqLine <- function (y, dist = "qnorm", datax = FALSE, ...) { # A function implemented by Diethelm Wuertz # Description # Add slope to QQ Plot for arbitray distribution # FUNCTION: # Match Function : qDist = match.fun(dist) # Check Arguments: # if (substr(dist, 1, 1) != "q") stop("dist is misspecified") # test = class(test = try(qDist(0.5, ...), silent = TRUE)) # if (test == "try-error") stop("dist does not exist") # Transform to Vector Mode: y = as.vector(y) # Compute Data: y = quantile(y[!is.na(y)], c(0.25, 0.75)) x = qDist(c(0.25, 0.75), ...) # Add Slope: if (datax) { slope <- diff(x)/diff(y) int <- x[1] - slope * y[1] } else { slope <- diff(y)/diff(x) int <- y[1] - slope * x[1] } # Return Value: abline(int, slope) } ################################################################################ .plot.garch.14 <- function(x, ...) { ## A function implemented by Georgi N. Boshnakov ## Description: ## Internal plot function #= 14. Series with -VaR Superimposed: xseries = x@data plot(xseries, type = "l", col = "steelblue", ylab = "x", main = "Series with -VaR Superimposed") ## xseries is numeric here, so don't convert VaR to timeSeries lines(-VaR(x), col = "red") abline(h = 0, col = "grey", lty = 3) grid() } .plot.garch.15 <- function(x, ...) { ## A function implemented by Georgi N. Boshnakov ## Description: ## Internal plot function #= 14. Series with -ES Superimposed: xseries = x@data plot(xseries, type = "l", col = "steelblue", ylab = "x", main = "Series with -ES Superimposed") ## xseries is numeric here, so don't convert ES to timeSeries lines(-ES(x), col = "blue") abline(h = 0, col = "grey", lty = 3) grid() } .plot.garch.16 <- function(x, ...) { ## A function implemented by Georgi N. Boshnakov ## Description: ## Internal plot function #= 14. Series with -VaR & -ES Superimposed: xseries = x@data plot(xseries, type = "l", col = "steelblue", ylab = "x", main = "Series with -VaR & -ES Superimposed") ## xseries is numeric here, so don't convert VaR & ES to timeSeries lines(-VaR(x), col = "red") lines(-ES(x), col = "blue") abline(h = 0, col = "grey", lty = 3) grid() } fGarch/R/garch-FitFromFormula.R0000644000176200001440000001445115104730075015755 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # garchFit Fits the parameters of GARCH process # .garchArgsParser Parses formula and data for garchFit # .garchOptimizerControl Sets default values for Garch Optimizer # .garchFit ... old Version, still in use by garchFit() # .garchNames Slot names, @fit slot, parameters and controls ################################################################################ garchFit <- function(formula = ~ garch(1,1), data, init.rec = c("mci", "uev"), delta = 2, skew = 1, shape = 4, cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "snig", "QMLE"), include.mean = TRUE, include.delta = NULL, include.skew = NULL, include.shape = NULL, leverage = NULL, trace = TRUE, algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), hessian = c("ropt", "rcd"), control = list(), title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fit parameters to a ARMA-GARCH model by Formula Specification # Arguments: # formula - ARMA(m,n) + GARCH/APARCH(p,q) mean and variance # specification # data - any univariate time series which can be converted # into a timeSeries using the generic function as.timeSeries # init.rec - names type of initialization of recurrence # mci = mu-current-iteration, or # uev = unconditional-expected-variances # delta - numeric value of the exponent delta # skew - optional skewness or skewness related parameter # shape - optional shape parameter # cond.dist - name of the conditional distribution, one of # norm, snorm, ged, sged, std, sstd, snig, QMLE # include.mean - a logical, should the mean value be estimated ? # include.delta - should the exponent be estimated ? # leverage - should the leverage factors be estimated ? # trace - should the optimization be traced ? # control - list of additional control parameters for the solver # title - an optional title string # description - an optional project description string # Example: # garchFit() # FUNCTION: # DEBUG: DEBUG = FALSE # Match arguments: init.rec = match.arg(init.rec) cond.dist = match.arg(cond.dist) hessian = match.arg(hessian) algorithm = match.arg(algorithm) # Call: CALL = match.call() # Parse formula and data for garchFit ... # Note in the new version we are working with timeSeries ... Name = capture.output(substitute(data)) if(is.character(data)) { eval(parse(text = paste("data(", data, ")"))) data = eval(parse(text = data)) } # data <- if (inherits(data, "timeSeries") data else as.timeSeries(data) data <- as.data.frame(data) # Column Names: if (isUnivariate(data)) { colnames(data) <- "data" } else { # Check unique column Names: uniqueNames = unique(sort(colnames(data))) if (is.null(colnames(data))) { stop("Column names of data are missing.") } if (length(colnames(data)) != length(uniqueNames)) { stop("Column names of data are not unique.") } } # Handle if we have no left-hand-side for the formula ... # Note in this case the length of the formula is 2 (else 3): if (length(formula) == 3 && isUnivariate(data) ) formula[2] <- NULL if (length(formula) == 2) { if (isUnivariate(data)) { # Missing lhs -- we substitute the data file name as lhs ... formula = as.formula(paste("data", paste(formula, collapse = " "))) } else { stop("Multivariate data inputs require lhs for the formula.") } } # Robust Covariance ? robust.cvar <- (cond.dist == "QMLE") # Parse Arguments: args = .garchArgsParser(formula = formula, data = data, trace = FALSE) # DEBUG - Print Arguments: if (DEBUG) print(list( formula.mean = args$formula.mean, formula.var = args$formula.var, series = args$series, init.rec = init.rec, delta = delta, skew = skew, shape = shape, cond.dist = cond.dist, include.mean = include.mean, include.delta = include.delta, include.skew = include.skew, include.shape = include.shape, leverage = leverage, trace = trace, algorithm = algorithm, hessian = hessian, robust.cvar = robust.cvar, control = control, title = title, description = description)) # Fit: ans = .garchFit( formula.mean = args$formula.mean, formula.var = args$formula.var, series = args$series, init.rec, delta, skew, shape, cond.dist, include.mean, include.delta, include.skew, include.shape, leverage, trace, algorithm, hessian, robust.cvar, control, title, description, ...) ans@call = CALL attr(formula, "data") <- paste("data = ", Name, sep = "") ans@formula = formula # Return Value: ans } ################################################################################ fGarch/R/dist-absMoments.R0000644000176200001440000000706415104730075015052 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: MOMENTS: # absMoments Compute absolute moments of a symmetric distribution ################################################################################ absMoments <- function(n, density = c("dnorm", "dged", "dstd"), ...) { # A function implemented by Diethelm Wuertz ## ## Georgi N. Boshnakov corrected the computation for std # Description: # Compute the absolute moments of a standardized # symmetric distribution function. # Arguments: # n - a vector of integers i, to compute M_i # density - a character denoting the density # "norm", "ged", "std" or any other # ... - parameters passed to the standardized # symmetric density function # Value: # Returns a numeric vector of moments M_i. # Stores globally errors in the variable absMoment.error # if the moments were computed numerically. # FUNCTION: # norm - Normal Distribution: if (density == "dnorm" | density == "norm") { return (sqrt(2)^n * gamma((n+1)/2) / sqrt(pi)) } # ged - Generalized Error Distribution: if (density == "dged" | density == "ged") { parm = function(n, nu) { lambda = sqrt ( 2^(-2/nu) * gamma(1/nu) / gamma(3/nu) ) return ((2^(1/nu)*lambda)^n * gamma((n+1)/nu) / gamma(1/nu)) } return(parm(n, ...)) } # std - Standardized Student-t Distribution: # Note: nu > 2*n if (density == "dstd" | density == "std") { parm = function(n, nu) { ## GNB: this is wrong, gives NaN's when it shouldn't: ## beta(1/2 + 2*n, nu/2 - 2*n) / beta(1/2, nu/2) * sqrt(nu-2) ## ## This is from the paper Wuertz at all (draft for JSS), eq. (14): ## ## r <- n / 2 ## beta(1/2 + r/2, nu/2 - r/2) / beta(1/2, nu/2) * (nu-2)^(r/2) ## ## but the results are not right. It looks like a typo/error in the ## formula and changing r/2 to n/2 gives a consistent result with ## the usual t-distribution ## beta(1/2 + n/2, nu/2 - n/2) / beta(1/2, nu/2) * (nu-2)^(n/2) } return(parm(n, ...)) } # Any other standardized symmetric Distribution ... fun = match.fun(density) moments = function(x, n, ...) { 2 * x^n * fun(x, ...) } M = .absMoments.error <- NULL for (i in n) { I = integrate(moments, 0, Inf, n = i, ...) M = c(M, I$value) .absMoments.error <- c(.absMoments.error, I$abs.error) } attr(M, "control") <- .absMoments.error return(M) # Return Value: invisible() } ################################################################################ fGarch/R/methods-fitted.R0000644000176200001440000000625215104730075014717 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # METHOD: EXTRACTORS: # fitted.fGARCH S3 fitted values for an object of class 'fGARCH' ################################################################################ setMethod(f = "fitted", signature(object = "fGARCH"), definition = function(object) { # A function implemented by Diethelm Wuertz # Description: # S3 Fitted values method for an object of class fGARCH # Arguments: # object - an object of class fGarch as returned by the function # garchFit # FUNCTION: ## GNB: this was the previous code (before v4022.90). Clearly, it assumes ## that 'data' is from class \code{"timeSeries"} and, to return an ## object from the same class, gets 'data' and replaces the data values ## with the fitted ones. ... Except that it doesn't do the latter, so ## returns the data! ## ## # Get numeric vector of fitted, optionally standardized ## fitted = object@fitted ## ## Get original time series class: (!! GNB: Nope, slot 'data' is numeric!) ## ans = slot(object, "data") ## Name = as.character(object@formula[2]) ## attr(ans, "Name") <- Name ## # Return Value: ## ans ## ## GNB: the following code is in the spirit of the above, assuming that ## 'ans' is indeed the original time series. For example (todo?) this ## could be achieved if garchFit sets object@fit$data to the original ## time series, using 'ans <- object@fit$data'. Changing the class of ## slot 'data' instead doesn't seem practical. ## ## fitted <- object@fitted ## if(is(ans, "timeSeries")){ ## Name <- as.character(object@formula[2]) ## attr(ans, "Name") <- Name ## ans@.Data <- if(is.matrix(fitted)) fitted else matrix(fitted, ncol = 1) ## } else if(inherits(ans, "ts") || is.numeric(ans)) { ## ans[] <- fitted ## } else { ## message(paste0("conversion to class '", class(ans), "' not supported yet,\n", ## "returning slot fitted asis.")) ## ans <- fitted ## } ans <- object@fitted # Return Value: ans }) ################################################################################ fGarch/R/garch-Stats.R0000644000176200001440000001070415104730075014154 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # garchKappa Computes Expection for APARCH Models # .garchKappaFun Internal function used by garchKappa() # FUNCTION: DESCRIPTION: # .truePersistence Computes true persistence ################################################################################ garchKappa <- function(cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd", "snig"), gamma = 0, delta = 2, skew = NA, shape = NA) { # A function implemented by Diethelm Wuertz # Description: # Computes Expection for APARCH Models # FUNCTION: # Compute kappa: kappa = integrate(.garchKappaFun, lower = -Inf, upper = Inf, cond.dist = cond.dist[1], gamma = gamma, delta = delta, skew = skew, shape = shape)[[1]] names(kappa) = "kappa" attr(kappa, "control") = c(gamma = gamma, delta = delta, skew = skew, shape = shape) attr(kappa, "cond.dist") = cond.dist[1] # Return Value: kappa } # ------------------------------------------------------------------------------ .garchKappaFun <- function(x, cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd", "snig"), gamma = 0, delta = 2, skew = NA, shape = NA) { # A function implemented by Diethelm Wuertz # Description: # Internal function used by kappa() # FUNCTION: # Compute Expectation Value for ... funcE = (abs(x) - gamma*x)^delta # Select Appropriate Conditional Density: cond.dist = cond.dist[1] if (cond.dist == "norm") { fun = funcE * dnorm(x) } if (cond.dist == "ged") { fun = funcE * dged(x, nu = shape) } if (cond.dist == "std") { fun = funcE * dstd(x, nu = shape) } if (cond.dist == "snorm") { fun = funcE * dsnorm(x, xi = skew) } if (cond.dist == "sged") { fun = funcE * dsged(x, nu = shape, xi = skew) } if (cond.dist == "sstd") { fun = funcE * dsstd(x, nu = shape, xi = skew) } if (cond.dist == "snig") { fun = funcE * dsnig(x, zeta = shape, rho = skew) } # Return Value: fun } ################################################################################ .truePersistence <- function(fun = "norm", alpha = 1, gamma = 0, beta = 0, delta = 1, ...) { # A function implemented by Diethelm Wuertz # Description: # Computes persistence for an APARCH process # Arguments: # fun - name of density functions of APARCH innovations # alpha, gamma - numeric value or vector of APARCH coefficients, # must be of same length # beta - numeric value or vector of APARCH coefficients # delta - numeric value of APARCH exponent # Note: # fun is one of: norm, snorn, std, sstd, ged, sged, snig # FUNCTION: # Match Density Function: fun = match.fun(fun) # Persisgtence Function: E(|z|-gamma z)^delta e = function(x, gamma, delta, ...) { (abs(x)-gamma*x)^delta * fun(x, ...) } # Compute Persistence by Integration: persistence = sum(beta) for (i in 1:length(alpha)) { I = integrate(e, -Inf, Inf, subdivisions = 1000, rel.tol = .Machine$double.eps^0.5, gamma = gamma[i], delta = delta, ...) persistence = persistence + alpha[i] * I[[1]] } # Warning: if (persistence >= 1) { p = as.character(round(persistence, digits = 3)) warning(paste("Divergent persistence p =", p)) } # Return Value: persistence } ################################################################################ fGarch/R/dist-stdSlider.R0000644000176200001440000000646615104730075014704 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # stdSlider Displays Variance-1 Student-t Distribution and RVS ################################################################################ stdSlider <- function(type = c("dist", "rand")) { # A function implemented by Diethelm Wuertz # Description: # Displays interactively Student-t distribution # Note: # dstd(x, mean = 0, sd = 1, nu = 5) # FUNCTION: # Internal Function: refresh.code = function(...) { # Sliders: N = .sliderMenu(no = 1) mean = .sliderMenu(no = 2) sd = .sliderMenu(no = 3) nu = .sliderMenu(no = 4) # Compute Data: xmin = round(qstd(0.01, mean, sd, nu), digits = 2) xmax = round(qstd(0.99, mean, sd, nu), digits = 2) s = seq(xmin, xmax, length = N) y1 = dstd(s, mean, sd, nu) y2 = pstd(s, mean, sd, nu) main1 = paste("Student-t Density\n", "mean = ", as.character(mean), " | ", "sd = ", as.character(sd), " | ", "nu = ", as.character(nu)) main2 = paste("Student-t Probability\n", "xmin [0.01] = ", as.character(xmin), " | ", "xmax [0.99] = ", as.character(xmax) ) # Random Numbers: if (type[1] == "rand") { x = rstd(N, mean, sd, nu) } # Frame: par(mfrow = c(2, 1), cex = 0.7) # Density: if (type[1] == "rand") { hist(x, probability = TRUE, col = "steelblue", border = "white", breaks = "FD", xlim = c(xmin, xmax), ylim = c(0, 1.1*max(y1)), main = main1 ) lines(s, y1, col = "orange") } else { plot(s, y1, type = "l", xlim = c(xmin, xmax), col = "steelblue") abline (h = 0, lty = 3) title(main = main1) grid() } # Probability: plot(s, y2, type = "l", xlim = c(xmin, xmax), ylim = c(0, 1), col = "steelblue" ) abline (h = 0, lty = 3) title(main = main2) grid() # Frame: par(mfrow = c(1, 1), cex = 0.7) } # Open Slider Menu: .sliderMenu(refresh.code, names = c( "N", "mean", "sd", "nu"), minima = c( 10, -5.0, 0.1, 2.1), maxima = c( 500, +5.0, 5.0, 10.0), resolutions = c( 10, 0.1, 0.1, 0.1), starts = c( 100, 0.0, 1.0, 5.0) ) } ################################################################################ fGarch/R/garch-SolverControl.R0000644000176200001440000000745715104730075015704 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ############################################################################## # FUNCTION: DESCRIPTION: # garchFitControl Sets default values for Garch Optimizer ############################################################################## garchFitControl <- function( llh = c("filter", "internal", "testing"), nlminb.eval.max = 2000, nlminb.iter.max = 1500, nlminb.abs.tol = 1.0e-20, nlminb.rel.tol = 1.0e-14, nlminb.x.tol = 1.0e-14, nlminb.step.min = 2.2e-14, nlminb.scale = 1, nlminb.fscale = FALSE, nlminb.xscale = FALSE, sqp.mit = 200, sqp.mfv = 500, sqp.met = 2, sqp.mec = 2, sqp.mer = 1, sqp.mes = 4, sqp.xmax = 1.0e3, sqp.tolx = 1.0e-16, sqp.tolc = 1.0e-6, sqp.tolg = 1.0e-6, sqp.told = 1.0e-6, sqp.tols = 1.0e-4, sqp.rpf = 1.0e-4, lbfgsb.REPORT = 10, lbfgsb.lmm = 20, lbfgsb.pgtol = 1e-14, lbfgsb.factr = 1, lbfgsb.fnscale = FALSE, lbfgsb.parscale = FALSE, nm.ndeps = 1e-14, nm.maxit = 10000, nm.abstol = 1e-14, nm.reltol = 1e-14, nm.alpha = 1.0, nm.beta = 0.5, nm.gamma = 2.0, nm.fnscale = FALSE, nm.parscale = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Sets default values for Garch Optimizer # FUNCTION: # Generate Control List with Default Settings: control <- list( llh = llh, nlminb.eval.max = nlminb.eval.max, nlminb.iter.max = nlminb.iter.max, nlminb.abs.tol = nlminb.abs.tol, nlminb.rel.tol = nlminb.rel.tol, nlminb.x.tol = nlminb.x.tol, nlminb.step.min = nlminb.step.min, nlminb.scale = nlminb.scale, nlminb.fscale = nlminb.fscale, nlminb.xscale = nlminb.xscale, sqp.mit = sqp.mit, sqp.mfv = sqp.mfv, sqp.met = sqp.met, sqp.mec = sqp.mec, sqp.mer = sqp.mer, sqp.mes = sqp.mes, sqp.xmax = sqp.xmax, sqp.tolx = sqp.tolx, sqp.tolc = sqp.tolc, sqp.tolg = sqp.tolg, sqp.told = sqp.told, sqp.tols = sqp.tols, sqp.rpf = sqp.rpf, lbfgsb.REPORT = lbfgsb.REPORT, lbfgsb.lmm = lbfgsb.lmm, lbfgsb.pgtol = lbfgsb.pgtol, lbfgsb.factr = lbfgsb.factr, lbfgsb.fnscale = lbfgsb.fnscale, lbfgsb.parscale = lbfgsb.parscale, nm.ndeps = nm.ndeps, nm.maxit = nm.maxit, nm.abstol = nm.abstol, nm.reltol = nm.reltol, nm.alpha = nm.alpha, nm.beta = nm.beta, nm.gamma = nm.gamma, nm.fnscale = nm.fnscale, nm.parscale = nm.parscale ) # Return Value: control } ################################################################################ fGarch/R/garch-Spec.R0000644000176200001440000001725715104730075013762 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: SPECIFICATION: # garchSpec Creates a 'garchSpec' object from scratch ############################################################################### garchSpec <- function (model = list(), presample = NULL, cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd"), rseed = NULL) { # A function implemented by Diethelm Wuertz # Description: # Creates a "garchSpec" object from scratch. # Arguments: # model - a list with the model parameters as entries # omega - the variance value for GARCH/APARCH # specification, # alpha - a vector of autoregressive coefficients # of length p for the GARCH/APARCH specification, # gamma - a vector of leverage coefficients of # length p for the APARCH specification, # beta - a vector of moving average coefficients of # length q for the GARCH/APARCH specification, # mu - the mean value for ARMA specification, # ar - a vector of autoregressive coefficients of # length m for the ARMA specification, # ma - a vector of moving average coefficients of # length n for the ARMA specification, # delta - the exponent value used in the variance equation. # skew - a numeric value listing the distributional # skewness parameter. # shape - a numeric value listing the distributional # shape parameter. # presample - either a multivariate "timeSeries", a # multivariate "ts", a "data.frame" object or a numeric # "matrix" with 3 columns and at least max(m,n,p,q) # rows. The first culumn are the innovations, the second # the conditional variances, and the last the time series. # condd.dist - a character string naming the distribution # function. # rseed - optional random seed. # Slots: # call - the function call. # formula - a formula object describing the model, e.g. # ARMA(m,n) + GARCH(p,q). ARMA can be missing or # specified as AR(m) or MA(n) in the case of pure # autoregressive or moving average models. GARCH may # alternatively specified as ARCH(p) or APARCH(p,q). # If formula is set to "NA", the formula is constructed # from the "model" list. # model - as declared in the input. # FUNCTION: # Match Arguments: cond.dist = match.arg(cond.dist) # Skewness Parameter Settings: skew = list( "norm" = NULL, "ged" = NULL, "std" = NULL, "snorm" = 0.9, "sged" = 0.9, "sstd" = 0.9) # Shape Parameter Settings: shape = list( "norm" = NULL, "ged" = 2, "std" = 4, "snorm" = NULL, "sged" = 2, "sstd" = 4) # Default Model: control = list( omega = 1.0e-6, alpha = 0.1, gamma = NULL, beta = 0.8, mu = NULL, ar = NULL, ma = NULL, delta = 2, skew = skew[[cond.dist]], shape = shape[[cond.dist]] ) # Update Control: control[names(model)] <- model model <- control # check if alpha and beta are well defined if (sum(c(model$alpha, model$beta))>1) warning("sum(alpha)+sum(beta)>1") # Model Orders: order.ar = length(model$ar) order.ma = length(model$ma) order.alpha = length(model$alpha) if (sum(model$beta) == 0) { order.beta = 0 } else { order.beta = length(model$beta) } # Compose Mean Formula Object: if (order.ar == 0 && order.ma == 0) { formula.mean = "" } if (order.ar > 0 && order.ma == 0) { formula.mean = paste ("ar(", as.character(order.ar), ")", sep = "") } if (order.ar == 0 && order.ma > 0) { formula.mean = paste ("ma(", as.character(order.ma), ")", sep = "") } if (order.ar > 0 && order.ma > 0) { formula.mean = paste ("arma(", as.character(order.ar), ", ", as.character(order.ma), ")", sep = "") } # Compose Variance Formula Object: formula.var = "garch" if (order.beta == 0) formula.var = "arch" if (!is.null(model$gamma) != 0) formula.var = "aparch" if (model$delta != 2) formula.var = "aparch" if (order.beta == 0) { formula.var = paste(formula.var, "(", as.character(order.alpha), ")", sep = "") } else { formula.var = paste(formula.var, "(", as.character(order.alpha), ", ", as.character(order.beta), ")", sep = "") } # Compose Mean-Variance Formula Object: if (formula.mean == "") { formula = as.formula(paste("~", formula.var)) } else { formula = as.formula(paste("~", formula.mean, "+", formula.var)) } # Add NULL default entries: if (is.null(model$mu)) model$mu = 0 if (is.null(model$ar)) model$ar = 0 if (is.null(model$ma)) model$ma = 0 if (is.null(model$gamma)) model$gamma = rep(0, times = order.alpha) # print(unlist(model)) # Seed: if (is.null(rseed)) { rseed = 0 } else { set.seed(rseed) } # Define Missing Presample: order.max = max(order.ar, order.ma, order.alpha, order.beta) iterate = TRUE if (!is.matrix(presample)) { if (is.null(presample)) { iterate = FALSE n.start = order.max } else { n.start = presample } z = rnorm(n = n.start) # GARCH(p, q): h = rep(model$omega/(1-sum(model$alpha)-sum(model$beta)), times = n.start) y = rep(model$mu/(1-sum(model$ar)), times = n.start) # APARCH(p,q): # ... we initialize all models with norm-GARCH(p,q) processes } else { z = presample[, 1] h = presample[, 2] y = presample[, 3] } presample = cbind(z, h, y) # Presample Iteration: if (iterate) { n.iterate = length(z) - order.max deltainv = 1/model$delta for (i in n.iterate:1) { h[i] = model$omega + sum(model$alpha*(abs(abs(y[i+(1:order.alpha)]) - model$gamma*y[i+(1:order.alpha)])^model$delta)) + sum(model$beta*h[i+(1:order.beta)]) y[i] = model$mu + sum(model$ar*y[i+(1:order.ar)]) + sum(model$ma*(h[i+(1:order.ma)]**deltainv)) + h[i]^deltainv * z[i] } } # Result: new("fGARCHSPEC", call = match.call(), formula = formula, model = list(omega = model$omega, alpha = model$alpha, gamma = model$gamma, beta = model$beta, mu = model$mu, ar = model$ar, ma = model$ma, delta = model$delta, skew = model$skew, shape = model$shape), presample = as.matrix(presample), distribution = as.character(cond.dist), rseed = as.numeric(rseed) ) } ################################################################################ fGarch/R/loglik-egarch.R0000644000176200001440000000170715104730075014507 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .egarchLLH ARMA-EGARCH model ################################################################################ fGarch/R/methods-predict.R0000644000176200001440000002726515104730075015101 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # METHOD: PREDICTION: # predict.fGARCH Forecasts from an object of class 'fGARCH' ################################################################################ setMethod(f = "predict", signature(object = "fGARCH"), definition = function(object, n.ahead = 10, trace = FALSE, mse = c("cond","uncond"), plot=FALSE, nx=NULL, crit_val=NULL, conf=NULL, ..., p_loss = NULL # GNB: for ES and VaR ) { # A function implemented by Diethelm Wuertz # Description: # Prediction method for an object of class fGARCH # Arguments: # object an object of class fGARCH as returned by the # function garchFit(). # n.ahead number of steps to be forecasted, an integer # value, by default 10) # trace should the prediction be traced? A logical value, # by default FALSE) # mse should the mean squared errors be conditional or unconditional # plot should the predictions be plotted # nx The number of observations to be plotted with the predictions # (If plot is TRUE, the default value of nx is the sample # size times 0.25.) # crit_va If you want to set manually the critical values for # the confidence intervals # conf The confidence level for computing the critical values # of the confidence intervals # FUNCTION: mse <- match.arg(mse) # Retrieve "fit" from Parameter Estimation: fit = object@fit # Get ARMA(u,v)-GARCH(p,q) Order: u = fit$series$order[1] v = fit$series$order[2] p = fit$series$order[3] q = fit$series$order[4] max.order = max(u, v, p, q) # Get Start Conditions: h.start = fit$series$h.start llh.start = fit$series$llh.start index = fit$params$index params = fit$params$params par = fit$par Names = names(index) for (Name in Names) params[Name] = par[Name] Names = names(params) # Retrieve From Initialized Parameters: cond.dist = fit$params$cond.dist # Extract the Parameters by Name: leverage = fit$params$leverage mu = params["mu"] if (u > 0) { ar = params[substr(Names, 1, 2) == "ar"] } else { ar = c(ar1 = 0) } if (v > 0) { ma = params[substr(Names, 1, 2) == "ma"] } else { ma = c(ma1 = 0) } omega = params["omega"] if (p > 0) { alpha = params[substr(Names, 1, 5) == "alpha"] } else { alpha = c(alpha1 = 0) } if (p > 0 & leverage) { gamma = params[substr(Names, 1, 5) == "gamma"] } else { gamma = c(gamma1 = 0) } if (q > 0) { beta = params[substr(Names, 1, 4) == "beta"] } else { beta = c(beta1 = 0) } delta = params["delta"] skew = params["skew"] shape = params["shape"] # Trace Parameters: if (trace) { cat("\nModel Parameters:\n") print(c(mu, ar, ma, omega, alpha, gamma, beta, delta, skew, shape)) } # Retrieve Series Lengths: M = n.ahead N = length(object@data) # Get and Extend Series: x = c(object@data, rep(mu, M)) h = c(object@h.t, rep(0, M)) z = c(fit$series$z, rep(mu, M)) # Forecast and Optionally Trace Variance Model: var.model = fit$series$model[2] # Forecast GARCH Variance: if (var.model == "garch") { if (trace) cat("\nForecast GARCH Variance:\n") for (i in 1:M) { h[N+i] = omega + sum(beta*h[N+i-(1:q)]) for (j in 1:p) { if (i-j > 0) { s = h[N + i - j] } else { s = z[N + i - j]^2 } h[N+i] = h[N+i] + alpha[j] * s } } } # Forecast APARCH Variance: if (var.model == "aparch") { if (trace) cat("\nForecast APARCH Variance:\n") for (i in 1:M) { h[N+i] = omega + sum(beta*h[N+i-(1:q)]) for (j in 1:p) { ## 2024-01-30 GNB: TODO: ## it seems that kappa doesn't depend on i; ## so, kappa[1], ..., kappa[p] can be computed outside the i-loop ## and the formulas below use kappa[j] kappa = garchKappa(cond.dist = cond.dist, gamma = gamma[j], delta = delta, skew = skew, shape = shape) if (i-j > 0) { s = kappa * h[N + i - j] } else { s = (abs(z[N + i - j]) - gamma[j]*z[N + i - j])^delta } h[N+i] = h[N+i] + alpha[j] * s } } } # Forecast and Optionally Trace Mean Model: # Note we set maxit=0 to get an object of class Arima with fixed # init parameters ... mu <- mu/(1-sum(ar)) ARMA <- arima(x = object@data, order = c(max(u, 1), 0, max(v, 1)), init = c(ar, ma, mu), transform.pars = FALSE, optim.control = list(maxit = 0)) prediction = predict(ARMA, n.ahead) meanForecast = as.vector(prediction$pred) if(mse=="uncond") { meanError = as.vector(prediction$se) } else { # coefficients of h(t+1) a_vec <- rep(0,(n.ahead)) hhat <- h[-(1:N)]^(2/delta[[1]]) #-> [[1]] to omit name of delta u2 <- length(ar) meanError <- hhat[1] a_vec[1] = ar[1] + ma[1] meanError <- na.omit(c(meanError,sum(hhat[1:2]*c(a_vec[1]^2,1)))) if ((n.ahead - 1) > 1) { for( i in 2:(n.ahead - 1)) { a_vec[i] <- ar[1:min(u2,i-1)]*a_vec[(i-1):(i-u2)] + ifelse(i>u,0,ar[i]) + ifelse(i>v,0,ma[i]) meanError <- na.omit(c(meanError, sum(hhat[1:(i+1)]*c(a_vec[i:1]^2,1)))) } } meanError <- sqrt(meanError) } if (trace) { cat("\nForecast ARMA Mean:\n") print(ARMA) cat("\n") print(prediction) } # Standard Deviations: standardDeviation = h^(1/delta) # Plotting the predictions if (plot) { if(is.null(nx)) nx <- round(length(object@data)*.25) t <- length(object@data) x <- c(object@data[(t-nx+1):t],meanForecast) # Computing the appropriate critical values if (is.null(conf)) conf <- 0.95 if (is.null(crit_val)) { if (object@fit$params$cond.dist=="norm") { crit_valu <- qnorm(1-(1-conf)/2) crit_vald <- qnorm((1-conf)/2) } if (object@fit$params$cond.dist=="snorm") { crit_valu <- qsnorm(1-(1-conf)/2,xi=coef(object)["skew"]) crit_vald <- qsnorm((1-conf)/2,xi=coef(object)["skew"]) } if (object@fit$params$cond.dist=="ged") { crit_valu <- qged(1-(1-conf)/2,nu=coef(object)["shape"]) crit_vald <- qged((1-conf)/2,nu=coef(object)["shape"]) } if (object@fit$params$cond.dist=="sged") { crit_valu <- qsged(1-(1-conf)/2,nu=coef(object)["shape"], xi=coef(object)["skew"]) crit_vald <- qsged((1-conf)/2,nu=coef(object)["shape"], xi=coef(object)["skew"]) } if (object@fit$params$cond.dist=="std") { crit_valu <- qstd(1-(1-conf)/2,nu=coef(object)["shape"]) crit_vald <- qstd((1-conf)/2,nu=coef(object)["shape"]) } if (object@fit$params$cond.dist=="sstd") { crit_valu <- qsstd(1-(1-conf)/2,nu=coef(object)["shape"], xi=coef(object)["skew"]) crit_vald <- qsstd((1-conf)/2,nu=coef(object)["shape"], xi=coef(object)["skew"]) } if (object@fit$params$cond.dist=="snig") { crit_valu <- qsnig(1-(1-conf)/2,zeta=coef(object)["shape"], rho=coef(object)["skew"]) crit_vald <- qsnig((1-conf)/2,zeta=coef(object)["shape"], rho=coef(object)["skew"]) } if (object@fit$params$cond.dist=="QMLE") { e <- sort(object@residuals/object@sigma.t) crit_valu <- e[round(t*(1-(1-conf)/2))] crit_vald <- e[round(t*(1-conf)/2)] } } else { if (length(crit_val)==2) { crit_valu <- crit_val[2] crit_vald <- crit_val[1] } if (length(crit_val)==1) { crit_valu <- abs(crit_val) crit_vald <- -abs(crit_val) } } int_l <- meanForecast+crit_vald*meanError int_u <- meanForecast+crit_valu*meanError ylim_l <- min(c(x,int_l)*(.95)) ylim_u <- max(c(x,int_u)*(1.05)) plot(x,type='l',ylim=c(ylim_l,ylim_u)) title("Prediction with confidence intervals") lines((nx+1):(nx+n.ahead), meanForecast, col = 2, lwd = 2) lines((nx+1):(nx+n.ahead), int_l, col = 3, lwd = 2) lines((nx+1):(nx+n.ahead), int_u, col = 4, lwd = 2) polygon(c((nx+1):(nx+n.ahead),(nx+n.ahead):(nx+1)), c(int_l, int_u[n.ahead:1]), border = NA, density = 20, col = 5, angle = 90) es1 <- as.expression(substitute(hat(X)[t+h] + crit_valu*sqrt(MSE), list(crit_valu=round(crit_valu,3)))) es2 <- as.expression(substitute(hat(X)[t+h] - crit_vald*sqrt(MSE), list(crit_vald=abs(round(crit_vald,3))))) es3 <- expression(hat(X)[t+h]) legend("bottomleft",c(es3,es2,es1),col=2:4,lty=rep(1,3),lwd=rep(2,3)) grid() } ## Result: forecast <- data.frame( meanForecast = meanForecast, meanError = meanError, standardDeviation = standardDeviation[-(1:N)]) if(plot) forecast = data.frame( forecast, lowerInterval = int_l, upperInterval = int_u) ## if(plot) { ## forecast = data.frame( ## meanForecast = meanForecast, ## meanError = meanError, ## standardDeviation = standardDeviation[-(1:N)], ## lowerInterval = int_l, ## upperInterval = int_u) ## } else { ## forecast = data.frame( ## meanForecast = meanForecast, ## meanError = meanError, ## standardDeviation = standardDeviation[-(1:N)]) ## } ## 2024-01-31 GNB: VaR and ES - experimental if(!is.null(p_loss)) { cond_dist <- object@fit$params$cond.dist mu_t <- meanForecast sigma_t <- standardDeviation[-(1:N)] qf <- qfun_fGarch(cond_dist, coef(object)) predVaR <- cvar::VaR_qf(qf, p_loss, intercept = mu_t, slope = sigma_t) predES <- cvar::ES(qf, p_loss, intercept = mu_t, slope = sigma_t) forecast <- data.frame(forecast, VaR = predVaR, ES = predES) attr(forecast, "p_loss") <- p_loss } # Return Value: forecast }) ################################################################################ fGarch/R/methods-coef.R0000644000176200001440000000414615104730075014354 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # METHOD: EXTRACTORS: # coef.fGARCH Extracts 'fGarch' Model Coefficients ################################################################################ setMethod(f = "coef", signature(object = "fGARCH"), definition = function(object) { # A function implemented by Diethelm Wuertz # Description: # Extracts 'fGarch' Model Coefficients # Arguments: # object - an object of class fGarch as returned by the function # garchFit # FUNCTION: # Numeric vector of fitted values: ans = slot(object, "fit")$coef # Return Value: ans }) # ------------------------------------------------------------------------------ setMethod(f = "coef", signature(object = "fGARCHSPEC"), definition = function(object) { # A function implemented by Diethelm Wuertz # Description: # Extracts 'fGarch' Model Coefficients # Arguments: # object - an object of class fGarch as returned by the function # garchFit # FUNCTION: # Numeric vector of fitted values: ans = unlist(slot(object, "model")) attr(ans, "distribution") <- slot(object, "distribution") # Return Value: ans }) ################################################################################ fGarch/R/dist-snormSlider.R0000644000176200001440000000705115104730075015237 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # snormSlider Displays Normal Distribution and RVS ################################################################################ snormSlider <- function(type = c("dist", "rand")) { # A function implemented by Diethelm Wuertz # Description: # Displays interactively skew Normal distribution # Note: # dsnorm(x, mean = 0, sd = 1, xi = 1.5) # FUNCTION: # Internal Function: refresh.code = function(...) { # Sliders: N = .sliderMenu(no = 1) mean = .sliderMenu(no = 2) sd = .sliderMenu(no = 3) xi = .sliderMenu(no = 4) invert = .sliderMenu(no = 5) # Compute Data: if (invert == 1) xi = 1/xi xmin = round(qsnorm(0.001, mean, sd, xi), digits = 2) xmax = round(qsnorm(0.999, mean, sd, xi), digits = 2) s = seq(xmin, xmax, length = N) y1 = dsnorm(s, mean, sd, xi) y2 = psnorm(s, mean, sd, xi) main1 = paste("Skew Normal Density\n", "mean = ", as.character(mean), " | ", "sd = ", as.character(sd), " | ", "xi = ", as.character(xi) ) main2 = paste("Skew Normal Probability\n", "xmin [0.001] = ", as.character(xmin), " | ", "xmax [0.999] = ", as.character(xmax) ) # Random Numbers: if (type[1] == "rand") { x = rsnorm(N, mean, sd, xi) } # Frame: par(mfrow = c(2, 1), cex = 0.7) # Density: if (type[1] == "rand") { hist(x, probability = TRUE, col = "steelblue", border = "white", breaks = "FD", xlim = c(xmin, xmax), ylim = c(0, 1.1*max(y1)), main = main1 ) lines(s, y1, col = "orange") } else { plot(s, y1, type = "l", xlim = c(xmin, xmax), col = "steelblue") abline (h = 0, lty = 3) title(main = main1) grid() } # Probability: plot(s, y2, type = "l", xlim = c(xmin, xmax), ylim = c(0, 1), col = "steelblue" ) abline (h = 0, lty = 3) title(main = main2) grid() # Frame: par(mfrow = c(1, 1), cex = 0.7) } # Open Slider Menu: .sliderMenu(refresh.code, names = c( "N", "mean", "sd", "xi", "xi.inv"), minima = c( 10, -5.0, 0.1, 1.0, 0 ), maxima = c( 500, +5.0, 5.0, 10.0, 1 ), resolutions = c( 10, 0.1, 0.1, 0.1, 1 ), starts = c( 100, 0.0, 1.0, 1.0, 0 ) ) } ################################################################################ fGarch/R/dist-sstd.R0000644000176200001440000001523315104730075013714 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # dsstd Density for the skewed Student-t Distribution # psstd Probability function for the skewed STD # qsstd Quantile function for the skewed STD # rsstd Random Number Generator for the skewed STD # FUNCTION: DESCRIPTION: # .dsstd Internal, density for the skewed Student-t Distribution # .psstd Internal, probability function for the skewed STD # .qsstd Internal, quantile function for the skewed STD # .rsstd Internal, random Number Generator for the skewed STD ################################################################################ dsstd <- function(x, mean = 0, sd = 1, nu = 5, xi = 1.5, log = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Compute the density function of the # skewed Student-t distribution # FUNCTION: # Params: if (length(mean) == 4) { xi = mean[4] nu = mean[3] sd = mean[2] mean = mean[1] } # Shift and Scale: result = .dsstd(x = (x-mean)/sd, nu = nu, xi = xi) / sd # Log: if(log) result = log(result) # Return Value: result } # ------------------------------------------------------------------------------ psstd <- function(q, mean = 0, sd = 1, nu = 5, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Compute the distribution function of the # skewed Student-t distribution # FUNCTION: # Shift and Scale: result = .psstd(q = (q-mean)/sd, nu = nu, xi = xi) # Return Value: result } # ------------------------------------------------------------------------------ qsstd <- function(p, mean = 0, sd = 1, nu = 5, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Compute the quantile function of the # skewed Student-t distribution # FUNCTION: # Shift and Scale: result = .qsstd(p = p, nu = nu, xi = xi) * sd + mean # Return Value: result } # ------------------------------------------------------------------------------ rsstd <- function(n, mean = 0, sd = 1, nu = 5, xi = 1.5) { # A function implemented by Diethelm Wuertz # Description: # Generate random deviates from the # skewed Student-t distribution # FUNCTION: # Shift and Scale: result = .rsstd(n = n, nu = nu, xi = xi) * sd + mean # Return Value: result } ################################################################################ .dsstd <- function(x, nu, xi) { # A function implemented by Diethelm Wuertz # Description: # Internal Function # FUNCTION: # For SPlus compatibility: if (!exists("beta")) beta <- function (a, b) exp( lgamma(a) + lgamma(b) -lgamma(a+b) ) # Standardize: m1 = 2 * sqrt(nu-2) / (nu-1) / beta(1/2, nu/2) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) z = x*sigma + mu # Compute: Xi = xi^sign(z) g = 2 / (xi + 1/xi) Density = g * dstd(x = z/Xi, nu = nu) # Return Value: Density * sigma } # ------------------------------------------------------------------------------ .psstd <- function(q, nu, xi) { # A function implemented by Diethelm Wuertz ## ## fixed by GNB, see section 'CHANGES in fGarch VERSION 4021.87, 2022-08-06', subsection ## 'BUG fixes' in NEWS.Rd. # Description: # Internal Function # FUNCTION: # For SPlus compatibility: if (!exists("beta")) beta <- function (a, b) exp( lgamma(a) + lgamma(b) -lgamma(a+b) ) # Standardize: m1 = 2 * sqrt(nu-2) / (nu-1) / beta(1/2, nu/2) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) z = q*sigma + mu # Compute: sig <- ifelse(z >= 0, 1, -1) # note: 1 for z = 0; was sign(z) Xi = xi^sig # not sign(z) g = 2 / (xi + 1/xi) # was: Probability = Heaviside(z) - sign(z) * g * Xi * pstd(q = -abs(z)/Xi, nu = nu) Probability = ifelse(z >= 0, 1, 0) - sig * g * Xi * pstd(q = -abs(z)/Xi, nu = nu) # Return Value: Probability } # ------------------------------------------------------------------------------ .qsstd <- function(p, nu, xi) { # A function implemented by Diethelm Wuertz ## ## fixed by GNB, see section 'CHANGES in fGarch VERSION 4021.87, 2022-08-06', subsection ## 'BUG fixes' in NEWS.Rd. # Description: # Internal Function # FUNCTION: # For SPlus compatibility: if (!exists("beta")) beta <- function (a, b) exp( lgamma(a) + lgamma(b) -lgamma(a+b) ) # Standardize: m1 = 2 * sqrt(nu-2) / (nu-1) / beta(1/2, nu/2) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) # Compute: g = 2 / (xi + 1/xi) pxi <- p - (1 / (1 + xi^2)) # not p - 1/2 sig <- sign(pxi) # not p - 1/2 Xi = xi^sig p = (Heaviside(pxi) - sig * p) / (g * Xi) # pxi, not p - 1/2 Quantile = (-sig*qstd(p = p, sd = Xi, nu = nu) - mu ) / sigma # Return Value: Quantile } # ------------------------------------------------------------------------------ .rsstd <- function(n, nu, xi) { # A function implemented by Diethelm Wuertz # Description: # Internal Function # FUNCTION: # For SPlus compatibility: if (!exists("beta")) beta <- function (a, b) exp( lgamma(a) + lgamma(b) -lgamma(a+b) ) # Generate Random Deviates: weight = xi / (xi + 1/xi) z = runif(n, -weight, 1-weight) Xi = xi^sign(z) Random = -abs(rstd(n, nu = nu))/Xi * sign(z) # Scale: m1 = 2 * sqrt(nu-2) / (nu-1) / beta(1/2, nu/2) mu = m1*(xi-1/xi) sigma = sqrt((1-m1^2)*(xi^2+1/xi^2) + 2*m1^2 - 1) Random = (Random - mu ) / sigma # Return value: Random } ################################################################################ fGarch/R/mgarch-FitFromFormula.R0000644000176200001440000001126315104730075016130 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # .gogarchFit Fits the parameters of a GO-GARCH process ################################################################################ .gogarchFit <- function(formula = ~ garch(1, 1), data, init.rec = c("mci", "uev"), delta = 2, skew = 1, shape = 4, cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "snig", "QMLE"), include.mean = TRUE, include.delta = NULL, include.skew = NULL, include.shape = NULL, leverage = NULL, trace = TRUE, algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), hessian = c("ropt", "rcd"), control = list(), title = NULL, description = NULL, ...) { # A function implemented by Diethelm Wuertz # Description: # Fits a GO-Garch Model using Independent Component Analysis # Arguments: # The arguments are the same as for the univariate case. # formula - formula for all marginal models # data - multivariate timeSeries object # ... # Value: # S4 Object of class (univariate) fGARCH ... # Notes: # This function has still a preliminary status ... # This function was inspired from the contributed gogarch # package of Bernhard Pfaff. # Example: # require(fEcofin); data(DowJones30) # X = returns(as.timeSeries(DowJones30)); head(X) # N = 5; ans = .gogarchFit(data = X[, 1:N], trace = FALSE); ans # ans@h.t # FUNCTION: # Multivariate ? stopifnot(isMultivariate(data)) # Data: X = data # Marginal Garch Models: garchControl = list( init.rec = init.rec, delta = delta, skew = skew, shape = shape, cond.dist = cond.dist, include.mean = include.mean, include.delta = include.delta, include.skew = include.skew, include.shape = include.shape, leverage = leverage, trace = trace, algorithm = algorithm, hessian = hessian, control = control, title = title, description = description) # Compute fastICA: # ... the following lines of code were borrowed from # Bernhard Pfaff's contributed package gogarch V <- t(X) %*% X / nrow(X) svd <- svd(V) P <- svd$u Dsqr <- diag(sqrt(svd$d)) # set.seed(4711) ica <- fastICA::fastICA(X, n.comp = ncol(X)) Z <- P %*% Dsqr %*% t(P) %*% ica$W colnames(Z) = rownames(Z) = colnames(data) Y <- X %*% solve(Z) # Fit Marginal Garch Models: fit <- apply(Y, 2, function(x) do.call("garchFit", c(list(formula = formula, data = x), garchControl))) # Compute Conditional Variances: # ... the following lines of code were borrowed from # Bernhard Pfaff's contributed package gogarch H <- matrix(unlist(lapply(fit, function(x) x@h.t)), ncol = ncol(X), nrow = nrow(X)) Hdf <- data.frame(t(H)) rownames(Hdf) <- colnames(data) colnames(Hdf) <- rownames(data) H.t <- lapply(Hdf, function(x) Z %*% diag(x) %*% t(Z)) # Add Title and Description: if(is.null(title)) title = "ICA GO-GARCH Modelling" if(is.null(description)) description = description() # Result: ans <- new("fGARCH", call = as.call(match.call()), formula = formula, method = "ICA go-Garch Parmeter Estimation", data = c(Records = nrow(data), Instruments = ncol(data)), fit = fit, residuals = numeric(), fitted = numeric(), h.t = c(Records = length(H.t), Dimension =dim(H.t[[1]])), sigma.t = numeric(), title = title, description = description ) # Multivariate Series: attr(ans@data, "data") <- data attr(ans@h.t, "H.t") <- H.t # Return Value: ans } ################################################################################ fGarch/R/methods-residuals.R0000644000176200001440000000344715104730075015436 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # METHOD: EXTRACTORS: # residuals.fGARCH S4 residuals method for an object of class 'fGARCH' ################################################################################ setMethod(f = "residuals", signature(object = "fGARCH"), definition = function(object, standardize = FALSE) { # A function implemented by Diethelm Wuertz # Description: # S4 Residuals method for an object of class fGARCH # Arguments: # object - an object of class fGarch as returned by the # function garchFit # ... - optional argument to be passed, this may be standardize=FALSE # to return the -non-standardized values of the residuals. # By default standardized residuals will be returned. # FUNCTION: # Residuals: if (standardize) { ans = object@residuals/object@sigma.t } else { ans = object@residuals } # Return Value: ans }) # ------------------------------------------------------------------------------ fGarch/R/methods-formula.R0000644000176200001440000000275515104730075015111 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # formula.fGARCH Extracts 'fGarch' Model formulaficients ################################################################################ setMethod(f = "formula", signature(x = "fGARCH"), definition = function(x) { # A function implemented by Diethelm Wuertz # Description: # Extracts 'fGarch' Model formula # Arguments: # x - an object of class fGarch as returned by the function # garchFit # FUNCTION: # Numeric vector of fitted values: ans = slot(x, "formula") # Return Value: ans }) ################################################################################ fGarch/R/methods-volatility.R0000644000176200001440000000424315104730075015636 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # METHOD: EXTRACTORS: # volatility.fGARCH Returns conditional volatilities for 'fGARCH' objects ################################################################################ volatility.fGARCH <- ## better to use S3 style because volatility is defined as a S3 generic ## setMethod(f = "volatility", signature(object = "fGARCH"), definition = function(object, type = c("sigma", "h"), ...) { # A function implemented by Diethelm Wuertz # Description: # Returns conditional volatilities for 'fGARCH' objects # Arguments: # object - an object of class 'fGarch' as returned by the function # garchFit # type - a character string denoting if the conditional standard # deviations "sigma" or the variances "h" should be returned. # ... - optional argument to be passed, not used. # Note: # "volatility" is a generic function. It's default method calculates # (x-mean(x))^2. # FUNCTION: # Match Arguments: type = match.arg(type) # Numeric vectors of conditional values: if (type == "sigma") { volatility = slot(object, "sigma.t") } else if (type == "h") { volatility = slot(object, "h.t") } attr(volatility, "type") <- type # Return Value: volatility } ##) ################################################################################ fGarch/R/garch-Initialization.R0000644000176200001440000002575515104730075016061 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # .garchInitSeries Initializes Series # .garchInitParameters Initializes Parameters ################################################################################ .garchInitSeries <- function(formula.mean, formula.var, cond.dist, series, scale, init.rec, h.start, llh.start, trace) { # A function implemented by Diethelm Wuertz # Description: # Initialize time series # Arguments: # see function garchFit() # FUNCTION: # Check Mean Formula ARMA - Is it Valid ? mm = length(formula.mean) if(mm != 2) stop("Mean Formula misspecified") end = regexpr("\\(", as.character(formula.mean[mm])) - 1 model.mean = substr(as.character(formula.mean[mm]), 1, end) if(!any( c("ar", "ma", "arma") == model.mean)) stop("formula.mean must be one of: ar, ma, arma") # Check Variance Formula GARCH - Is it Valid ? mv = length(formula.var) if(mv != 2) stop("Variance Formula misspecified") end = regexpr("\\(", as.character(formula.var[mv])) - 1 model.var = substr(as.character(formula.var[mv]), 1, end) if(!any( c("garch", "aparch") == model.var)) stop("formula.var must be one of: garch, aparch") # Determine Mean Order from ARMA Formula: model.order = as.numeric(strsplit(strsplit(strsplit(as.character( formula.mean), "\\(")[[2]][2], "\\)")[[1]], ",")[[1]]) u = model.order[1] v = 0 if(length(model.order) == 2) v = model.order[2] maxuv = max(u, v) if(u < 0 | v < 0) stop("*** ARMA orders must be positive.") # Determine Variance Order from GARCH Formula: model.order = as.numeric(strsplit(strsplit(strsplit(as.character( formula.var), "\\(")[[2]][2], "\\)")[[1]], ",")[[1]]) p = model.order[1] q = 0 if(length(model.order) == 2) q = model.order[2] if(p+q == 0) stop("Misspecified GARCH Model: Both Orders are zero!") maxpq = max(p, q) if(p < 0 | q < 0) stop("*** GARCH orders must be positive.") # Fix Start Position of Series "h" and for Likelihood Calculation: max.order = max(maxuv, maxpq) if(is.null(h.start)) h.start = max.order + 1 if(is.null(llh.start)) llh.start = 1 # Check for Recursion Initialization: if(init.rec != "mci" & model.var != "garch") { stop("Algorithm only supported for mci Recursion") } # Trace the Result: if(trace) { cat("\nSeries Initialization:") cat("\n ARMA Model: ", model.mean) cat("\n Formula Mean: ", as.character(formula.mean)) cat("\n GARCH Model: ", model.var) cat("\n Formula Variance: ", as.character(formula.var)) cat("\n ARMA Order: ", u, v) cat("\n Max ARMA Order: ", maxuv) cat("\n GARCH Order: ", p, q) cat("\n Max GARCH Order: ", maxpq) cat("\n Maximum Order: ", max.order) cat("\n Conditional Dist: ", cond.dist) cat("\n h.start: ", h.start) cat("\n llh.start: ", llh.start) cat("\n Length of Series: ", length(series)) cat("\n Recursion Init: ", init.rec) cat("\n Series Scale: ", scale) cat("\n\n") } # Result: ans = list( model = c(model.mean, model.var), order = c(u = u, v = v, p = p, q = q), max.order = max.order, z = rep(0, times = length(series)), h = rep(var(series), times = length(series)), x = series, scale = scale, init.rec = init.rec, h.start = h.start, llh.start = llh.start) # Return Value: ans } # ------------------------------------------------------------------------------ .garchInitParameters <- function(formula.mean, formula.var, delta, skew, shape, cond.dist, include.mean, include.delta, include.skew, include.shape, leverage, algorithm, control, trace) { # A function implemented by Diethelm Wuertz # Description: # Initialize model parameters # Arguments: # see function garchFit() # FUNCTION: # DEBUG: .DEBUG = FALSE # global variables .series <- .getfGarchEnv(".series") # Determine Mean Order from ARMA Formula: model.order = as.numeric(strsplit(strsplit(strsplit(as.character( formula.mean), "\\(")[[2]][2], "\\)")[[1]], ",")[[1]]) u = model.order[1] v = 0 if(length(model.order) == 2) v = model.order[2] # Determine Variance Order from GARCH Formula: model.order = as.numeric(strsplit(strsplit(strsplit(as.character( formula.var), "\\(")[[2]][2], "\\)")[[1]], ",")[[1]]) p = model.order[1] if (p == 0) stop("The order p must be > 0 in GARCH/APARCH(p,q)") q = 0 if(length(model.order) == 2) q = model.order[2] # Includes: model.var = .series$model[2] if(is.null(include.delta)) { if(model.var == "garch") { include.delta = FALSE } else { include.delta = TRUE } } if(is.null(leverage)) { if(model.var == "garch") { leverage = FALSE } else { leverage = TRUE } } # Distributional Includes: if(cond.dist == "t") cond.dist = "std" skewed.dists = c("snorm", "sged", "sstd", "snig") if(is.null(include.skew)) { if(any(skewed.dists == cond.dist)) { include.skew = TRUE } else { include.skew = FALSE } } shaped.dists = c("ged", "sged", "std", "sstd", "snig") if(is.null(include.shape)) { if(any(shaped.dists == cond.dist)) { include.shape = TRUE } else { include.shape = FALSE } } # Set Names for Parameters: Names = c( "mu", if(u > 0) paste("ar", 1:u, sep = ""), if(v > 0) paste("ma", 1:v, sep = ""), "omega", if(p > 0) paste("alpha", 1:p, sep = ""), if(p > 0) paste("gamma", 1:p, sep = ""), if(q > 0) paste("beta", 1:q, sep = ""), "delta", "skew", "shape") if(.DEBUG) { cat("\nDEBUG - Names: \n"); print(Names) } # Initialize Model Parameters to be Estimated: fit.mean = arima(.series$x, order = c(u, 0, v), include.mean = include.mean)$coef alpha.start = 0.1 beta.start = 0.8 ## if(include.delta) delta = 1.5 params = c( if(include.mean) fit.mean[length(fit.mean)] else 0, if(u > 0) fit.mean[1:u], if(v > 0) fit.mean[(u+1):(length(fit.mean)-as.integer(include.mean))], var(.series$x, na.rm = TRUE)*(1-alpha.start-beta.start), if(p > 0) rep(alpha.start/p, times = p), if(p > 0) rep(0.1, times = p), if(q > 0) rep(beta.start/q, times = q), delta, skew, shape) names(params) = Names if(.DEBUG) { cat("\nDEBUG - params: \n"); print(params) } # Set Lower Limits of Parameters to be Estimated: TINY = 1.0e-8 USKEW = 1/10; USHAPE = 1 if (cond.dist == "snig") USKEW = -0.99 U = c( -10*abs(mean(.series$x)), if(u > 0) rep(-1+TINY, times = u), if(v > 0) rep(-1+TINY, times = v), 1.0e-6*var(.series$x), if(p > 0) rep( 0+TINY, times = p), if(p > 0) rep(-1+TINY, times = p), if(q > 0) rep( 0+TINY, times = q), 0, # delta USKEW, # skew USHAPE) # shape names(U) = Names if(.DEBUG) { cat("\nDEBUG - U: \n"); print(U) } # Set Upper Limits of Parameters to be Estimated: VSKEW = 10; VSHAPE = 10 if (cond.dist == "snig") VSKEW = 0.99 V = c( 10*abs(mean(.series$x)), if(u > 0) rep(1-TINY, times = u), if(v > 0) rep(1-TINY, times = v), 100*var(.series$x), if(p > 0) rep(1-TINY, times = p), if(p > 0) rep(1-TINY, times = p), if(q > 0) rep(1-TINY, times = q), 2, # delta VSKEW, # skew VSHAPE) # shape names(V) = Names if(.DEBUG) { cat("\nDEBUG - V: \n"); print(V) } # Includes: includes = c( include.mean, if(u > 0) rep(TRUE, times = u), if(v > 0) rep(TRUE, times = v), TRUE, if(p > 0) rep(TRUE, times = p), if(p > 0) rep(leverage, times = p), if(q > 0) rep(TRUE, times = q), include.delta, include.skew, include.shape) names(includes) = Names if(.DEBUG) { cat("\nDEBUG - V: \n"); print(includes) } # Index List of Parameters to be Optimized: index = (1:length(params))[includes == TRUE] names(index) = names(params)[includes == TRUE] if(.DEBUG) { cat("\nDEBUG - fixed: \n"); print(index) } # Persistence: alpha <- beta <- NULL if(p > 0) alpha = params[substr(Names, 1, 5) == "alpha"] if(p > 0 & leverage) gamma = params[substr(Names, 1, 5) == "gamma"] if(p > 0 & !leverage) gamma = rep(0, times = p) if(q > 0) beta = params[substr(Names, 1, 4) == "beta"] if(.series$model[2] == "garch") { persistence = sum(alpha) + sum(beta) } else if(.series$model[2] == "aparch") { persistence = sum(beta) for (i in 1:p) persistence = persistence + alpha[i]*garchKappa(cond.dist, gamma[i], params["delta"], params["skew"], params["shape"]) } names(persistence) = "persistence" # Trace the Result: if(trace) { cat("Parameter Initialization:") cat("\n Initial Parameters: $params") cat("\n Limits of Transformations: $U, $V") cat("\n Which Parameters are Fixed? $includes") cat("\n Parameter Matrix:\n") ans = data.frame(U, V, params, includes) rownames(ans) = paste(" ", names(params)) print(ans) cat(" Index List of Parameters to be Optimized:\n") print(index) cat(" Persistence: ", persistence, "\n") } # Return Value: list(params = params, U = U, V = V, includes = includes, index = index, mu = params[1], delta = delta, skew = skew, shape = shape, cond.dist = cond.dist, leverage = leverage, persistence = persistence, control = control) } ################################################################################ fGarch/R/class-fGARCHSPEC.R0000644000176200001440000000242215104730075014542 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: SPECIFICATION: # fGARCHSPEC S4 fGARCHSPEC Class representation ################################################################################ setClass("fGARCHSPEC", representation( call = "call", formula = "formula", model = "list", presample = "matrix", distribution = "character", rseed = "numeric") ) ################################################################################ fGarch/R/dist-std.R0000644000176200001440000000604715104730075013534 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # dstd Density for the Student-t Distribution # pstd Probability function for the Student-t Distribution # qstd Quantile function for the Student-t Distribution # rstd Random Number Generator for the Student-t ################################################################################ dstd <- function(x, mean = 0, sd = 1, nu = 5, log = FALSE) { # A function implemented by Diethelm Wuertz # Description: # Compute the density for the # Student-t distribution. # FUNCTION: # Params: if (length(mean) == 3) { nu = mean[3] sd = mean[2] mean = mean[1] } # Compute Density: s = sqrt(nu/(nu-2)) z = (x - mean) / sd result = dt(x = z*s, df = nu) * s / sd # Log: if(log) result = log(result) # Return Value: result } # ------------------------------------------------------------------------------ pstd <- function (q, mean = 0, sd = 1, nu = 5) { # A function implemented by Diethelm Wuertz # Description: # Compute the probability for the # Student-t distribution. # FUNCTION: # Compute Probability: s = sqrt(nu/(nu-2)) z = (q - mean) / sd result = pt(q = z*s, df = nu) # Return Value: result } # ------------------------------------------------------------------------------ qstd <- function (p, mean = 0, sd = 1, nu = 5) { # A function implemented by Diethelm Wuertz # Description: # Compute the quantiles for the # Student-t distribution. # FUNCTION: # Compute Quantiles: s = sqrt(nu/(nu-2)) result = qt(p = p, df = nu) * sd / s + mean # Return Value: result } # ------------------------------------------------------------------------------ rstd <- function(n, mean = 0, sd = 1, nu = 5) { # A function implemented by Diethelm Wuertz # Description: # Generate random deviates from the # Student-t distribution. # FUNCTION: # Generate Random Deviates: s = sqrt(nu/(nu-2)) result = rt(n = n, df = nu) * sd / s + mean # Return Value: result } ################################################################################ fGarch/R/fGarch-package.R0000644000176200001440000000144315104730075014557 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ fGarch/R/garch-Gradient.R0000644000176200001440000000602015104730075014607 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # .garchRCDAGradient Computes R coded CDA matrix of contributions # to the Gradient ################################################################################ .garchRCDAGradient <- function(par, .params, .series, eps = 1.0e-4) { # A function implemented by Michal Miklovic & Yohan Chalabi # Description: # Compute R coded CDA (central difference approximated) Gradient # Reference: # http://status.sph.umich.edu/computing/manuals/sas8/stat/chap46/sect26.htm # FUNCTION: # Starttime .StartGradient <- Sys.time() # Algorithm algorithm = .params$control$algorithm[1] .trace = FALSE # LLH for the computation of matrix of contributions to the Gradient skew <- .params$skew shape <- .params$shape delta <- .params$delta deltainv = 1/delta llh.start = .series$llh.start N <- length(.series$x) .garchDist <- .getfGarchEnv(".garchDist") # Compute matrix of contributions to the Gradient: eps = eps * par n = N - llh.start + 1 K = length(par) G = matrix(0, nrow = n, ncol = K) for (i in 1:K) { x1 = x2 = par x1[i] = x1[i] + eps[i] x2[i] = x2[i] - eps[i] # .garchLLH(x1, .trace, TRUE) h1 <- .getfGarchEnv(".series")$h z1 <- .getfGarchEnv(".series")$z hh1 = (abs(h1[(llh.start):N]))^deltainv zz1 = z1[(llh.start):N] llh.grad1 <- log(.garchDist(z = zz1, hh = hh1, skew = skew, shape = shape)) # .garchLLH(x2, .trace, TRUE) h2 <- .getfGarchEnv(".series")$h z2 <- .getfGarchEnv(".series")$z hh2 = (abs(h2[(llh.start):N]))^deltainv zz2 = z2[(llh.start):N] llh.grad2 <- log(.garchDist(z = zz2, hh = hh2, skew = skew, shape = shape)) # G[,i] = (llh.grad1 - llh.grad2) / (2*eps[i]) } rownames(G) = c(1:n) colnames(G) = names(par) # make sure that h and z are ok .setfGarchEnv(.series = .series) time = Sys.time() - .StartGradient # Attribute Exdecution time attr(G, "time") = time # Return Value: G } ################################################################################ fGarch/R/methods-summary.R0000644000176200001440000002044015104730075015130 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA ################################################################################ # FUNCTION: DESCRIPTION: # summary Summary method for an object of class 'fGARCH' ################################################################################ .fGARCH_summary_body_orig <- function(object) { ## A function implemented by Diethelm Wuertz ## modified by GNB: replaced [] indices with [[]] indices. ## ## With the [] indices the extracted elements remain lists, resulting in ## a matrix with list elements. The only change in the printed output ## though is that while formerly the numbers were aligned on the left, ## now they are aligned as numbers (on the decimal point). # Description: # Summary method for an object of class "fGARCH" # Arguments: # object - an object of class 'fGARCH' # FUNCTION: # same output as show method show(object) # Lagged Series: .tslagGarch = function (x, k = 1) { ans = NULL for (i in k) ans = cbind(ans, .tslag1Garch(x, i)) indexes = (1:length(ans[, 1]))[!is.na(apply(ans, 1, sum))] ans = ans[indexes, ] if (length(k) == 1) ans = as.vector(ans) ans } .tslag1Garch = function (x, k) { c(rep(NA, times = k), x[1:(length(x) - k)]) } # Statistical Tests: cat("\nStandardised Residuals Tests:\n") r.s = object@residuals/object@sigma.t ans = NULL # Normality Tests: jbtest = jarqueberaTest(r.s)@test ans = rbind(ans, c(jbtest[[1]], jbtest[[2]])) if (length(r.s) < 5000) { swtest = shapiro.test(r.s) if (swtest[[2]] < 2.6e-16) swtest[[2]] = 0 ans = rbind(ans, c(swtest[[1]], swtest[[2]])) } else { ans = rbind(ans, c(NA, NA)) } # Ljung-Box Tests: box10 = Box.test(r.s, lag = 10, type = "Ljung-Box") box15 = Box.test(r.s, lag = 15, type = "Ljung-Box") box20 = Box.test(r.s, lag = 20, type = "Ljung-Box") ans = rbind(ans, c(box10[[1]], box10[[3]])) ans = rbind(ans, c(box15[[1]], box15[[3]])) ans = rbind(ans, c(box20[[1]], box20[[3]])) box10 = Box.test(r.s^2, lag = 10, type = "Ljung-Box") box15 = Box.test(r.s^2, lag = 15, type = "Ljung-Box") box20 = Box.test(r.s^2, lag = 20, type = "Ljung-Box") ans = rbind(ans, c(box10[[1]], box10[[3]])) ans = rbind(ans, c(box15[[1]], box15[[3]])) ans = rbind(ans, c(box20[[1]], box20[[3]])) # Ljung-Box Tests - tslag required lag.n = 12 x.s = as.matrix(r.s)^2 n = nrow(x.s) tmp.x = .tslagGarch(x.s[, 1], 1:lag.n) tmp.y = x.s[(lag.n + 1):n, 1] fit = lm(tmp.y ~ tmp.x) stat = (n-lag.n) * summary.lm(fit)$r.squared ans = rbind(ans, c(stat, p.value = 1 - pchisq(stat, lag.n)) ) # Add Names: rownames(ans) = c( " Jarque-Bera Test R Chi^2 ", " Shapiro-Wilk Test R W ", " Ljung-Box Test R Q(10) ", " Ljung-Box Test R Q(15) ", " Ljung-Box Test R Q(20) ", " Ljung-Box Test R^2 Q(10) ", " Ljung-Box Test R^2 Q(15) ", " Ljung-Box Test R^2 Q(20) ", " LM Arch Test R TR^2 ") colnames(ans) = c("Statistic", "p-Value") print(ans) # Information Criterion Statistics: cat("\nInformation Criterion Statistics:\n") print(object@fit$ics) # Return Value: cat("\n") invisible() } .lm_arch_test <- function(r.s) { ## Lagged Series: .tslagGarch <- function (x, k = 1) { ans <- NULL for (i in k) ans <- cbind(ans, .tslag1Garch(x, i)) indexes <- (1:length(ans[, 1]))[!is.na(apply(ans, 1, sum))] ans <- ans[indexes, ] if (length(k) == 1) ans <- as.vector(ans) ans } .tslag1Garch <- function (x, k) c(rep(NA, times = k), x[1:(length(x) - k)]) ## LM Arch test - tslag required lag.n <- 12 x.s <- as.matrix(r.s)^2 n <- nrow(x.s) tmp.x <- .tslagGarch(x.s[, 1], 1:lag.n) tmp.y <- x.s[(lag.n + 1):n, 1] fit <- lm(tmp.y ~ tmp.x) stat <- (n-lag.n) * summary.lm(fit)$r.squared c(stat, p.value = 1 - pchisq(stat, lag.n)) } .fGARCH_show_stat_test <- function(object) { r.s <- object@residuals/object@sigma.t ans <- NULL ## Normality Tests: jbtest <- jarqueberaTest(r.s)@test ans <- rbind(ans, c(jbtest[[1]], jbtest[[2]])) if (length(r.s) < 5000) { swtest <- shapiro.test(r.s) if (swtest[[2]] < 2.6e-16) swtest[[2]] = 0 ans <- rbind(ans, c(swtest[[1]], swtest[[2]])) } else { ans <- rbind(ans, c(NA, NA)) } ## Ljung-Box Tests: ## residuals box10 <- Box.test(r.s, lag = 10, type = "Ljung-Box") box15 <- Box.test(r.s, lag = 15, type = "Ljung-Box") box20 <- Box.test(r.s, lag = 20, type = "Ljung-Box") ans <- rbind(ans, c(box10[[1]], box10[[3]])) ans <- rbind(ans, c(box15[[1]], box15[[3]])) ans <- rbind(ans, c(box20[[1]], box20[[3]])) ## squared residuals box10 <- Box.test(r.s^2, lag = 10, type = "Ljung-Box") box15 <- Box.test(r.s^2, lag = 15, type = "Ljung-Box") box20 <- Box.test(r.s^2, lag = 20, type = "Ljung-Box") ans <- rbind(ans, c(box10[[1]], box10[[3]])) ans <- rbind(ans, c(box15[[1]], box15[[3]])) ans <- rbind(ans, c(box20[[1]], box20[[3]])) ## LM Arch test - tslag required archtest <- .lm_arch_test(r.s) ans <- rbind(ans, archtest) ## Add Names: rownames(ans) <- c( " Jarque-Bera Test R Chi^2 ", " Shapiro-Wilk Test R W ", " Ljung-Box Test R Q(10) ", " Ljung-Box Test R Q(15) ", " Ljung-Box Test R Q(20) ", " Ljung-Box Test R^2 Q(10) ", " Ljung-Box Test R^2 Q(15) ", " Ljung-Box Test R^2 Q(20) ", " LM Arch Test R TR^2 ") colnames(ans) <- c("Statistic", "p-Value") ans } summary.fGARCH <- function(object) { res <- list( show = .prepare_GARCH_show(object), stat_tests = .fGARCH_show_stat_test(object), ics = object@fit$ics ) class(res) <- "summary_fGARCH" res } print.summary_fGARCH <- function(x, ..., classic = FALSE) { # cat(x$show, sep = "\n") .show_orig_body(x$show, prepare = FALSE) cat("\n") cat("\nStandardised Residuals Tests:\n") if(classic) print(x$stat_tests[1:9, ]) # cat() doesn't work, it's an odd matrix else ## TODO: at least put tests for the fitted distribution, ## rather than always giving the normality tests; ## see the qq-plot function .plot.garch.13 for a way to extract ## cond. dist. package 'goftest' seems suitable ## ## for now, same as for classic = TRUE print(x$stat_tests) cat("\nInformation Criterion Statistics:\n") print(x$ics) cat("\n") invisible(x) } setMethod(f = "summary", signature(object = "fGARCH"), function(object, ...) { ## original code by by Diethelm Wuertz, ## see .fGARCH_summary_body_orig() ## completely refactored and modified by Georgi Boshnakov (GNB) res <- summary.fGARCH(object, ...) ## For compatibility, show the old summary when computing the ## object Note that the print method has 'classic = FALSE' ## default, so if the object is assigned and then printed, the ## result will be with the new default. print(res, classic = TRUE) invisible(res) }) ################################################################################ fGarch/data/0000755000176200001440000000000015116751403012360 5ustar liggesusersfGarch/data/dem2gbp.csv.gz0000644000176200001440000002762515116751403015050 0ustar liggesusers‹uKŽ$AŒ\÷sо@ üÿÙ ´ ûŸFfôa:øº½è@fz¸ÓI#i$ÿçÿú?íÿÿûâ¯ügm³÷vÖŸÿúûߥ³G['?Y}¬ºwû<Ñ£ÖÖ®·}ŸüèIÕw­;á3ú¥Ù×ÎOêêe—ò}¢Œ1·~©æßé­”¡¥ço›eÔYk‡µõ¾ÏZŸUëA¹§ÔÝwÍOÎðâ:ìNëŒRáÛúåÖyó“UJ½{Á)Ìs†V=òªõ*§îñÝ}FSO[>sÆg~W{P—¾žx׎6œVP–F¿3ÏnçÂ^ëËô$É›Wp$#'í¨Ÿ´r%pŸÏü„ŒÞ{梵­5wiß}³T±g/7f è=¸ê~|¬ùÛúžõ’Þ6Ç^£ÏGOnÙ»×üm?õ?»d·¸%óŽ»GIOô™Rô‰·qì=ô[ðm]bµç"©ÚU+èß÷ñ)¬v‡^ŠV°ÆœiÕþ¶v$Wß“ó“]}QÒ·éÉѽÚã>8­Ï}I»èx´ pë%í³œöù6ËN½ºW÷{·CN]ï +¸m÷5áI¯¥ÕS@Bælþ·Þ–$'I¯G_²ãµ•® J§ío[e®†šb©ª§Ð­Dk-ð>wHHSèb-­áï-–ÂÖ¥ájå1êèÉ–ø–\m¡½nëêÖµrØŸÚtvôõ>Òt¢.ãí ßt4«Ñ‘¿­ÕîD;*s!)ÈZl}ì»×>SÝ·[;iÝÑu’eŠÏœrõVð¤.éñ O¶ìß8_ö§ª[VæJïõ[á´-’DØ·& "Åó•ëø)e1àI]E7¸Â ´e]¸Þç^iù•dçÇ:Qj¯OØ7É›4Ü-&¹‘„|­Ù“iÅE°í%{Ÿô¨qÈÍö@›}ê$¼3u…×äÐÊè»ÐªÏ‘N¾4¬^tΞn}œöºú§äϬ=dÏ*­­Þ2ï÷M½;³X¬à¬[GÒ‰¾õGF«$;g©ºKƱ‘æ»2sç€ì´}¥G“$Zè*´EXLÊ¥ÙýýÄÊJêM*á{>qƒ…açLZÌ+ûtx¢#0\ÎOd1…"hÿV–ÐI|5x*„:%RÒVó»>…&˜8’¦\Õõÿé´cgè~¿-0’ÔA¶sÞë&°6üNmºÛ3!¡ÐoúÐ"»]eL¥ªÀbÌQ¼×´j­kIóä'Úœ.‰[2o•ð$ÌHhëæ“†Õ†nÙ@Ò×2rk‘-¹ÍZ>ießýŠüÒUIƒ„)F—"OÈ;|&™’sè3ºÂ{÷-´ÿÃë†÷Ñi˪£­—±I®§hÕ$½q¦ºõ'éÃHSvžÔ^{Égc[äànwÚ+¦ LÞ¤vŽÐ`ëB/›|¦.áJ"l)£µ²¼ùÛ„4ŠÔoþ6™Eð5Ÿ¶ÔºoBÏÏêù}âM¥‘gûz,qÚåN¹èà;O{Y²µùwnÑí9ä}T]ùŽ{ /XÆ6ýNÜSãTº²§R ô›^Sx+íNèÄ;ÏMþODdèÑfùxtFd´ù‡de¦Lpí U²?ƪ°;[Ò÷$¯­öYdÎJþŒ¤PBJwN—Êñº§²š-Ûz{`M7¡$ øç|3©Þ/óæh]SÐ’Êð Áï5È£¼Ó¤BŒ>O|礔k% èoú‡\wÝ’žõ›}M™Úñ¨ßTïs‹û³·\Ç¿w'ö`émóªÛžMb5Òr]Ó›†Ï´¯Ü6x"9yøŒ,}m¨‘té®Ü‚üD~}×ÅÙÙ~5Â|R,Kz$Ù¹ŸÉ)yâC ö&o*ÞGú²QdAß$›AÚE^š'¡ë¢Û]?º7ÎgJê]?oxtI[WŒyÙ£E_×>+x¿#¡’ !û#õ&ƒ´Øñ9tÈ6gG2¾Æ(¨|9Aòø«ý•Œ{ŸTÉÙ#¯ºÊš ü}ÚïÖGì4ùÛá¹^aoò»üSýì›ô«´%á*Y¦SfŽâXWiqã+ÏfId «)ÕÒÑ–•FVsÉ5ìä›I åñoV<‘X/°oS ä&|¸J0d&¿1dTÖ§'[âÝÒ"gÂÝ^mKH;yÕ²²’ø6I»6"´] âÞïòÁuÒHX„uáKƒR-ùÈ„jÚYB¸pìSëàJ^ÁÙ‚ø9JíóYrÚzŠ9D„I>]£×eî9Jï#E~)†bì^ŒWI»ÊÒ~W8±Ûg‚µÕc\S(þ&$·žbò@k²?¿1bÇêaßäP E£¿½¤+*eldÉš¤‡V=„inÂþ#Ž D~‰4¢„¬æ,‚ד¢8£wéµîÉzº·Ø- ©ºˆ)´1ÇpöM—Án[~"ýá é·}„("#ŸvH(š·d~yF:y»”EK=´6²šÇé,òO·C±s,mЇònŠ=…E·g”Pt`X¡ÁAqK‡P-WIܵDÄóHÁ‘¾–Žw¬‘Ðz1jhG…ØFè*yS;i¾89=ØiÕqëçu .fJ<6Æ:›\׎÷tLŸå³dš  Þ.s‘ò!!gëY:ŸðŒ–|©Ypöòx Ù_ˆx|³ƒ'ò}NIZìɵ4EBøŽ‡HÁUÀñBëöó:ÅT{öÇX€Àº=’DçàìÜÓªkæ£øŽDQW n–6§9ýo:ÙÝ$ñûz¿é"–óE\uJ¦JŠN>]m‘X·8†ž§JëøÚÿޤCp‘÷p8œä@ÛyÖ¢»=ëKqŠX›îÔ”U ÏHCÖ|Öþú&]ÎZyK ïH•ënÁÚ†~®¯Í û3egg~ÙÓ+ÉÉQ‚¸?Bø9¯iéíÞ̈Œ+ÙEw[òFˆkvé–‘4…w§ÚE'm)!”ÕNw;l½`üN±õнGðòõU«„Áˆµ:Ø29[’ÿºJJ´“ìÈ‘ºR0蛕9r\,üm­®RŬM»#TÓ*ùV‰]/”?#sAø-b\c9t Ÿqic¼Jޏ\ °2ËNSÿF¿ÂnK[ÛÍßæÛ(ÈN8DCpùñx]BvÕÐ…â|ÃùÛ$½!æÕàûèe´s”/Yç,ÝßOÂÓ“K[’_ÿÎôN!O¼Û¾ ä!7Dê7êaÍ×·½gZ›d€7v Ž!ÞÞ“\~çi$‡=(î"ojÈ—¸vtܘýßUJÖÖœt®÷©é|¬«–TÒZÿð$dO(«(u°ŸÂ''-¡"YlèUI‡Üsõ„¼Ã®*”sàiíKñóÕ:ßz©ñûÎ@YZÝ`i*ÂUíV‰1-†…í¦ן—•—ò#+#¯uîŒjôd‡9¥¨® ­±Cþ‰ræ´Köt >éb9ÛÆ™XT²€ë6Š÷ÚuŸ“NAöO`•V`¶‰,E=äÊ· î3Ð mCÞnŠW?DÒØ0êqÍ  ¨a•´Ì] /u€,*)‰Ýþ‘Ÿó+aät«ûH–i ‰e´÷gšGçÓG¹…2PS¾™´jÍK,cûüù‰Ž´9è »së_3ä@ç#¿#à¯ÃK·DºªÙ3Šq™¢›Jžk_ÅŠ'¯@Gãf"÷Z‡PÍ(S€â†A²?”Û•ª¸Ù“ˆ¨”´Ù§ÕݶJ*Ȧ»ö¥ˆ;9dµ6( ')X˜; 9í|ß'ò ºò²Ï„¯¥Êý) 1Ì|Š?Aþó3W.CŠ‚'Îf•HR¥7-)ßøó¢­Z6²&œb"Ÿ4EØ'Ôˆ5!í*óC¿3p>¨ùtMW¾õ!;º#)Þûî° Æ¼ Tå¼R”àQnHâåXö×A›-õ¹ÛÙ^ÃŽ#ìÁ’‹~rt?âHÂU'±ÂšŒ,ƒ=‹„„¸ò\oG_¦X)¦LÊŸ°Á„oJÛ9/c ;œV$´>tp:ÕϪ_Ü_Á—o*MÎQw9+N&7æ,)N;êo£»m¶åeNÉh33¢BB“š”ê«;éJvÁ ¼EÈ{ÛÖoäAáe‹x•@Ÿœ ºsBÕ}·d }ÛJFÏ?+ØÏµ&>ßï –ê!M¾LMg‹îÀvKqòŸ‡æ%ϵ_sçÓmü1“yF8"ïN¤½5éÛ‚å¶êÉHõÝGÃI‡ ÁEn¸¤pvŒ»nèÞ“V6æD¾Ü*EÃw›zSŠ­ V:EGñ7g¦+…xeë(“bÆgûæ>^lC7µ&Ö^H|äC‹®ÿ/Y¨N !ÏN‡}OɨF2:ûÑ¢Û(+|s4¼‚jÆÀw?pˆ4GóŒ¬G³§÷§¹Èf¥:–ÿò>ÌÎÎoº¢´}ç.`52×]ß¶ÌïBâ{u2/Ú¼ ÙçAÜ"m€.>VÉ—’µ¥Ûت”â'Bþ©óÑ3WjøþHÜ/æ\Í”¤¹©»fæAÆû\ˆFüê‰6ÙŸàCá ÖÝî#quÿm,´²€º\x…­OCfÏ}ÊŸ1eAê§™Ú#éõuÖ¸;òÏ{²´¿>“I¤ÉefwöümM7¡knÉîÌ2êØ­ SŽ„—sÌ*ù‰¼P­,KˆíÏ]ùñÓžYÆäo6é »Ú3C.h3%8Ÿœ¿MdŸ%“ÙGf|ÆgL|"ÏÕ5wŠÐîbŠÈøÛ"\Å5rÞ/1ãtå3Kåe]Š®Øg’;w2F²ÞiN¥Ó¾™z“¼Yû²¶tœÏïšk­¼jà ԽSZ§¤íCiB¤˜oœ¶197™â¼"|F·^:b(’›ëº˜ï·ù–èÚªŽ’q.k\}Ts>+òšºÚ²}céºÁ³umNfUÚã—žÀˆL?mÝR5„+i²FŠ,lSâÌýú§ÞjÊÜõ)‘OÖÙXL€ë̯}º·®'·^253GÓ»c’í¨Ãñ&}æ7•QØ ëÍ–Ùã»×±¶fžÙS³ÆKÇ ®°  'È›•NÁ¨‡ÜV×w€Ä¨ú2À šÄ01CB¤§.¢i^yÕ´oQÆ‚U>B|ºÝ´£ÝEw‡DTJà­P¾ÞqÎUWoZÃ\õÙ.¤o AÀ K™¹õ/.› ì7Bñx+kÌV4W¦.òÛ ¼ªع~ûO|æJõRmŸËÀVÒUQï|º%‹®×9È<2€Dm)÷YT«;Ö‰ö4W‘¾^ªRÖ×.†T,ñ„š 6¿·1îœÜ©–ã£Æú_ÝmBÞ¥›qƒQÃ-‹•tUÄC\j•lý¯ù´ÿü2Év¾õÞ‰AfM¾®zFåH—k)+"OÜ…m •go –óS'žötX9ñ‘þ®àPäGÊRŠ”|¦átòêÒ¢™¡"@ÜS5ÑÏ«v¶râvhs5«¥WhtyÑïf9tšê¦Ú´åèWDó¶‹%aεc„¼Î%ˆ’+”_C š2žW¸åôÌi´ÄËǨ)N§ÝWEnž„£˜©š?# v\}™?ã0Ÿë_àÉv#ŽœI‰®S‹F4¨Kz‰ir³—ù,ÀBѯk&LöebG‰²È´èN°ƒ¶\«¹Œž´e³§I«vçŠúå8í®î ©²ëq ‡4W7Bi:Qcå¿çE[ïtAY³^Þ-ùÛš ¬5YÚWI38+"”(]EU³‚ð§LŠ_Kv«Ì6¬À<”™#Û!2õ#ùfêèÙkó™úÎå ¾ðO­¯3³Ç:Þ±cÒUÇu4¹*&4y5·ˆ¼w¡·š{鄎כ^¬´•žêõz7ÂGI<»d>¬Ïçnöu†¶ì: ü>‘M’c”ª–žk§çÝ »íÐ-wÙ‘ˆ¬%°Þ©Zqh—ËS&2¤j›ÑøÝѧaµÕ)JýjyÜ—‡°ÿmª’'a’Ûiȼš2Ú‹<£‚ÜÛäEN]O‹Læ=Oî»ò'¢»!×}™9X0lQL†â3r=n®&zñk)Ó›Ãxª_pd²cí¿ÙÂ;W¼9»¬]ãü ù%këQÿj—à™èÞˆµ·\Œ‘«Éu 2Ý Uö޵˜ ¿)o&,¦›ò½ !‰’WÌäH‚¿öç'ªoä”äÎVaƒu};á·ãÓÉÑ¢È3'æé}|؃º)¸µ—ql^[_gì[中i¾ëÎ"ýr&wÜ€U; ƒÕÆ&à n ç*ß9ÇýŸuž]ˤ¿\óö`o´%f‚.ĉSV³äZ߈8›¼BÝ!Ž3”ˆötÑVÀJ#šPÍo:Ú7:(Àzô`ÖwÔ•YÉqf‘ÚA2F›¹Â%˜#‚׉±[×WBžÉûæ6E‹¤aÝQŽ"?v7ÅÒÌ·iÕ•·²6Ö£W“ Ñwžîₜ`‰€}3:¹æZìÿ&@qwºëlá‚åo3 ßP>#:RåpèãÎl¥^ýþ£ Å2 ²“¸¬(²„„ÄcŠ÷J ¤èM -‘…h¼ÆÈ\•y&L®‘ZÄxÈ2Ó›™Ù‘øE ëŠêûÕvtÙ¡,œ §˜o.Ûj —z•F@?KzJň]æQÙ‡Ÿ¨Ž’ÝÄo“O?SåãÏo­oß)¢ùë/´ÄÁxŸ±HçkÒßàRoÇJy îÇø}S[q'*®:—ç\R´ÕwÁHùëM)Š‚5]2Û%k>¯ÍôƒöEªÁrp2e½C°Yn¦ säSùXû2NŽ4>”¶K®|ŒŽFî‚Ä·^§&—*O¬É3æ «)?ï[d ÌŠ"nžã3w̉|°ŒÉ Åa`¿+ì[ßþBZÁ*î̆œ9ù?—jI“)¹º=´Ë†\ð¤N©ë¯®ò›Îíä;å뇯fû¤ôúÂÞtר¿P„ɤ“çói «*êþéj¢Œ¯#ÿ#<¿üø¸Ûîú•üŸ‡—>‚ѼëZ_Š_o7¥™ðŽê„(îâ!…¢­–œ–ëBâK>EÌ$Ÿ-÷ô »íF«'e "º2Bæò‹ÁœéwÂwvæŽ:©U¡h‰wœŸŸi}A;lc`eÐ|c;’†‘…9¦ýýäEN­ýQÞ„¸ZöÑÃsý·èåô ³âÏë= _o¹ZÄ9íîj¸ˆOîJž‚=r¥ž¢Üûq‹PƒPÚ7rúóºP¬™ëÃo”v„¯G?aìáwÜ`s`Í&pQýO–ÜOHNå¥^UV»- jD$ ÖeXÄrÓ~vîÏg¶ýN̸‘ÙËeðdN‡qÉ0tìX ‡©tŠ­ëÆËd`籨m§î*n`¼&vm8æKSíKŸî°Fýä|u»MðD*öfä»?G~#sW–Õµ |1EØ)庨Éugìƒ} ÝÔ)g¿õ^r‡™À–®õ"ßY¢™ŒümÎa—Ìâ ý¹wXµ3ß{à鉷š»)4sQþ~#:D}õA쨀¼n0ÝmWboª–œŽîgvzDÐú°†Ùþ.ëÊ+03¢eÝv»O›º¼‚jNKÆ?AŸ-û2±;F£ÔÙÊ&³¥È\ØÁ'Ý!òø :Å•…žÌi§ÓžV‰ß(º»ž ûhkÜÖ¦/›©ÓÃÏo¥“ãÇywltµ¸‹‹ °ox—á&Þ†û.Kï†uŽ2UjÄûh3aØx)Y³!t1?׋+m)nÙܹ{|Öè(NUrΘMoÚ´§‰ßûl£.äÎGÀ®cä´Ê9ã,¶ä]›M¶¾Éa9):Ò+)Ü™=ó'x(Ô³´:9Æñƒ=ÍÜ`ÏÕ$^Š÷º*E㉠F'b$¹­5×7†æ+BÞ”û°šX™Eõ~„æà‰»|&ûóôŽóÞÔŸo¹YgêFòçÕ ™Ð@½é$Ù}R…ålÑ…4_Ð~ó oÊMm©³omNדÞÑÝvû\ø˜nªIùhºOærÜO•ù°óÈhv¹Ž÷¸»uR®Žú xÜ~öÀ©¾A½µ\ŽqS¯Êï]8è/N.õO9ä¶CO”suùxêÇ¿3ä¿§ß -枥ٯ»}Ü!bO÷᛹{7KþÏÁ.°M²˜úN>‹xôýJŽá?”&Tñ½§±ó0±3©ðV›ØßRÈRŽ=iŠv¶[‡KÇ4JÌÅ^Ü¿òÎî~³ròаZØ×ûøy5:·d³~}Àus ÿÎÜî9Å:q¶T©oÚ݃ûëÓFæîXó`_C+ëÄõˆ3 zfî–ùZÉÿ PŽzzîÄ!Àp;Å*Ÿq©~.ìv9·ØEÙ³)ÐûðÅÂl¹¬™»X~Þôe±qHQ‚€nÎ Å^Ï»flœL9Å[R]|^βö…šHak—öÈ%U“úû»‡JÉì³Wÿã~ÑTÝQLL#oÊñ%;œ}c½CYRÇÿ6ž‚sØ+Ï"ñª§Å ûÔ7W°{‡Y{‹úݺÇõÊÝþbßkqÐe˜zK(:ôµÇè$Ûè™N¨]\ ±Ð byK[íF?´j›3Ò×ηv¬°Àφ²ãâ›IX9z„4ê´ZÝ}k—Ýù²]¬]Ö=|žÚp¡FJËý¼_ ß2e<¯ùg_;0’ ­çÀûØ9ÍÌ„x¢¿lKBF›yG[wonämH÷Ö„:ãn{<ÔÁþ½GŽÖÉÕDÁz½²éXSl"ú%ÛÝ7‡7õ‡ýõøu¨Ä$;ŽAâ¼?™y Æó úÊ}²âL…í2— b5ºW“§,œè1“Ÿt7ZÈœz#}Ä. ½é¶#oZÍüªè…Ži–{⺠”é’‹aìM§àa`ÀÍû‰š»½Z~¢Í$•¿Ÿü<Ž™³0ÕñRµñvÃÔkïaÿº`šC‰Zß{p–Ü”× úúÅÖ=lƒPZÊnÒ;6€è¹Ú^Ìœ“xqX¡uŒ²I‰ÎAú­9-ƒ• ­öžµä>Ö^™uôІ„:wÆþÕH‡c.PÎóô~s95{” wPŠú#¹kÃø£Ck@>¬3ÿ-Í{~Éuc’ëi1Fu­3NœÚ6æøÿ-äzÇTʬÊ2ò,Ïâ*¬ÙcÜ Ú’©³ü>NˆßT÷vÛnQ®ˆ}[îŒMYlÏiAMqzõ$5Òäžr¿:ñùLæQ®àºt§`Ôí|#N‰À2Msˆ°?özÕ6ûŒXÉ[¦YaŽ{dBþ6sÆ% „)¢‚c·­_bYÇD˜èÝ+0æËô×"xä!}›¼`aDªÒH ç/¸NÞÅ"ùÉê/EJ\ñ§«MvnÝ™36Ï“8îHQ)@º8Ãr½P¦ë:¬XáÓö DÞ±¶†ÚØßó¹8SÐÙå“"2¿™ëñx÷°ÔCRv.³xŸ.#÷ž~Ò®;ÕñÇ›ÞHØ$ʞν^“òÁ'q0ß(Mµ¹«kÛéªfî×Á*,ÍëÔ[x^©ÒÌYˆ½v9ÑGÃÆ¾Ù6Êq%t뺂\ôuSöП›÷r¼ª9Ä…¦!#Ϥ RêsFîu›çŠüFÝ‚Žäú˜9Òa\–Úsw¢—ÇèÌqvSA®f›„5ÓMôsìéÕä †eŽ¡dßìå<ÿã–.<ùêªðiegû?zs;‹M¾³Dú@Å[ܬkÕKe‡ÕØÌÀhOt&%WëGìÉóFÈ/ñ4YÏ{Ê{`©š W…ÕôÌ T+2jõš´XÄ‘nÛ²éqžîò‰üÄ©›Š¶džð„ó ÜJî`¦ØÒ­¦Û+qd~36ÄCùóæžÔsþñjÞÄ'Xu{UC°6Y‹žçŽý"ïÆ ý%0wÆ~VÓ”¬Htv!a—gO͈%éõœoDÑîyµ3($ÄyÒ¿½ê€bÅ1r¨jþ nk_X]ØMXƘªç|C.'âr$¸†ýF“Ì3u—ëSÔC8HÚ’>c€€|$7ó© k ãï&­ìùP¹ÞìiX¹Yy¾³¥·D²t|¸2Å ˆ Üð;œ§“;“bž&<1§§J9Úꆪyæ¢+ìyÕ.4åúS·ô&yLóúó]‡ž3ֽݽ܈ÿf^@ýG¼Ê¹eî˜#—2OÈõ“:u:Ø]HU8€´˜8Vâó¹ðääúÆß|VMÝ£böë”GžëÉ}²žÓ%É.øE“VÌ7vÐÖ›`|û9¼jýfcú¸¹3ö‹”TÀ?‘ņ^aájt°÷S¨ ~5×ÄZAòÛ2{³DÕßÍyôê[˜Ë¦Q›Á³-7Ú’î ܨ§…Ûÿ\œ?çqÌžØïÖ"‚Œé+ÝŸº<œ8Í{‚l g]óî¸;°µâäœ ¥YÃÜÀ‰S4—ƒÇ$×:Ó…¿k }íi”g’âëëÛÕöÅP<Š+w› ¿þ¸â- ­0e\å:s·ÙçéY¸cެ6Î8pó›ý:=d(±^dÎyÊ…wrÎU>¿Yž†üx¯®ízúϤ|‰dºJ_SMJöb%Û›€}Ý·“¡4mÃZÏüZXµ¦ ¤ˆîˤ3ÿÍT­"£+Í™9âì[ïRAäî7;éPÍjìï:AÌØ¸æf-ù<®™jV«ùwç/蜑kpKt£ç¥›) ¬õˆmšWàÚeAüB\wó9fEž ÇZÒº<àùbËd-’Þ=N«ØëUîœG(ãÌÇã® ã}¤û¿é.¸„ïé;x¦æ£bÇjùÁ’b34W<à<£áÑ–©·}X3»ÂZò"–yLùw<ûôbUf¾|@"™y‹OáÈ­ÎÝñJUVò¯ C Mfˆ™†y¢ŸŸHí™jAß&Ÿú`,Z®YÃ<­“±žP›ŸxvûÍY¸‡C*3>ð–»Ë³Ýì•¢8N:c?oJž« ŠŸBkrß¹æÎ}”§õ¤§‘¥×gꢩC=>¥Úðþļrÿ@{spþéÖÞäY±êãmŒ±˜Ÿso/¬LµvÜU°8Šyt³rÝ¥6ö:Òï;˜…šÂƒlçÐêîÙ§ ^Í>0=ÞÈÁõx³Üévbfã`+UÞ×mõB¿3MšËS=,;nþ–Ï4ô)±ßÈiD‚=󻈹$_.²¹mÌ(~à¦ÐÀ{²„¸_è%N½{¥]Œ[" ìUwçµU¨eûŸÑË\Н±*Ù9Ë[Þÿù}îŠZ+ê¼<Ü'˜¤ÊÝ¢wΛ‡lÁм×qç,mصnÈ1JÜ"¯`;h˜ÑàŸèÝtþ½®¤$"øêîÆè›m‡ŸHz~IÝ´cwª‹<)³:¢2¡Ó‘FæÐÆïó¥©Ô¼Mô›Ä[÷ÝÖê¨ãûñ„xªk“>4¯Ÿ*»wÌN§Ý©º…=¢Ü&wñÿ ¦ÒÌ É'×Nt%´Þûuô”bfqmªáð úšâo¼·L}Î*Úšä–*~ó×åàVàLÛ – tŒ-ú~&¤³—SõÈ œï<…¹rãÏ›¦z ׿.×®ËÁQf‚æýy™]:äJ¹$^@D#Œ½)?Wm°xúNÌ3ÇÙ¹†½˜½4›Á"’?3åœòte)DwYK{¸œø¦vÅsgžÀñ:œ\±[‡qˆÉÜ‹I ÄÀÇ Îp~½LpÁž0:¡[¬ù¶ŽÍܼŸ—‘>©ÇÀÓ°Ã °‡ä6©âû;qKL¢JñøÐ‚h“úR¯¨m É3žñv˜‰9ÜÉ'k½gö>mÈÏ 覡P”Úe‚BÔØtÌDŽ4O#~?è ùÉýL6íÎ4{úå¦ÜIšø!žî|/VÞ‡Ñ$‹><Ø$MÄüµ§îiUöiz¢{ 6ìÁÚ\ª‚ñ®pr~Ç-m'¡´90#ëìî¹í[Aq—ê …h1dKuç©Ç§ÔŽ»›À äË…]â»ìÕȳÎKôßéÐS©Ä¼ÃZÊ7ß–É_GG¢Þ ³E R^[3Á©8QM›ú®¼ß1B"ûSXä›9IZR§®§[e\å!ÅÌÑÁ-7ÚÉû&§´<‡=ðŽ9…Ø7ܽèsåÓ×.dÄš;cÎ<ÿ'´¿T<æŒ\ç„Ü<™Æ¹Sµñ/z ºp~â¡E7Ïõýüxψ‚}sþÉU)ð;î·‘§÷†>¸Ñ·žlϤ{:œCÈ}¥b¯=«HœæÂY ²2Bd1¦û},š¥Po F(ù3f°J½`÷iÓKyM!GŸþþ¶Ð!1"çŽyœމfPؘe–hø´Û“˜_7yL0Y+ø–®¦Éö×ã0NaWž”º×ý]è–8Z6RÇ÷À°Ë¤Ó¤ÉÃbL++Ê{TtÊc<›]±!¼w8íá¹eó̼ŒP| º¦žo { « B±!>ÅMO\8á3Fz,ì—fñÉ“éâL¥q^”9]œ¿ÝÝ&+å(cm'ÎÜ{ây¸Õ>:E¥Lrkü>¦Îä®AaMßßyy³ÚåOt'D^玶 ÔSéV'†q'_àM›œ÷’{׿Wfæ4mÝšìûmKóæ îuà BŽRH²ifƒÀËÊL˜Àñg;_‘?S³Ë1Õ°%Õh+Þ\ÁNÕDî/I ú¹ãlIžæð§›˜6±§ßò¸wÆ!MKã彞U‰uc×\/“ZÌ £~cOíÁyS®!ÄÙD£x€0ò MGV¥'vç Cмwì¥cJX£®A£Ä€idUÎ{ÑÝè;_¶ë:džÞëñd…Éå±P¤ÞÍÁgžWð'²VýfMn ëqm•¦¥iYó|ëeÂÒnwNÿVÚ¾'º’«°"íÑö4¯ºkgfî›÷óêoÁ*’uÌO§º_zœîΟ;»íÌ×ôgœ4ËÓÒ#m7¡^G1•çËsˆ7uŸDÄ£fô·\ñ|>óã‘®cÛ<õëE²ä'Ž®èþ Ä;?†6k»ðžâ®›’7EŠ ^:ÆGMe»tmwÔÓîÔN;ª…y’( ´©“[™-¨s¹Å2åO]»±bÇìÑNñƒèîÏváš›NØÒsorULDd<±'@ôá¨;¡õY‘ãw $Ån¢þT° «—_R݇ç:®Ä¸ùóä¹ÛlT¢9]B=T¦G&æÕ;m;Ôyl¸Ó΀u•FÉܼ@Ñö]q⯠páN¸Mz{f»‚»z¸ F0œxŸ©º=îBõl>œ§×Ýšê†æÓ‰—·Y¿vûE0ÜÃå#;Ïs"4iåwOÛÍ‘ÓЉrfFžnyf PxŒYþ̾Ñ>øb+Z±Ã š‡p¤®Nñ¦Ã˜*ªîp£,ÔUŽ+îœt ÀŠnPÍ(ñÉŒ›ˆŽ–mIìµ{˜”äkÆÍòDÁOîýÅß®;Ì`šUHzŸ8“Æó¼©òzg¸D,¿iïîÃNþB—ÿ×¹·Ö6³•*5´e:ê:,üè1žÜ¯&"Šð;'t‰­uIÛØqJ>†T"õšÂDõsfGJ™Ó·uû2ØñÝƒÏ°Ž¿¹c\ž¡ü'ü…Ùsw¯ðåϪCÜ-g¤øAØÓî±Ø8ùÙ½´±òÄUu=gËßëÕ©ùüÄý7NÈu÷mÏh‡”`¢|ß4r®Çã¹²ÎyÄ)Ñô7ŒSlœ½)ûRâêT™ê8°Ü6ä Ë,,¬8pq_šÍ·˜ÎþÂÃ!î.Œ(Úö'¹»X®›Š¹¾g1v™fÙ Ú7ópd1cæÆáØ;Ýã`R±~7°x_mÒ5@Èß6]ų§µóï žîæZ˜G—i^©¯Gd¢…>Y[ÍKsEêðª)6¨Së“û,ÃQìÝäöGêÞêÜÝ+tˆtž¤óóº)ÌéZ{'!!§“î×—yYë=ÌÆº5æXÑõ°£ÏgBÇ{0(y®îí‘ô;µ»¼vTÐò¦y®±O´hÄÚkÓS©cNõÄ«Äßy÷ÔJUôöOÇ?&3¸A"!'Á°/÷`¦ûã2½ÌK{ž¸M XF|8#Ñ] ÷™3µ'wâ.µƒiXeê‰ …úïiìôʼn–ªeXXéÔ„3Ë:ò2G` ûmXVÉU·Å!Û¨…mˆAFÍôÿÅyî›Ç™»b\G IÙ¬š;cÿ¢´;»6°‹UXªå ¹¾æsSŸÓëy¿ß™Ã¿úmLçò“eæÕ¦žº<ž\ +ptÃymÍݧ±°T¼ v“óøSóäÒBôØçãm;_ÜûvÇ)È >&x¥Fp²\…=¼®4âÈÑIóÖ·¡%Åßz“½ JA¿ÿÅyÃóO3î^¦æNù!ñ²Mg¢I&öùñ±™þ•÷ ÷9v «®¯Äîº$ú‚Æië_άNO:‰¿ÍRêãlJåJ>í/"Þî Oº©ó4KøÀ­E°ñeÐ –Ó&¯’*ÜÓ¼ ¦Ò¾ÚåyÕÅé‘uÔÆÊüÀ|®¦Š·‡]yîXèQcН†}¿Ão_Ÿ6<‰u ~;lI3O‡˜ÌŽC4›5Îôî{ò\«ðÝýš¦È •¾â.°¶Âx³a3wÇZì8UŒ’hßî¶kôýð™]ÇNwr„ÇÄ.äÝ]2¨ZR¶¾äк啧ÂÚFùïOÂuvS˜‘F=¼;8ð>¸*¾m™\•ª´ãÛÌÄD®®uHܱÍÑVÌ3É—©i²IXçã¡?8Ž¥¥ž qL,Ê=ôžT¥Ét±q–г ×uk:Ó˜2Té}†y‰ñ;6Y'Ç]9T©ò³Üÿúæ:£à~µàÊæoëEîiî›ñA+˜yyg—㙎ޑŸ8B¨ˆaü¸éØo£ºt ;Y+gô÷GXã5|{½Ý¦ŠòLZ›Ž„•Ýkbaå–æd–NØàwK¹©kºÿ¦•ÿþûÞ@„ÈfGarch/data/sp500dge.csv.gz0000644000176200001440000016043415116751403015053 0ustar liggesusers‹l½I’$IŽE¹»„ÏÃzßD}ÿ»4 Œ÷¡Y•‹Ð27SUacøÃÿ÷ÿÎRþ)ÿü[þ”ÒÚç½¼küãÿ]mœö½ªµ×ûýc-­÷ö~o¹ú{YëlõýѹmÅŸïï¸ïó½<«Ÿ÷›eîïÔzµÿþè¶ó>}î¾û÷ªÿœ÷–s¾íw•ßh}áyîûç~w|àj}¯÷rÖßÍ¿ùâÂ÷}W9×9ïzìr{}_¨nû…¸ ƒëñ/×â»­9ÚØúg½(Ï»ó‰wqágï÷»õ”vㇷ¾\ŸûÝ­Ûïìñ=V<–ví+Ž<ñ€ÊXklþù]ƒýcy¿7:numó{uìrnÜ‚=_¸Ämí£ìïëê…oÞû|_bÛ*‰?cŽßgî÷Žv}ûûÕnú}ß§·SÞ'·‹aޏá¾À.7b¸¾kŸ|ã{ûîCí{4n?=¾uÝõýâ¶Æ7Üv'Þº°»V\ô±¿‹ulkòûfvkæû×f—ßçœUë{K{ÇÉŸŒwÑvw&a×ö~Ó.úôX Ç~£ÇÍŸ«ÞX¿ÃV]¼×=»Å#kå¼Ç=láp§ëz_Î^Æ}ësú£} cÖw«K›-nÜ,½¼ggw8ÖÅékÄíÒŠ÷¯Q«^ö÷Ù¶,âoúµ[<Æ}·Ëbe?Ž3ãÞ{KK[+~Zû÷»¡õÞ¸aeÙƒ[ñÕˉ}°lý'°n~‹­Àø˜+u±Þ§4ûÄÒ¹îV b•Çf‘mÅC÷õ_¨Ù_½+j¶kü‚Ý›ïýÛ¿c7.ÕvÇX†?±_ˆµð²âËÅv¶_e;{¬Š»4z=ÞjÔï.X”µuñ®ØÙÛö'=õŠýØV9«¯€·øZ‰@qJ\Œ…‚^X›èa1§kå¶ÐÚ´gÕ‰ê5~ußÁ5ÔÉ­­µx|v Þ:±Åî[ûÝlÛç¾Wᆲ3¹™ö µ×â±M?Ib³Ú"ÞÅ ûêu蔲´¸­•k¬o_m;èŠï{wÛSlï±lg².1hÆN|¯þþ‘} ·ëôémó×··-ˆ8%¦Er6dlÂn›†X²b­~»ã}¬^Ù½eÌ~ vœÄYfK¦ÄÕÝ1ßW»a;Þ»/‚ÊØ'ÁØvOc‹WÞÇ"&É6cDÎÆf´«º±Ðöaë”û=™÷žè#$­{Y-öðñÇâcœâ¶Üø‹yï‡çúꎷíE{³ÍŽ\7;ûþoÑ×raÉ~óTž£'±åt¨°í{t%|[õ±Ÿ{¯%¨þWÄÙ4çŠàWn‹•Ü[ã3ꎳµ‘4Œ}ã‘ý¼ôÃ)² ~OÄ8{Ž›ý0"W¨Õ‚Ü{’¾›ccÙÕ­HnîºÚC/稣^2š÷žïÛÖ+¢EV`‰Bkl‘[ Ë E2`ß6^Y¨‹ë²Þ—PœAqìý¾¼+~n{9΂:, ‹Oµc®ÆBj£G‹;m÷·¾ílßiDÖa¿ß¹Ê>8ó·m8vpå!ÛÇ*èÇÎÿ÷píËÝxäÕÎøªÛNá÷to¹…sՎθõ•|Ä¡~X ‚ýñÛÈ–ÔÁ–G(±˜q",÷=Ö5›{4²5Û_qŒX:ž«ÅÛõûΘz,²‘dÔÞù.%Ò;:7ºûJ ó*‘pØ7lV;\`¾ôę̑=vìâj aG)°åVñ†5Û%ƒà]É(ï"O\¾˜ßdgç…Õq=½’íöE¬évòpäõX"ÝRáL©âëZºÙbÝZÝAH³E¡¿ç‰j7èÄÙ]ÏäyÚsâ!û†d ½E\øyv2q8Û‚‹@ê¡9¶ç% 7 qÛ-¿{×q'iiߤ/)‚gSºqlYþÉãµ{ÆröH÷V~ÎÄc³wˆ»h1þ}’í•)U‹GiµFâi[fòƤ ±k$÷ó—:mÇB[T/v%7ÂçG„6{ðo7Øî³K}›®s ´Èûmûœ£¤ë¾ªÚfYØGð±8t2iã`9vn“%î[²õEÚ{bz–‹nm‚sƒ¤zÄŽ ‡áõ"§öŽâíÚÚ‹xn…ífíŒRrl:>Åj@% çÝ»M^)¿_´{Á¯¬X?âëØ6u¹üqý–¤ÿ†Î8À{‰4«5¶~Jœ ÍkÕøw )D¢õ×ôœ–\¸ˆÙã9xjÒÞöm¶xÞ÷èV1Õù¶ÒÝü‘e¤øvûcƒÚjo-Ò˜Ëʵ·"÷·Çö^QêU¯)"6Ú;î¼­ÿèE\Ã% ³%w¸²‹ÎöG<ÌŸh9–)Çw”wvÝñyö]#÷²‡‡¼‰¡Vþ7ª`B–…Öý{ù-*Ë«g„Áx4v“9s=œÆ9ØygÚ±Oœnc}ÛÛÆÖ¶“½Fýl·šÏµ‹ü”ÔžK{…—Å“™‹er›²nÍ_“Jþ™ `!µÆf‡A„‹ÝÙö– D0±m´xÇc©6Ï¢¯/âå˜DBAl5VT6VìÄ]Y—ðµúŽ«µ8ÄÂõ«Ñ“é‘/YÍ¢Œ†š¢o«]ß‚š›ÞÁôŠó½¥eï•}.q÷¯^åÅ"ò ‹¿˜QÜ[8D)ÛGÑz²c&n¤ñ3Ûâ$Ôvð^–ïáXÔ=NNû‹§CgCd…hEiDÛàõÝ({ÇÉD;صd»i±ª{%™´ÇAÓîm„©èŽyíKíd1Ž"mÒo³ÛÈÝÞ_w‹S¢Æ±ÿÎÅlÑî»… ÐN!›™«DsÎO»X“â¯íûÖ÷ÏÃÎ-¾»‡Äï)ZTˆŒx6b¤­û¢–X¹Ôa§Ñ·Y³ÌJM"ç!Á³Àº½çŽ7µ·¼R–P¿`‡ê‰ö¦êm[Æ;–íßE·“ö»Èêwø­Ùª¥L%ÎiËjbWÏá[øýâqõÕ*ÉŠ'±ø½¡ußK+iÒØþ­Û8|¬l4•,×zy¬Ñ±Ü6ó;]¼â< kÙLX;޾vgô-Δ%–ƒ|c§Þz_Øöõ´/©÷C;:vfºl­ÇrÜS§…ŒØ)Ó"àKí×ZDkK`bY)±×‹…p´·Tß¿{áõA_3:"{èõY|i±/ú}«Ð"N»*GÛs äûѶÆt ì¡G8íÊt¶J0ž™…Ÿ½ˆ—›ÞO%!k 0v¤Þ3zz–¾n’„©5¦á½÷ÛÚ5‚—ÝSöžç<ñu¬‚Šè³*Ùe³æd_Ò61g¼•-‘ÏZ–ú¾„ÝÎxœÃRä¨ï«.Àޤ7ì”r¶|èyÜ$Ê]ªÁ“-y;š##²è…·7ni´[ùD[Ñ›‰„—XLvÏH¦í\`6eØv*GûÌ6\aù¥uíûíÐnUÃO·8–~ø^~Ÿ½ï¦´oÜ©øèÙ¶Žõå/â‡óªæµ“¶ºí„×…±K rWüÅ «ëÝŸ8N½'Ä–§‹f¹µŽ ÖWçldyýk÷«0¿ëþª£ïb'óo)P\õRIÐÈuíûGÃb…á»Û—tåí4ŠsùîèÛ‘Hh/ô–bÓ®'j+O•b‘lõñA…‡ì©k¬¦uyóyx8¶¾YbÕKž÷§Å²­[¤à`GÇæßoèÝSèÈ‹-6Dâd¹Â«K»¿QÜ$»ž¸…g¾ìÃÝwšœ¡ùŽíêxƯ؊EþµF¤Ev|¡Fb`w!~œeöüéµF”ñˆo¹:yÊš‘¼YH‰ ØdñZmXÕ–:¼¼>âŠï“^õñGÜ)ÛYÑÑýÎKÿ¯å5²4‹2$–Ù0ì93ÖU+¾Y9Üé¹=§®ƒûÝSû<¦8Í2ÿ˜¥yZðªrÛc-ú°í§—Nëd•5¹Ã±ÚWÿ½•~âÉÆ«XþqcÚךï]bV‡êã^ß„èýÉŠja¦ÅáöO±¬¼eóD‹ÁûØŒh,Ä_2(u (#š V2Ó:jÆußÏïÛ†‹ÈH™š€µXØv–ÂêS+}·I·Nä¬óË–c ܦ ¡-—hÃXDWy­2p÷çŠmѧ¬–Ìš¼Ñ#ó™Ý/K™&Î/:¿_©KšV[dû‹¸Æ¶iî¿+ñhJ,x[ïÔQÙ^¶°?Ø‹î¸]eÍ®tUí\=Ñ'²¬•>‘ZÄó^ÕGg̈¸Õãá¨ß¥)s£b ÀmAƽ¨~E°³}Gþ¨tZìöNª+.Í» ´ŽoÙ‹Û5Û>‹2Ç´­àWÜZÕ´¹Ç£È|¯âæð:‘ k);Ü9ÑEÞVŽm1I,mƶÄTÙ‘ﯭòˆâÒž}æäs¼ìÆVÄŒ¬»ûI«l«“•ר.»=xRS+ç£lÞ—âÜ’îè4Õ=i­VÛ q>Ø‚Œ¶‰¨H™¼ëÝnÞˆIÌa Õ=ËŒ÷l3V-•­NKU.M•Èšçî‘­nNb[‘‘œ÷á]¦ˆEë-Yop°:Çwh|ïݲ´ò4òÎó¯Àˆ'݇ú{wÄùì ä½²+$i›‘¬í1­¤ ”À«¢8 <ðóï³Gµm•æ¦jñEì^³7Ù»àQâÚìÒÇ ûÍc§s¨ú¦\,¢ÞHÝìŸ_š[`‹ÜŽA5ÒŠ&Â> ûîf;ý]oõ&Ä÷ö¶®ãTöèäãÚ ¯±„kq€ iãb®iYQwª-Z¼KÅ"‹æƒUÁ 4§ozÃé¾—†xv0¼µc›jǼÏÂBU҇ΠÛDí¨™Á~æŒ7*ØòµUI¿b±EßqÙ s2—òKjóá#¾»µ¢B´]~kO›ž¿ÇîØ¯ó°Ï¾yðî}ª‹ÚGÚé3²Û›­åC$ìÙúŒÒõ½ŠÅÖ9áæ\œå½v5,;¦Ð¨‡¶úeêmÙEßôŽJäåk*ÐSö‹“ôlMÎ7xŽ»£ñW¿>"Ü7æhö¡ñõ­=Q× Mc‹ìF¥g5©ŽäB×½ÏKÑq¬ ˆí`‰“†n{Džïᓳõl!Gå`·^ÉQc’`9„áX˜ˆæVùþõ]æâÛ[îÙ#ê6?Ÿ–#>3"Eyç{tV-Ÿ‹jça¤.¶ÎV’l›ƒ]¶o6ÐëâϨ„Ç9'›·2´Ì™ŸIƒ6Eäf{dšÑ ±Ûwfz?ƒÞOŒˆ<82;h€X0md–ÜFˆíÃê ¦5[Ü™cæ–^añ*¾·^¢‚õ'‹Rå¼-c‚N£"±ÓZ±¨ýªt+Ëk«v¿¯¬î÷ýùÜåÝNrýySÝ‘0 r+£œ:&€Ÿ—\ì\<ÚăóÌî†F‰ûÁy¢œ.Y;ªMŸs¨²Ž¶ˆ“4ã-%$À¶ˆâº^®úž<]©/¨¿sºªÕëÉH,Ü~Ùˆ§¨QSX~´H[+=ñmÑV³h¾åRg3‘ÜQå{e8 o+XÏÕD ¼õù Ocgû÷ÉRзí¹»©bg‹”ÙÒ:@‰vþÄlog¼¸2Hð^~®s{AY™H²­^­}§ï­ì¬™$³–aƬ~:"îEZŸûÇã”;¶Û…©i"9@gK Ñ¿²ƒŒ¯Ó´s´Elê•Gë|YR- mP#u×µ9+ٰ嵃œîNà¬V=öW±pÔ\«ÞŽ TÇTæ=m U6áb\í)«aª1h•[B7{(_öfv¼¬w½ÜvyÅþÞÇ6fLì›Ï#Æïïv¾Ec÷ø=6ûÄcX¿s¾¶~b„c¡™¢ÞvXì†eßë[Kõë1pôX–ò=¥ãXN¢ðªÁ¥è(Ç(–,jõ(gN d÷é\€gnô }ÿÕ(UN»Jzâø·=à>·ˆNˆèô}ö)Ñžr”@çMî~c±t»" hsP=ÙIø‚U÷HT*/™ì%s_bå®o¼ø<5J|_üºÔSµmÅk:$ö-â2âÕ÷«{xî­À[˜Åzå ÈãCôg7ø KP¦îz' Û—šï=çfv¿³“ón»ÝÖZ¸¤¯ãýnû¥÷=Ú&‡mÿK¬²ª$²ïæÉAìÛ]ƒøm‹?þÌŠ7Æe–0ÄRµ°A°´5û"ƒ­Ž1@¼í8a­8«Q×ì[Ú¢SìèúatÞ.1êÉWÕ¾N"K"+¶#s0÷¾Žùöê #"ŒmÑ—æ +âÕü!¿…”%•ƒ?^"bW4Ê–s”n |˜…ý½Ô“ÜDk{Dñ4¶·IHj^ïp+£/Lœ£‘7Ú"¨ŽYÇüI¼<Š¿võ÷5›g‘ÄÛ Já ŽéÛ¸Gí0bó"¨OÊïÍA¢ÙëHÓ÷9Ž5¢Û:V48úm@ç†çˆ¯©`7¦‚ˆ›U¢¤Æ!"1ê±ÈÄ×¼ b°ˆyøûËáeE^¥ÜŒWVø‚/?õ­íNKÇN÷€¸/Þõ”‹ØDó¥ ÐU–OÒ½þu¨ø…˜4gWT6 gLñ^-™C‚j¯/[*F¦æÙvD‹Z˜?|,J¯^_ƒÏ›°q`øûЋ¹ ²íƇÍÅ4ÒóŠ%ÑKU‰ïˆÿ¿òõïc+©¨Ã¼hÌxíw82Î[ ¶"WµËÇô±:+hn‹4ý/?>xýŒ!ìu+|.H÷ kûÇ(Wâ>ü  ç~ýyêýÕëü°¼ï£|Ëý“¯Þ¥FѾÀ/-ìêïÏ׈Kfvø\ݶ ú^¾”À„¯a`Wz<ý}opÀ¯¿¯÷ÝËjôí€à²øùò>߉¤ŸŽå„o™í«‚{·h}wÔ0‹\Þ1O'Ú*ß«÷ŽFˆ í[Dì="ð ö½¿ƒÅo.ïœ~ouЯæŒ÷IGÉ®×;/ÿ¶K¾±/GÔ®1ý±Dèvˆ3 ÿ2î¦_%÷mú6_w¶ûë­Ýj¹Sƒ+Âñø"ÝzýcNQG‰°_‚a«'ˆ7–ˆm  ú}3ï*Ò]³%ç»-|†g•wUV(­Ú‡c®ÇÎÇþÔ¼×V;iÙ~8׌;áSò8 ªÀGNÖˆcnZõO±©ÍîÕHl®ˆ— (¶ç¢o ÂÄþî—iIß7ql||ÕjeÌ¿Uœ„¶+ZêµWumOetyãkßB}‹s<Л÷„"‡³7@O^ÅÆ°£r&Ì}Ot2*T¶æ‹¼k^²Ž¸ˆ­e»("«àBÐrºXQ9Dý³i»†F¯m|mýí®u-ý™úÊ/YŽ|.ä^án§î¼[}o…X%vèȃ$òÚŠî‰N€Žl~½[s‹HZÎ2|°sèŠ4*+DEKu¤Ã÷}e¿à=s7ÔÚÆ+† ›¾áñb^Ó»zKß²èJl·kJ„sp ý_Éûò¥ý3ĢӲϑf«ˆ½ :é'Íú@úeL³¨áo ›»ëÔ’ø#Éî¨p´ˆ¨}ŒÑê$>:G^DpMÑqò±t>NŒ6µžßYq™»×qôµC#ǰ4‡ÊpupýÍ×pLÿÉÿ>Õ¦¯ß4ê[íÇÛp߆:ËyÿMcÃꈀºuâõ~$æ·žJð'm >:œ=ãµ`‰ªë1(¾Z’`Cô9(ÌÆ´ÛßýЧ6>dÖûÔÚˆF““­Ù§Çk_†~¢}瀯ÎZ"Û£TÉ,7yÊY(ào·<ª^çÙ¾\­n _.´ÆíiGŽ`ÑWci=1Kz‚œ¯,ŽÜ7ÛñÜ::ÃâàËEmK¶X šâXæS£mäëõ¾ùïo¼ré–ô«võ¨œ õ.»-ÿ¢!K÷ˆrf‰*kçÆü;!jNwQ¹RÌ5-Ö¯ƒË â's|ÍVbŽü6OB [Àj)úÚ‘I]ÁìöоªãyãmõPâeÉôØÂE_8/ªZIÌÛ~tb4j[ŒÕäȼˆYgg‡ðÄì`·E‚[» 0âî§ÈT1·µ©Uêg™`p€ûÞ Ò¼ý9©§JĨó`O?•IöF\Ûð«pëÙ¡†ªAqòÿ½;Ù‰sݘµßº±|íÄ‘ukiiÿ}Ñ7±Àv#>9Üì;D Y‡"jWÔwdÁqídc=X’A2¾o„|; £íoa¾QÂÚ=¥9Þ5%³º0†À—•/¿™~TòÇg ¾£èn”¿²é¸ÓÑ ]b°8ƒöA§örÞùN) Ñy´"{Àxº4Pü Vïh˜Ìo“Û­P¶CΨ‚Ã¥ 2AŒñüùoPò6ÒQGÌÿîÐí½×à®P‘ÛB`òw4ã¾c#{Ç€ó{Oøƒ“ ßѨècß[=DS·ÊŸã휸#zÒ–E0CÎYùGgzqNÐÿ}"'æþ@)os sVMUOž[dA¼¹¯¨—ýÚÁ¼¢)Wdå,WèèÍ@õ8&H]©KÁ{ÌÇG°/h­Ë4€Ž£¸«Ýi¦<ÝvÿbòHÏ–c´ÔšxK=ûî/£üHtµ;<‰ŽXå©Ô»{Ò”÷ŠÜöU¼‘¦ŽŽ–òÆ¥Ãí2±Ã =ÛÓƒˆâµ9¹×(ͽ›ó6?Å…99jýÛ?ƒ\0Ñ›6¹¥#Bsî5Ñq¨J¶P;§€Ò¬Þi¥ )z8K]fOøâðzìãÎ` ô™¿n÷w‡4Z)ˆ¶7“xG$‰ˆ[ĶS’”ÝË=Ú—žDÆ^*ޱZòZ©YŸñþí˜éS^hqG24Gõ„½Œg°O Œ]&Ü‚Þí˜ÓÑû;ʉ(?xÈ ¤ÕÕ*À•!†ƒ ãLpB[üŠ÷ñøî+o?2bWúƒ%Á$×BœP ª+ã ‘SAœµË€~ kÑègx’‘cŠ¥¼Úacé$ø¹ÆNmž¶Ç3©+¡/‚Y x „˜uÅÝri=,qìKk­€aض&xN8ËŽî^Bß_¥ësD*épdê4’qnzÙôîù‹Ì÷„öQ´a_ØõñAcEmyˆ¦¶$9áí¼÷¤ãô®þÄ!‡ T°-‘‰jpÓËõ–z1Ì{ü­…‹›Ý€h­,~Sâõ¡vb‡ ’ïê„å¹Ñú©bX…9uT_òÕ1®ÎµìƒLõê7‰k#$Y®D¹ÕWDÞ*€Ryn†*ž–C¿iT—à.zHI²?Y‚÷¶sª{üÅð8b ô…iö'GÁÁë#ûøç=çõm]ޤHÊVKrä|ìžpŒòç¶"=œÀþ©âKÚ3æP:Sh÷ÑÀžøÙ3Î$¶Im§•™èkiÈþ¥;W½S%Ñqµèâ 9,ÚO@‘ӳܸû)¹[ÑÜB敯Óó¯’Ï)Ä* _b"­žÅÛ×#êÂϩ루À9.o³¾ÕWÅjnER-^yÁmš±“gQcý¸LG5¬DñíûD YŸ1ÓÂ9T4ö{¯g 2L;‡FnùWtRüö4ètêîY7» ZÜWF tÀ®·$7äøÓh xðK×8Ó¡&´³o@ڻĴ*+}§òmè-­ÜS^«BKÞ•¨2gáÉOr$'ïÞè~·ho~àÐ$ú£IÕWå"8´[ü7…£*-›x7E87;A„Ô\qç|…p%ÙÅÎq¤ŽÎPs^p܇ ’ÑÎñ‹zÙ\À#’í£TÂRhØ_¼j®rË©žßϼ^G ®Šý¹+Íëêg/C{WŽ~›ÏÀÆbz×rZý¼üøYï£[a¦îLúìB çé'cSñÝ«ZÝV¤Sã_b]¾ú]<þòw—ä}á }Íé‹’ÐÚa˹Ú¡)…è ôwE ì>é‡(¹vÎMØ„)i¤ãŒ!î-ZNF§ÏQq9Z„ÐXâ{k(I¤N}à"GG¦AÒ]ÿ軾  8ü»U©Üq‘Šùˆ'Ìi‹FÞvU2‚*&¼¦R­01úøñä?]ºC²vAô×Ê` 7sÉ1ØwGUËÉÚ‡„ºÑn³Éjò¿eð"a“°áÞâX·(ÎNA° õ‰Õ;*­ÈVûÇËï[¤:~¯XKÞ³D)Âg€üã0gV K}ÖÝÿ¹Hç¾Gf:Ešûy¤Ahv’Pp満ÐFg"#åw»vlˆjxP‡©1е%ÌY3' ÛfÉe€fædÏ´_›¢,­ž¼DxêUËv´ŸGu¥5¨ØþÆzå 3²‰í8§¿žõ÷Ó[$Üå%Mñ‘Vy;ù]Õ.œÕïUlRéF~÷òÓ!ü¶BêYjA‘½ Z òÞËf¤=5u~/úåÙÐ\¿!a JôÕs®›®•Α3;丠½Ûº»Ti:êI–R²ç¿ôŸ¿.É¡´¿,cæ±xö„žK;fËË>WRo® ®Ã0…dÕRÇÏ Ê½y£—'ë7û»ÐCË¢ùGO‘J¥ƒäu =Œî}•|¼€Œ]?õÕpÄzKÑBþ ±CGWWfOÿ¼ôÑK  úŽÙí¨=˜ß«Ò”~’ÀdS%.±ùðð9/<á×&xßçna9 ºiEí.gˆÆ†]jªV•%ŽÅ!ù\ÁØlóçŒXV’ã|ùn$–ã"Ýs/Éò•ˆÜ’ºÈ´‰||t¿Oãå÷‹–ês£½±}f¤MJ¯. Ëäh/š‘oàý.riÏ,ßVZêF#í}Lü¨ñ-‚ä©ñd”«õ%mÓ=MUeû׉4qó´&åAt昚zÍÆ­¥Õck*;¦·ú3Zü óȦî%vï…¯¼–'›*aôF­äÖÒ $MÛ to«êRát½ðCÇrz„Ùîl¬S©Yâ×V½ûå¤ÿ¾ØÒh—¬Â3v<Ò T¦®x ¯Ã ÿ•OðL•š¤~r¹åÕl̦É[¹ÂIm¸]¶(a_¬ØËvoˆ»7 Ê©4ì=®MÑG¼ñQ¬ËEÏÆ3u¶zèïÅ\‘~&OÏBÏ—r¤•·EµÌœ ûk„•ß{óž‘RÚݶ†f](3M“-9ˆ<÷0W?2§+†Þ#¿µÅØ53 Ø+%’+/8²¶=íÉÞt²¼ ÉÁc2Àà–¬HúžçjÌn6²KûvÑV¨$ ¶G±RÁêw«ÞËïC•Né9èx íÏÆÞ ¨kWÑÖ=½«°îFª“ÂZ/)ÕÆ\¥¾!£Cc¡ ¹³Z‚ßê8SM¶nuøN,‹¥Ñ¤Å©¨ÝÊ&»°õ»FèêļìÂ0mûG`œJΜ÷ Ô*É|æ€vè qáöÒ¸Es)>EËÖÍvªò4Û=Ú™]œCjËà¸î=È+6 7\ÁS¨§_ô#’л³E\$iaž­¨ 6`ÞÌI®í2Y–» íÏÅ;¨Î©&ΚˆxýTiŸ~\„Ù"&çùQœØ% ¾µÓwòb*%˜ùŽä_@C{t=tC Ôõ–é×8~Aä%ZU•cTLOêöÙ¨9ûGMè;×=|ñ'倾Cý”ËÄë½zwë(¦Sß.§­ÚT„N߀¼ÿYhehp´ª2RªGä. 8¬›Ñé£+z2kÒóKɯîñ:¢è¼Z’Uèn¦KcDÚ²XŤ\™7‰vM [L_Šœj(ÏQˆL–ók2”ŲHöp낈󳸡F—Þógò%Ï㜞Wîkزôð=)!>“Q}µðòrœUÎ/Ô¾@ Ý} ÊìB‘¦žFôviõ¸öðÈ`b ¹ DRfy– ckðt‡ëʦºJ[¾9wÉRH G}²²qBƒhË 2­ØE([ÑŽyŒ¾w[ç‰q£ÿ*-¹´j«B½µ_fÕN¼HÁoäs ™öz€ÞtùDXýcOž€çòï^® ¢2Žž¢ u"7óz !co FÞP‘GjŽux JíÂ)W±Ð9NgT‡Î ×.t&¤¢æÿJjHÉíÛFl“ùÓn5š€{ ÑÔ¾}ý`<¤À·i]ØŠCÝöLîJ€•ÖÓ ý'n$$º$ÚV°’n"Í,KÇê–÷òûæ>ÃåH8(‹—P÷>hªò@˜ðöÍ$ãÈ&.¢8Þ¾‹&Ö¬2öÈ—«c¡Wõ¡TÞ{_ü¡™•\tÁ/Ð ÿü÷snìwcI|._ºñG(8b<£l5ªÄslã]»ù yÓPXuÔ¶ÎN‡Ùì^ÑO}/¿‹è›´³Å‘[}ˆEýÙ5stµzÍä.ñ»)¯#'§‘1èÁÓöþ]Ø]|°‘øLð?´L|Í¢ê•\è“Ý{±IºIw”:Þ%òÉSÛ±†EÎAÄÏa¤ºVKè2à»ªŽæítm÷÷½&v2¶#X‰ÞSáÛn&ð>Ù“y…ų‚﹓$àäã0Mššõ@©æ«¢oßZ¾®EÔñ¬9ý‘4óÔ•ÀãdYê±XqÏq£zÝCʈ›ºËîÊMÞÑÕ GÁ¬R¥¸Â©®-&KêÀ»£—ïÒ dÃvfFÊáz2pñf^°%srJMLegÌ:C¢0ÎnuòœJË«Ž8Qì¶IÐx35tx[«pö÷o¸ü)…ÝMp›ÅjÍ#+ó4Q3Õ’:®.t}—ˆÕSÅ{wbÒ„ÊW_Ó:.O(:a?ºBU Ñ»íSÔ%ž¿}ÇUŒ'_“éÖóÓË ¸u üÍàØ@Ï2HvŽÝ‹ìlí!xøïËÑ(HÃ|-`…_gnu+¦8xö•TŽœ,߈æ÷-pGt˜“Ö·«„€]å½õb£ŸK7Ö'ƒ„ŽK•êói4Ãé}[û¼H­wJ.øŒ9u9@™¿º¹š(©¹úý#Þ¾Ë"/­Ïøâí£O[õ[Ñ]À³ÛÀÉøqѳU!p‡èOŠÿû¡Û1D½Ä-¨Ùùÿ)â$ã쑘®ÚZE{“åT™4"¿—jéDV3q^qO©‰2óöĹͶzâ(Ü`,î-u­Ç[ft“Ò¡fS¸‘¤ööFMàà]¹ûT)\9„žÅ¸E`Îx™©3#³6#ýï:·Ì¿¼BÔ÷Ý•øgù‹Òd,Ù-I ÚÅ„¼ëÓ9 õäëÁý£E»ê¨å¿›`Ø–ýo- ñÛ›Ò:U†S’™ö9ODbY•ã=nxum,eX!‘´Œ†šK1D“f÷¹¹y=›ÊÑ&ªVòx8â”|½ÕøŒ/QŠ¿A,®º0Õ÷çvÆÅÙcá“FΦz²:_C!Ĉ¯Dã¾Î…²ð‰ókÆBå”jáÊSÝÿˆþ«€µ.¸qö;à↪š ’î˜4;¦fôUÁ™²Á )Ä;[9BÍYè ¨ÝfÉü¶I­#R¾å‡q–¾Wï‡ "´S°}ô@!u8C{*׌K²âÊì¬áEß} †óŸF¼ÿ£«˜ñç7ù–¸_èûw»ŠXÙ®àÁ®ˆD÷SWÉ-ƒ‡óñY^ü—à·#q鬯ÚünÒ½$¿2Í5Ë×îV z¬ñÙc¼ëaå yÖ,ln¥O°â‹‹ßµM$[?],=q.,9ièu¤Â†7 4ÿ©4™ï™4¾,,0Ð\'ÞÊßPôZ#=q‰Š¨-¯pÝmÂ-ØHg­¬‚3Ú¾a:‰WDS;KÈOÁÄ÷¦ª–.J c2Üd„Ä¡eúõg¨üù*篦 ÞÈâ]·Ùm=‹+Ušè/ŠC%NÀöý{%è?¶c©z*ÿ&jcßa·/Es“gTŸÒ\uôTHR‰ÁB¯òÞ¡£i±wåʽÈâhß76Oêû\<#½ôƒ ÝÏ·(vÖî¡ÙëƒÙH¶`¨:Õ/®66½a8®›ÊìÈ4ù΃Y8¤9ð¡r£'¶**E.)ï&øð„z—í¢¢)xgBËû‹Æ…—ïXŽ®J«9ÜU³²¦àpÓ¡·5&Šˆv¶]Dsú$“)Š]Ú‰Œß6ćœ„zç¿qæ]ÔúuP" ì¤rÁ©`ÖXH†®áÆ ñGººëYÄYy¿œæûÒ‹ ãìõ:ý•ƒ=$¼q‡L;YÒSÞŽ>EñŠo«õrŠûô1K/|ßz¢½7—¢Yu¹mJXf`Oÿ=£%ZÇÖÈβÜmÏìòóÅêV$s_=éù2ÉÙûdú÷ô²¾¨âT-žñÞj—Û°!Ò0 u•Ïõx(8‰ M;±D]hdÏ9ï*X%ùŽÓ0J$é–˜Ç[Z!ÔÒÚ2Vl° _hEü»„wŸ{…2ŒmÇxhÝ‹7XÙ¼¯½÷npô¯½¹ ïÜ!d(¬¸26gtÂKÃȧ*®À]P³ösÖÀÊ‹Ù@wè˜<ÒËÔWÂ=òï^V óv4=\å$Ø'oþ¶Á×¶ò9ÐËꪱh›{Ü?.êWMXÖ‘ìÃ=Œ;ê #c%–½›¸÷ý@¾\$ÁÍÝ BŽdÁ.#C[¡w¿»+f"ÐR™ Þ&ÏÉQZwNªÚi;ýht8"<Žºö†¦ï¦ŸHЇs ãÍeØû^–8S#±ò¨ûþÜeh#o,_ÝC³“µóëØš÷ž€ÏŒrñt(kȧXjºqT‘Ú`o ¤PSÉ1* ‡;Eâ«ü†9·Û×Ò°…Åm{GÃ÷ŽêŸP¶Õq¤Íy(ìüÿ¢•„×÷*’^r¯è:2‹Ñ]lWáToE^àKéý)va^­¡> §bÜH\˜H`í^’ÔÉlÒÇ}Bñn42?)Z5@JÒ:êµâÙ¡ z>‰YS-Šç¯ §ÎìÅ×9,íßê¾xÜ.â¿ó:‘kjJ¼  Î7U%¿?‡z§î%m¡q¿+Ó0W/ˆjçƒTë“(Ž 1lŠ ÑÅ·haB㷈ƗÔË7´=·f´Pý¬^%4Ú]»*Þh†¸ò,¥ ‡òÕø­{%¨ãÈŸtwŽ{¤ùtÕ®µ§ø–`w-i1=–Þ‚W£+3"ÆL‡·:Ú.žQ£—ØK`yBA29 ¸‘­«\¥up®þÄ¡^¥µêæ<ÀPtÝ)ê–;Ð=üé˜î÷–(QW«¨Âÿ’‚xZW®£à…Êí˜2xÃ4F‡RRœ]ç»Ýv,ȇÀJ.9®¿>U¦Y™D}Œ>νçS¥zÔ¨œÇƒ·¿Ë8G£Ø ^t­O'£BÙØRV!z1ªèðó ™Ñ[¸Íz>I‘ïT¼(#[¡í=”Ø‹Æ#j"aƒÇÍá[qN@ÅKm1#ôD1/µ‘²Êqpê®1(# D˜ÏÙn80: CsÖÌ©B“WrÚ·KÇá[d†ÒÇ>i#€$†ÌJØ¢Œ‚1Ÿ¨)ê…#”ûÏ)^7©zoË!Xl'”ªŠ”Âqú1ûQâK¤cφ‚mºˆöõ ¶Ô¡QöþŠæCº¦=† ½*_G¶Å‘x”㟦S` mg„lO¶ÑIaæ{[²„£ƒÄȲ B÷B•ƒRƒÀìGjjz©kê¶É¹À)¶ëœdœ‘/»Ò V^kô­ê ÔX±ÿ‘.ã­$]ø#äÞDo^¨F9oEŠ!–pS©,Ìõj)أ㑔Tø_¸úü¢?ep/X4£IEl„s]Í®ÈëöÍß_ÇäÆ-&©îÏHéÂàtžñ-rÒbŒ‡,7 _·7á¯n½šèyòýøn»›c×N¾¡ŒŽêÛ)f›3‚möA_ÿÎ+\Ž\âOt¡d>µüšÿ{æ,Q¹Íø\Œ¡ßm¢½ÛÛ@q!½dþö“`º¢éštŒ2×ôVÀ½%¥!Y„ª¶BB(§Šå›^9n]3§s…gÃ9tü÷Ú[‡œ©WÁ$Ø¿tî­ Ävy„}µZ\zYõqnc2ëPâX¶b¶¹”%}á‹"Xq20ýRJyŸ'’Þ‹×a’@œÐ DE(WÑG£E¸›L,}ØIf^%ÒãŸ'5™|dŸ±ä¡úì(¯Û#¹fU'XUXà \Ç"X¼ã¦×Û†ý£zfzK¡ÚåòqùAn A䎀ÎF䛈ӿÄmžŽˆ‰ì]I'8ÆôqÄÈñKÁ¬J¿ùªË>JÜÌ£ܬ _¦äÓVÁ¿­Þ ïÎ%¹P« #0X_=‚æ¿”.ËŸ¿'nJlÒÓ€ÛË¡‰~]_Àzݾ äĄ̂J{W;EjO¨/2HÇmA˜÷jK‹ýà—Yª–¹“w抢BAÑ3^½…°ÕB â7hÀ{¡Æ_É=Ëý‹ô¾î­Ç~äHX«I-`ð¦ÎÖƒ¢¿“CG§·%¿ó|Àp]”V½È ” wë~:°o™ÎƒUHõ¤?†Fîûò°]Ó‡µÛë.Ãl-Ç5½kšöt=Ñ}£ôq\0_»uXŒª>K‰Á‚Ã?òW¡Éû4ë[bßo2væU’sNŠpøM©‹êúC1¡ Ÿø¯‘¯3ž”ÓUg~?ã}n‘ÎOÈÂ'bÔÏ=™"Og|#—3“.VŸÏãŒ[ ï«Oð ó>ლñ›€‘GSuéçàõw0·‡B‘þ (ñÒ×x‰¦¿dzRåM©j8úˆi/á/ä‚»õ?ÛøýÅ[´]¾ÅE“²';{BHìÔý EñFEûà€ÅHø8Ĉé»™› µÒÂqXD¼á-éÖ-ÝéF•ÖæL·û1FpÉ*|<¢öVùNÖÑ’qí%gÕ¤yì›XPÕ¨ßßðFô’>}U‘±ëM ¶…ÙWˆ ÅÛ}Õ7Ñ}ÈÛI_ý©eh{1cHfö Q•„Ñ+J£%Ù‡Ãø(y$KsÊÿšeÃo-4Ç…ŠoU‡èfØÿz©¡icfÚpp%£˜†5¾Ä£è|=娅WÖ>E±Û[A5érñùyJ–XHþþGF—{pŠÊ jœ=q~îyè ¥ xº¹+v®­#®ÌG¦ç©:ªHÒ2h-ŠôÞ¥÷Kˆ× é#UxÔl ª2 '#öý{κÉ%5õgÀ¢ÞsQˆ_‘ŸÕþA—y'Èw“’EºPbñ‹¡=6çý;  g,]t0DülR¨ðgžêû*[…òšz”艭¾o%búãÊ¿õ ೫_Æ'v@ý_bôžØJ­JÕB>Fö€öðN;Œ¶#¨aè뽽ݒ-_iF¾Wï«4f®‘"Üâëšów"4§%ê£PÄ»]V´ÁfgzxVàZM£p×ÜÞžhðݘ€…½ä[5’[üñÔú1±ïýˆ¬¦ºxâûÐÊ{Šïf¦4æƒùÄ쀼WqW°ß¶;5£FK¥£¿0&ÝGçŠ÷WÁeI‡â{“‚ÍÚbâŽlÚÅ;®M"c±Onoi„"áÀ_UG×xXd:ò…±?…W.'Ã’û üßoæðó”ßMmÉÙÓ«¤ÆíïWAU›WèÀ?ú[’5R1‘`ZÝð•3vˆ&a™{ÌŒ$µkCY¶¹kBl©Jªz%5ç .F–4„>üC<‘…÷°ebñõTlW ïú*â|í^Š&<Ç¥w{ž Î?ù¡qN«¯â©v%fbH!ã¿’œ‹’Ìpk^ 1ãÐ>ñç)pr¾lË·|ì2ú’Ž$­¼¢DߎcÈaºâHÁ£6ïBÕŽl»ù‡o¡L´…[2` “þÅÞ®’ǯ^þM-E´Žv/ÅB5§pеnCý•ñÃÍy´0„›±ûÝÑ ‰WaðúýLS–¾¶0¦Yœ zg/x5ÜÉmq²Ðì¾0±’"ÂU.xu×ÔZòÙ'®›FGëLZ‡ëJ³+U4:]3 ©·¬rÇ×HeA<Å3tYßuÓ[zÆ;ïg•ìÿŒh/8©{§Ùku@â®ÌÏ#ûûç†Á¯þ´¥UÜÌâ¥ò nÿû÷ˤóacƒ¯s¤œò2£ý>ß;}º^yú¡"ïš¡ã7D¾À§©¡ã¬Yj]Ñö‡ïêÌdž©FwùqzMG×gÑãÂôÁJPZåòs¨çe‡"=¯%)Æ_yØ %r:v:½MÉY”ìÎç­øû¥ºåzõsÚ¸·ðˆÔeÊkªuË®ÛEmy²K¢E•k•KŸ¼ ¶.fš`¾¾“ ›rã¶“tDm©Ü[~à¬P_ÇPêÝЙãêáŒöÕ#â“Z”“?â¼#i@­‚"qÐÿ|öÛ?ˆ–"UQ¹Ç㕪õ‡ˆ·RÀ¼SJþS…ì~$JUäÀ«Çx£øÆAg´ó;‚v †2¿ÿFü’»m\Á>¼¯! ­€í)‹þÓʹ`pjXÙen”šwåQí&?• zM})ªe(rûß_Í»Íá÷nQüÂÚš³U|"š[Ÿñ ЯlŸCV|<Ê-­¨nÓ«G–üÞZ@˜$$}R¨ÓúÇ<ýççõŸß:kW åìŸ#pÚë¼þO'ä§_ØJM#.šŒ¯¿úÝ@ÄvüÈÁºªÄÔ»º¡…ìF<é×ø>ärÏfQÑÅÑc*¿¥ù’º#[/ÁÙª(Pý ¸¾ ‘7…Ó—ìñü^½ãã ¨ò„¶¾%[c=¿‰Ú·ÆR)çiU½ Ø¢âU΄°gµøÞš¿–ôÓ`ˆ,c&§öK—ä³(*_©"Œâµßøôg´ôÖÍ–D€}… £f¯m¤¼Ã0?¦GᄘÆ7ü¾á&ù­{ÑȉΒ ”Ã@ƒÊ½&µ}ŸÌÓ_¿XGBû~YÏDâ|¸+ÐW!-:º^n𰈥B‡ª8)eÄŸü¼rvôyW˜]å„{&œ`r²9ò™%¬Œy™…w×$u6¦<¢Rõh(¯Ë—îYC»ÆU§# šRævd+Fì^ß»Ç=¯[BVå0lÿ(ÌÔ l]!áÑâIuœvÙ‹)'-‘½w”²­éд(—œÊ›{G£Û*%¼w1à8ÁûÞñ¾œ™´Þ y¤OúµwI¡Í¢qðñ|¨ÜÄd'1ÇÉ`/ภÐ{Cª”GñÂSœ®Ù‘ÓfESèúˆ à]M«N™Šì·\½Šõ>‰‘ç löÓ9Y›íûV`s Ò2ùa÷¼s•˜]Ý:êMØO¯ÂÇÑ2_¾0ÂK²¬­™úÏËŸƒÛž&£l×Bk “ôakÓ¼´Ê«Lòè|¯ž±g‚ÿ×VèæÆŠ ùãµðŸ“i8}H >¨ýŸ‡ØÏ ¬ÊÊýÇËþ~¬:‚–˜ëdǬKK’ ‘{ÅM—¹Ž°;¾“òŸ šÜHa½Ý[Á }¥äýÇÞÉJ4òp?ŸÏ+Àn®ÓÏ€¡Zÿºay»â«W$|V€ž½ä•wÀ8HKïÑ2°ü-Õ——ô2©»4¯‹4û‡ûgHÖmî“Dk@yÌ2ÂâÔFsçªíâ´¦‘€ôáÿΈA¹êž Á=·ÓBÜȲ^úu–Ök¢ž±Â0oÖÈvà|Æø\(z~ã¢í}ýÑ7¹’3m}k– ¡í~ËúT4ì3±åUðtc Ÿî-g§xË%åjKf$‰”/—Ô‘>«?¾&^—ˆTó ÈPëòŸ³z†Ùs=z5$DתYB“l¢Ëþª_§?P𛬮É9CWäêï¦}ŸàNèÌ ¶Pj“$¼wpù#¨ˆâb:° ÀÇò',ª¢ƒi~6Tì'±ÇÕ†¹‹W¨½~Øœ¼Y!ÓS;˜–ÀÙ‡4&ˆÎû@åøÂãiy4'ªp] ·¾OÁ´ mỞäÆû¤!{Šo¤_΋)ìå$¤'®EøÐ5W¸2a©]¶.©’§HÁKÞþ"ñ%Ôf…>λ¬øâ .c)Ëš2Àx7ë÷Å’kãù'\V£äÅ2Þ]Lâ˜z·¨î…m¾²µ ç!6ô¤ä´ØO‡ä$gžëPüŒâ°þ ï!.^HÎL‘PÞ‰‹ý?dEè6h<‚S£Ã%´Ci%îbx%ͬ]&>·~`ê!tLN•ïøÚP@©ÓBÿôÇSÂËÊ«ÔÑ*¨r[bRâJÛ$†úâN²d³¡<ƒà÷AÑ=¯Ì÷j2Ê«H#4’Pô?2…+àhŸiWVçˆîRÿÒÊ׫¥3 ËQæs`ÔÈ¥jzqäÔc!Û½ÛÛ4oŠK†²(¥q' ðsP¾càíÉ#H‡Ë¢Oð^…Úè±yøúXÂ&0k¸š"÷F¢ú}I§ûÚyÛ~Í÷©pâöÁd¥þ™ÂŸ#‚ÜZ÷Wqc1“Äòór7ü¬óÕ,:tô£îÑ¥‡ë¢ÁñZ±ÚškÆF£È½Xª?/óß­†R âöÛJ/=Áµ® Šœs†ÂºË'_¹l^ú›µß;7Îéjr7êhí—ôp,hjÙ1íQ¾nÈýÛ­oÝnU~¶š"®n¹Æ—•Ùú”)i^™C’â>o¬Üf—ñçÂÑâšeð¥Fî’æ}M˜¼÷^Xç+ÅO7®KæœÞаL®>Ô¹s¬·UþJÏs»8?;ØFÍÆg#ŽÔÎ^ªÌd\ôœ=[ RäËæ4º?}Åö^CÓ¸>~Ð.&šî']šŒå5´¬±~^>åïó“ÝÛűwƒV¡EάrqðLŽ-Ÿ·Êà42ôaoÜÆÑÙ¥ÏàKPI®È>ÌÅ|M2ZbH¾œ ¦5†õŸk$EÑ—\ƒBöýóD¤Ô¾EÔÔN[}g£Ë‰¾W> &ìäìÏÐঠýçA¾oèZl_”è'ºJÐù´÷)ÜPëzŨjÂv ’5ú—;*+Íp?B4)v(€Xß%¯¢Ä,©.p”X¸bp#Dí‡r\Û=T†Ö–ªb4>Þ´ •÷µß‹’¼0L®½äOk¾1S)+Q) gÊ>!õl _,V«»)_{Z@Ug½DY"þȦ[„Çf6æ]ž`D¸1íÉy%6†œá!å,™twàXY?’êÙÞ|Ÿ¾F´®öLÔ¦#n@0®!%Ôy$x^'òÊ?šOç{Õ4vÙBAv6Ô’©zAV{IÝ•N ¦pݬÔÕ¼õ=þ6¯«¾°¶æh€/I_è}žÀÏÜH-ŽÎG€‹@Ÿv•ÞE{qUwg‘3µ­éç9C·~õtš Ÿïë°‰ ÞÁÑÝu²ß™­Å&ïz”ÁéøÐ]š´,\ìóåQñB‘·ƒør|"m»ŽúüZ¯)S1'*}¸…;„¯ ©(-'y‰zŠõìVI4D¡0Ôz‹øÈ"Oïçnóo,]dòòAÄ ?uaV²tÜÏñ½´o¢ù¢Å €[Ùéç¸ýÞóQ¾[”cîtŠI¿÷5DC,·uöC–DôQì¡Et= ;·™¤!â÷Þr^­hì%qõq ¸ ½7¹Ò”¨ªÀÇ¿UЋšé~mÏ´ç(&ñ}„¨ÇyßLPú*jæûóò%Î0hÄhtýJr:·&c(éy]º¯Ÿ}îCñ(Qüqi]­«ÅGô­9Žß.L2à7Hä©âë_ìÏ7¾ú¬…®Z20Ú«÷­Ú#vÅ?gŽi‘Á™±)ÅŸì6†Žîª]ÊËûyh¤d1iRl9FW'5ýñ5|"t쪰£–°wàìX˜Ã®i¦£Á…o&[â®ZFÀ¤g¬3|›Ó¾Ö+W™=ÕCFÔœö%¥Ã3;ƒÇ0DsÕv#~¡ÿYHÀ]'”Atý— ù??ù¯ˆƒ î,ùÝ¥1—d"G~eÉ‹æè:tšÔcS qa¸Â|¢Vúgiîe{NÄÅþƒ«Bl0‘-.™þŸCp2(ìYë¹è‚  ×Þ Õ 9¥Qªq¥««Å‘<¨žÇ…¥K@Ͼ+&i æÈ'bnŠ%Ÿ¾³Å ¬ØAë¾'YJýê–¸@‰É­† „-±#’FÃqÙv¸忉3p]q`œ•ó² 7‚“”Ú€ãêþq@Ù©@Vß5ÊQî XÏ#„È–`oX+}¡ÔVf…ãr[øy, ¡¸é.Ò<#Ôx?ÒX|ÑËå{qH_¹h˜Úï•ïæUl<‹8¨ÛùÔO¿-=À ÐfÄáàfÚbI寳)è´µÄóUÁj‹œùÇÉÛIÙÑÛZºÛJçÍÈæJÈ"½±5¼<<]Šxöð Æß÷‡¦Þ…V’U•@®=½~yhQ–a/ü‹Û÷NÊÎ,Wá‰|ÞJ¶77•=dUæwïHÚ À]ÁžÅÌ} x#ÞÑ¥]¢¬‘4†XÜÍqU”þóóô?“šäˆ&h½ÉÅm¥+ئˆ´Â[ö«fðÝøÀ/ñÏ&j„V]Ejµ]¿ –¸D|–ä7ÖmzÄ—ÑrsâÉ?½ªM£†-%ʵð2[W¹(ο6oDÀ…,ž›ôÅ+<\3–¹%r[CdHìÔ¦ƒg ÆIىܾ]Ÿò.$× ÿ ŠtSÆU"ãæ6¯)è{ëç–FˆŒ‘©/"™¨¦pV˜Ö$ûœI쉄£§žœfÈˆËÆº­•b‘ªýªË›©O D³‘9xæü:ÖìÖÄEö>ö¥¦Z›:æ"K,•<¾Q!ÝE{P>?¤(f%©iþÓüê?èJ,sŸ§s$T]fiød­òÓsœ+Z#‚ ¼c½Z 6œé=&¨s×JåÃ¥`žôÛ>E¤øY½˜Gç„- ÏœóQuu›Ò™]ˆZ:wvÏá·Å$>´w %&µîé¹=ßÔO¢¸kêóSÈZ–Õ3r=´ÓÂJéCxI7]-s¹¦÷Ž8h=ÿ×6~ŠÕrz•í&sÞ_Y{AoW b··Â5¨£·ó1y"Â3Ôñnx¤ oúA>Agܾ¬»8ÒK0-¨(˜ê¹7ÎLˆqt¡“î-¸õ¢)f+yÑÁp"4g°4S½@¯¼Ô¥Q}Ô¢ 6ëêµlGé$í=Æ™ÌÒ¼ÎUàŠ5Ô9~N(o[‰žÜÞ+‰¿Ct ;=Õõu,™À]@ÀÕØŽq}—ܵÕÖnŒð¸ÒÚ]’w{£ó6ò8w…ø²é‰öq2Á‡3zfm®fÉ–-Ghõ*÷·š˜¦^¹˜ 4²×÷Š›¡òx.™Îö¦‘Ö=˜F¤Þ=’¦¿Hïṿ¸–Óz'/®_» Å—UÒ’`,‘nÊ$4½µ]h–Ç#7)a¢O¶líþ.%iÔ$÷Pdë×1}¯î¡SÀj [“pgÛžÍby^‰%Û7:Œw²Á¡t‘mé–;Ž@,KáÈNõà¡=bzìÂW ¯ÜëJe$QÁ_ZÌ/¦FËçbOˇ[?¿ù"À‹„xpˆÐ[¥;%ðýƒ¯N.ïH@rÀ"ÞGnÍs‹RŸ¹7åã…ã9w¨òù³»£ñôCßÓ¨Z4¯ÿ>Ôr>I;ô8‘?3¨$øQ× VçÑÿ1G_@[*6ŠÁ ­§^†Ù3Ïþ™fÿý#‹CTY‘kI_ Ûƒ[K~p#T”œ«ÑmúuTéx¥¯"rÐÆoG [bRžø% xГÿµ†\`7Aà8¡0žÍÒ{·®)A¯Šë fÏÓÌøž¡Ã“_ Úh´ÚÔeGW'¦6>nÀÎÍa©¥4F—”ußËï½Ë§Ò÷~a^x 7ü.=çü‹§¯*$GØÆ¹~K¡äMúS¹zo¸±þû1ñÙb\LMeÛ½h›}ýn~Æõ á|¹TÒ›r¤ë5;Òÿü\ZüŠgä°ì],îÏÕYM÷A“yQ­Òu³ h›¯³HW½SLg¬2þ<•£h[4ˆh±d‘{[ ê‡¼Š¸!Ó2‡µ*™²ôVU´šêtq˜¸¦Íù˜¤œàx{9£JxLæìÙõ."—Ù©žo*T¸˜bâŸ'á{Ó‚Åæô7ˆÇwPËwûäÊmy˜…(Š;ðÁ_ ²UGOór°¸Ã)i¦MÀ¨Å.[UË©%ÛU¤¯ 0Üe­›9ämÌÓ&ÈI÷êt‰CͺºrGN|ã_'$ãYX€?uQ=¢³·Å/.Ù%ÔZ€ïÎl¤¾kJÐÖ5µMâY9%»§[-g‹¡t²VIŸ‘ªLO¢SMOt-*åÿ ¢qW|¯±]UþŸòWOkŒ ˜®Jr¯Ð‡tà·¼ìcT÷߬¯üÝŒ/YÚCBÊH¯/9¥kâ'T±æm?C¸/aã‡=OÕ W7ˆ´P`Ñ*Ýd+Š”‡é=½®Ì²”[jñMÀ•ÂñðF8æöTw…1D+Ú?œµ»E¯³Ê[ý‹q,m9“Ùu³úZþô y¿dqH†&‰—ê‡d]/ŽçŸ¹DpÛ?ŸþÌýæ„;N¶èeDŒ&¡|ZXýs ôK^™kBnvu©À°Sõ»®2S)8†-ÐIVxcÓv †$Iu8'dÍOÆ1ãnd¡‡püÞvŒO…G]Ûqñ(Þ¥Ó–™χõÓýPP]½ÇĽ&6LD¸Â;*k‡[8$æ¹)›d´nØ'J+²^&jEØŸòû»O£Ó}èB]ßøï²E¢wP›P‰÷‹ùß•„1Õ\iöô3íE¶ç VúÂb™7—ÞÕ‰„v{D–÷Þj?¿%×:Äã$rÝ‘÷ý$!]¸,+â®fÉY–{· ¢æî¢×Yoð Þµ¾›“E®zI{ƒ5åÅÜ:nÄ(S¡rVÄÜ|EÈäˆjûN2ƵoŠùîÈk•ÈÌüeësÜ}Lp°V ¤²Xÿ›"¿?§ú˜>Vç÷'LÜ-‰NχÌÝl¹¥’Z²­„+ÓEkoß«„b¨:.“÷’šy•£T4ߨbð.=¼ÕÀPY —Lø!ËТÅí"¤wÊ™3°ëgŪ£2'³HG¾(b ŠU‘Çv ØßùPA`ÒiWñäºñ¼é7ä’J4Þêi"…Å«#´‰­§DÅà™OÒkL޾Ȝ 5OÓ*ØKp&å “ÆoyÛ¥B5úÞöí9 x½¾B¤"š³C64Bup7BÉ1Õ;r—«È㦠EãêûÔ) êñо[ÛÓŸSXq—Œ¸°7)FÏ}ñiSÆ &‹¾?¨ó pøÃØj¼’b×dx ^”…1èe#2[¬³‰ˆé ¤Ž­uñà”ƒäܺ=×ͨ0ö-…—+‘”ëG·ã¥”Œ™Àý|TU·§þ0yååöóñŸÓ.ÏY·úç-9è«ýì@¨–õ Ç¢]ßVéSYˆõ㔹\“jÊ{ùß”Ίˆ¡. ÊÞX½liüt4çrïMæÎU’b'³ëÏ2þþDÎìòi0*‘?¯ÁìÜéŽèÐäqËøhüˆÄô#§]5š²ø¡ÝWûèÒP¨?<­-UŽI–ÅŒ!ê¤[ÚöÁ8ç,çʤŽÿœqž7„(°&‰™Ï‰3íi©ߥܤC¿ /~AÏ8q0œc¯£æ-Iú5ð¡mUfîšÌ»¨?Hz”e³5÷yˆg‹‹…KsVJdïÒŒv¥¥X—ºHÁ»i¿ÉGÚÍàVÀZ;Æ~(Ò éÜ@MºÂUº 2§ôÿˆ¬‰÷ÊèPÿcôä…šïˆ^8jó'QW6™“âî¥ðèÂñ¤~¸ÄòÕû=Ô[sÌ÷Ï{ MkõGé˜ÔØk¹Mƒ¸ ’Öºö)€ŸìðQ$½ãre`Û¥Æ0Þ¹ªî¤™›Óâ„ïƒ_¼¥0€‚ÉnÝ]´÷SÈXÊ€œoꩦ¤íÄ}?œ.ô.ḇÀÎWq~þ ´aKoo±¼¥–VùñÐ1³!Û# a+@Aæy=6ׯ1Ç'`Qüøo’úÉ-nVîíðâ•X ø ?;P¢ªrÔrôvJž>µ©kášKïA[Œh7gé>.ÌÎF[bå82¡m>«X\3òf ,¿ÁÚ¯ðÝ\ÙGv:XaºŒ[ I«OHöqc«5Ï5ðXAj°Õ>ãnPzZù‹:NÑh¶OXë­Í1šÈ€ e±=Ñj™…ÔÈVÅȆ‚˜^±´ ¥ðR9RÚi³Gæé²¼›.©·ˬçŽó…g"‡°}ß²0ɾ›·<ªæ¨Ö@UUÚ‡;'ES3i•Fž¯ŸÿíÚiÒ¸yºšAèbtô3#æµEF웲¼µ4nÞÊ‚U’ÌÏîûCÊ-_Û5žZ±·E^ú„Ò Oz™µ¹lÜ’-¯Ë9¸Ò±ñsD(g9Ã…yɼŽÔ ²éÐ ù Nm«'$ Öª \ z ˜»wo8µå½Ñ×a\‚x×Y"& ÏÝÖ†?‘r¤Üd`W"þ92ž#]ûª²à"hÂÒùœƒTå7š%,IÄ¢¢cÖ’`MšLGÅ“½‰6[úq’Îjí"WF‘7KXà'Gù1ãCs‹«Ë"¿«Ë²mÈÊÈ—óç0/và!(¦DÍ•“s/­mX+£Âäñ‚ŸÑÒÖ0ÔA³ ˜¥¼i§Œ¬MŠ à[¦Ú–6)—95Ñ PÔÆ"ýìêÛ=Uu¯´? E·ž jßé(=_Æ×ÔümKõîUPÝ3÷ÖLëN¸þl  r‚§Òÿ>À²=·’¿#^ÇÕ[â›»F ñ¹ªâXj»úÀ–N-+Ö2WRóSdDõ‹™=EíÏ*'C½ÅW-³Û»KüZ3¨ŸMÿã ûã1:S<ö¢ÜãºLbç«–“{È·E{>å¨â\—+Vwòv¶K|ŧw ìýËAãøÖÔÌÉc1§ì$ŒŸ÷<ëè’=¯ÿ4syZ¬».þÕñjÐ! ù딆i=I÷»W€F8ù¶&jq•©<ÏÚÎLÊ çÙwLt^=4ájVfê$1ø}™`àô®# \ÿTáI¸Qÿ·?/úD5üh¬NÖ° #¬è¹"üü‚êB?îGaþC^‘WwêB°¯ô¢â©ÙɃÜ[œ-Y¥}„ZP’ÞV€…ä@¹÷~´–\ŽbÏï§JQŠšvȰ©aìY2X¹obWxÇ‘=|0‘NÇ{tK ®Z¾1ß™úši65?¶·q®ÄÛlíe…ÀŠü‘FRãu”'})§ãÇ:ÀAÐ*Ní™àÍ>$“Þ®zà9Ío‡³±ÊàÒy™¯tòÛÀÓY:.¾ð?”$ÎÎ]·6«Ô¸aÜõЧ–Æ[^ëîG+0 Û…ÈXåÂä¹ÉÑ㥥lD¿u(]"I»Ï‘ïÛ%#k)ržõMBX¤‚éù¤‚ˆG¿ÏµAy+ô-wášÌ‘ôý {¢8B4^ØÒ·ÄøÒÐðh©»l‡¡Ð-ñ=•Œ*IîÊ1¶¦gKÓ™· ÍŸ|L£Þ÷{LÀ=)ú™HKóȼ“èm]ã¥Àøf±5¬2‘ؾwíòJ“?õÏKW‚ÐOONTDþ­^ a…DLRÎUKìã&rôÔKÇ¢Ãy}œ§ñ")¼ÓG*El»&3Ψ‘¼Á&Íûä±KÏâθTŠª~5½fÄ´q¦ƒÎ(¬ ,F?ùÞànûúñlY*óéV’¼³$<ÔÄÇ_*Md¡üD¿ãNá™-ìfŠÆ|»¾,díÝuÀ,‚ì'}FìsêƒB7O4}ëž]öÛÏG¨Ý«(I»Ïóä8Ÿ\TBØÙÉŽ<€†q¿¶®CµÔ‘ ªhú_k0It`ê4d:'8*öjmà0q«„y$ýk'(¨–A³ÐIt±SvººV>ç»°±wÆlóùyEh‰¼b0òÌ官³ß™q‡L†„sËÝ’ð›åVqÎNœGÝ)yšöµ±Å¦¬k³O\E3ó)y\™0 ÉŤ]•ŸI…ô¸ípû®Ã¸´L*A‹°8}Ò¡öºZöö’´«‚ë94om%rñpŠh|‹™Ä®ä k9™,±ÃvÜ~cxø¤Æß3ŸêÄ>s(¢'dÔ©n àŸ!’áªôx]¤N·)Û*:k¬ÛTðþÐÊqƒ…ýñ² ®œX€F–N”ü:k¬nUUÙi‰¬Vhú7Ni®*ÌÓ?:¦'òÎÛ‹16rÁ½Ê—ì@,Çûfœ£9–T¹ŽÎ;‡s*üýž¶‹i\ƒ½ÿ{“:Ê‚ãTéywäš[} O/޳|îÐÚsýiÒÞ PÖc m}&‡•«ßÏK íT\û¿ßÖW³2ò‚EyÚ¯¹&+ÏmIj6A²¶XÁ´59jÍ6Gx?Ç®ëGÌvqç–@¬EüGÃ!»ý²v‘÷õ;"!%òUgZ*¥„zs$8Ð4þqàj¡mïõÑQ1_¯†b…ŽÃëHEÉkËÆÑÜRÃú;âz”V¾ÁRô€?b8ÕÅë÷¦rÓ•žddÑ÷‰6mêt7I%×àØÛJ§{ÿêÈev€½§ßbn]¶‡”Œl¶æÑK¶-=tèOÀ"ÙÿtìY„™>$ß4«ðÓÜó©´éëK+Ê0°o²6µ ¼þõ_øv-{&Cv2%Ë€ÒÈnòV°Mç«#ˆêÓÝønHG h75mÛ–2­^9H#ñ¨v{`¡¬)µ•à#”YßóÃñ}¯a*îy¼øKƒm|'í'M¥ÿÞlé깕drç4 ’9ƒUߣҽjŽçJÛi/öîR²UÈ›T4:û’œ2éò9Ã"ËÉiæœÉTâ"\¸*§¢wñÊÅ›qümÙ¾RYkJ+nÝ]ߢ$U`6•„P$œ·NÍ]iV»u7öë…›±Õ¦ÝøÂc+¿Ç4e̘Š(Û¯W¸± ”Êô*¤‰Å– Ž7Á{\Zw?Ìä…zù:D)?éãÕUÏ«XA·VrÇ™ Nô3½!1ó¦fJM!FŠˆ}¯º¡‰!ÿŒ»âqW é=çxMj „ÐS%ïÕ‡G•‹Ud-4ï*c|zÜÿ>Mýy— µ¬!í¨’ÄÀ$`¯?‹ùï+m5pK:‡~/ßj9RC|÷1²¾÷iÈ Wà,Ü>ŠÝwJl´¤6ÈñqPÜâ®te2ÊöÚ žx“‘Pýé¸Y^Úñ§®ï"Ä­ËM]%ròšô;o@P«ŒqFÊH☠ÉFE4t° óÚýÑ]"œ…ÃzËsû”ŽÚüZßÚqž.§ˆï媒‘Îe;E¢ÊŸß,8î«ð"ð¡à?ÁÌyEÉ×¼ Ós Lª«œÐ#a@5Áµ‚›yPwûk•DAWqR«œ}¬[(qƒ²à “POo?o,RvPÁUu‘1ÉÁH½£žr¼âYtÚ‘Vsª.s È÷½Ô2xS+ÊñÓ¤îv`ÈÔ=º/{ oÓFjUsy„P)DZ!*aq`W‡aŽc‰-q«ŽäìäîëŒ[ÑèðX>¨Z§ˆ­Ìml©0×ËÒñ&”Šé<*{“B<ás Rò²¢"sŽ10sÕA§"g÷%~ÑT¸wYw¨F{,×áJ•‚>!ûïí-Å\œIkI©JϤzÛ‰&Ìôãè¼o‰Ÿèèž.¡HYž¯¥Ä|]u³]=ƒØO‡a-²ü~ÅÜ®.6L …qä9!2,t*¯‘T^“›¹cE1]ö=>‰ˆWCf±H§.™.ôþ¶Ê±ñ´í#è€TL¶ü¦Â).òCƒ–³¤‡u#ž• 0;t „@¿ÒÿZwå…â…@‰³(yó†FQܵlgqæ¬h$Èú;ƒaRÔûœìs£©9?¨Ý»tXœ »¼Óžÿ5±ýåfk™¦„Ç#j{.jß7ÂÝíLk‚Û¼*W“—¦”˰ÜQ3óÞ¸R°nÿ¤'÷òªå W-Õž®j¸‹'Ä*|5iGhdóJª£ÐIöÆKDv~bµ[M…r“@¤åEç?u¢e_jÓ.’ÛùéÀF¹¡Àc q”ÌíÁʇⷋ…cM D[uUé8ö·H¾ýÊ.Á…¨ÈJ1ï°«e"`>c§&õ’Tðf¬LíÄäêZèóÕòô×´P×´‡òéLጡ«…µ¥®ây—ã£ô ÍNUÔÇ'’V…J7ØU²`­®—*8å§´ªúÂggC¬­2aAŠÖ¡Kê¥ü`ÔûSCå 6«×iý¹Êf1íJA-†“ZŸ‘ÔäZXî­áÄÂã$NÔ¶$íWÙh¸|¿â$§UmbᏴVÆ|£ICÜ?ñG’÷R“^ ‰ê½­ÈЇLžÛNcÊW§×<ÍC&D†¾+itWÔ.¯Ì |…;¶ ÜÁ00F(Õ6¤?¬„|]e½—±Ÿ«Í$þxŠpùu¬ÞýZÌ@ÕA?c$WgBžÓñ×…’)dê Ê’Ú|ýæ±ÌR’+nÁð™$+‹ö÷ WT ¦,¤ý½ »• €oM±ŸÁpoe{SQ¤²CÄ®@0½ž¢gµu5²ïÙYYŠlÿ‘ËÁÆB˜è1Cf3»å‡Kãúöó8¾ú§|ù–XšPމàj“­ƒV$¹›¾w)~\Ô[—üœeåÒÏ•~Ž Ç]Žó®%÷"…ÏQ:4Žé—; GÞ¯,Q¿ê f‰·Od)„d§+W(&µ’òº»s~Ùé{¥V”t©f]{Êà†×úñ Ë×Ês.j~ŽdŽFkÔ©Úœ»©pç¨`§ú†U˜Z¥x¥€ÓÁ=ºž¡˜Rê-2ˆ¯Hš®#Er¯÷x ÈÁ;pþP~¾± K2@´îOá öÍŸÜM9zôϺà]Á×Jý^à’Z× ŠéÀ—ÂÓ}àøî#nÀ¨.ð ªJ&&)㪤F¨:ž$ž¤‘Žã:¤qvô&³Xçßð«Umx–Á[ 3qiy•ÈuIûoˆób@KB…4t‚S·¡Ñ³Üh§»/œŸ¦âšuÏ’ÜhòƒÖ:âÓ”«vêÅÑÕÍ}óH.OÙ8$ú­7ùl#qhéJmh!0»ÔS²/¹¶$Ÿÿó{D7ÅNäV‹׉àð¥ߢ$$¯-nàAÅÄÿ9Õ ÛUÅýN-žGÛ&ÚG](ç@ÉwSut–èA w4[Ö¢‘Žu´¼?§í÷÷ˆ »}Æ¥o “ջ“´Ã±o7 ùÅQ"v˜¹|q$)á×Úñ)=OjÚK¥Æ¦©ÙUï2ñΙj%ˆ¿õ)¤ t?ÛßÄ4^“¶«qækŽ ˆ­°7ý§7KHZãȱD@þ¤Ô¾›si#{Ö)Ím2Ø”}£J)´‚‡nªÊLèHÆÓ§”Q!õ"­‡M‚|ª`Þ1#K¼H€ù‚Sú¤Fì•eU¨¢q厒¿Y#¯EÙìpÚËÃXÇNÆ~ØL¬ê8±ô˜!ôßV{¤ ›=’P“og+ðå¸Í‰±l™fϽÈ=vØ›xg=ν+UÊ-í_ ~KÙ–TŒ°<ši ,öÚ÷Ög-R¬JÁà™Î.â…Õ8²­uV[¬ÿ{P$ êddd× Íp€õ)cþw[ßž÷'ü•!PuPâøs’ÈS~;/K–ŠóÒŸÉõÕ”ÙøÌWMë@1…2äÎnÎ j“ôyW¢O‚ ¥d»Tà†ò‘vÓò …ÐòÞì™ @ˌDZS_.¥våXÖÉŽÙçö)Aç‹Úb4úJ‘”~Kš¦¨!½À š¤Cî¯U,+Ëá:õc3¬’*ãqνbýUz§ÏÞ+¡C%‹Ç ”ýØŽ:2Íwü @é‚Úç•´Í6oN¬èËÊ\äÞÝ9n(¡ëb‚¹´'ÂÒ¥ÆóÂU+ræiRôk§¢9º¡ÿØÞ×ýaûßÇ Éë;9[èè/µƒÅ–‹ ‹+Ÿd=·NÓVr\Hf,³ØÑS¸ µ8·!‰Ë®’«˜"{»Þ5kB£¼>“†5¸KÇíÙ-sd‚ªSå~@ë?è³oÞ#¾W„yØ2xm Éýž ¾|14;±"Œö}ßrÚ˜S˜´y–³|j¬XùÊkÚ¸e¤&ƒèBÃVP¬ÔS@¹)¹š^ŒƒÛQV¹Ã64MË4‰0œ§çã0†G“zDÙ\·´’ZGªšµ_‘T\ÀAsj ½·¯aÊÂ¹ÅÆ›Ðéh°ìÓ’!¯¢*Ô‘ãO%u‚F7ˆñ‘„ÎÁëT?„Éœ»T‰b¯)Ýw²ÂºDFºgåçÓ§îüH¾îõƒ8ƒ4>&Ê7ŦôN¤GàºbˆZeÍW¤‚…¶Ëèsu¸\®BCdEܤ[7‰kZ$‹4}–TóMƒ Ÿ‚DõÜ]’#8‚¡Ït±ïߪ~·€ùã>§½–Õ)Ì=àÑ|®-qv¡Þ2YæÙx4ÃVÉ> –™–~*Ëå(Þ"wÙeH)`ˆ"uñ3qR& ]²0š V§‘®;«“Œ ±V…«a*»²Šñˆãzã̾ÁmðÊ:AÝbŠg&Û5·îßz‰×%³NêÇSr¬î¼ Ž©7LS^‚á³ÛŠskÁY™ØÁ˜C ÞÉp˜;GE9µ¹N\‰+5ó\Éf ˆg#ã±S‹¿ö~¬t»˜ºÕô±hULœ-K¸O—- ‘ÚE ”‰²õ³(XœE„™ÝüÐz+ÂJÍõŒˆGcØÌqO2·…ê^-’¦H×ñ ‹³Ïß[­Ï¼èý¦Äœ<ÐÎFdbUJVs¤%!Õ””@{c 2? Ñ»éMKÝ6‚´IÏ¥YƒsìcGX…ô +LHFë ¯—R¹þ…ìØjA¬Ÿa5„€]*;ƺ®KžG‚ߣÁá¼/a¹—6â,š*Þ¡qEº°ð· éwÊ”Ô[šÜ9¦]¿–[[LÛnšøµ4q–t³ '“îÛAËó™•w…ó£ Ž©ô·}2ÑŽt[ŠØ¹µ+hÂVy½Lz¯"Ô4u»°»È|Íã¥|\ý‹Û;Ãc5kûTgÆm@TK+yWøŠ‡Ym§ wF­¥UCÅàÜ:dfA ¤’Œ¸”*zT!51çã ÑV£ ZÏ©QŸHž7Øîî¸F2è§4ø£§¯›ÁÕ-ÊZ~@3qˆB>uk$Ï Q"¬ªQYo9ë   Ý:. ùò‹8Ò–´·ë°«„¤ SPŒ¥çëý$±Æ/ç§ó6˜ŸJN¨Àâó”H¹‹•7äj‘®æ̳ùdÕ›³™•š’Ö£Ü×\”SÙ‚úºJ–½Èæ#…¹»d¬WáÓõuÆR×â›Æ.e€Ñ¡AY9p)9¶u8\ªL'˳ŠƒE\Ž4¿kU'öNØ5ñî]~šþVƒU r£*Aù*ïâϺ93˜Qì.pÈ@îÀ© dV5ÝÛ ò#U¼ÆÞjˆpð#ß½ïfS ÓM;lÍ×Iå¯%år¿un=¦Â3µª‘¥/ 9O9ò>1©ï]Ÿæäû璈ŠÍHñ,XxÓ^™«ÜçÅ>ðq¤ßtqkR^ï’—p-ùHÀ7sÉU ‹ï‹0}-4¼ª*b;…é+»|³V¡¦*íHÌ«¦CÉÀ¬Õ®\w¦&§!}œ¨ äpf¿¸w¬©m_·ð)ÇȈŠî»Ë‘.ê›U¼‘æÙÆS–Sé„ÕOí?®Y$w"ÓÔÂÀ_Åèʉ‚®“¿þ¦:`O¶|q½ù}å%gð]ìE©AŸ¦.HEÿ„t¾?o_gð'EK»«ñì-ÇÜÌ*ÂÔȵ[{¦û‰%n³~â:@¤×˵°¦â)ð%\ >¢ƒÛ™}+Ʋœh5Ç£¥¤\ìN'åJ!‡Ô!óOÓþÝZæ`Õ™Ìß«6ƒXîóŸV]Õóû¼Ó…èu™lA5ìlózÜ®]…G}‹<¤ÛâlÁpÚj!hðõnFÞ8C<ÿc†ÐѺµ'úÁu€DµÅM:V«³&*!as: gµÑéøpnG# yÃí½1’Üر9Rç€4m‹3.G|Z· Mü´¤±§Ù2ÅÖ0­¢¯QÅ1‹sr#tÓXS?S"ZچΫ§]¹‰àçC‹Çqšôµ\õèÁÑ9“ )D¯P`ªã¯à „Ю-uQIÚæ\¦ûÕñR¬Á+kÝÚG‘RVGBØèÕÚ­Bþ¦°kCeÕ­PÝ+=–iý†Ûqa¿Ub¢åù(‡Ê‚]¾àošVðL¿î’ž;ˆ˜½W/:®š8މgü’®¢¢ãä6„% H¥òÕ.M“Þ!ˬa$墽 Ù  ¹•3(‰¥5½J UC Ö°w\ Zïô¦"ÛÒ DNªt“ÑÛY".Tˆ!« .[•ß–Ahi¹¼]Ùä=–õ}¾~V¦Dèeºr’v Jž¶â!fÀ×E(¬l÷o\6ãÒ6d‹¹Äpã[+œ)!²Ew·^Ífh }Ö¶q5ŠC co³KûÂåsÅ€à~Á·„ð•ªLÇûŠC‚Úg&dqAÚÅW9ðüòÈw±Œw-ãÚŠ¾žš2ZIiß©{-ó‰Ý¥“¿2X9r  Èh³ …¢Í4·„?µ&ܽ*ø•¢Ý-gcñ4¤¬x4ÚxÆr%ºŽì”¼ñj\º KK»îУ÷•ö>~ËÁt4 øÜî–0Áêº^O仾Ž_’{eYqÖrSÇ몴 *ÜÌn 1ª©Õ$5µ¾€9C 1‚¦:^2¬‚ûÞëINkÜ«¢ª ?S—ZýëÓïy7kqÒmôg~@«JÛžqœÕ-Ø*_œÃ]h>-‚ñéŸ}ßÁmé¸Âœ`7ðî+«e%™Ïï¾|ÖHÛÆ!ʲAt6co ¨ì¥2h›ëEÇÛÌÏäíêKpïPkšŒõ&üc]¿wÉ;=P½d&}Kg‡1ԇ܈Ñé²^ú“e'1üäãeä1*nzU®î^1sתš§•6—£ÅˆaÈëy P-k"Y;n§©ª$‚ì™ã^I:‘—yV Ðl"o“…@KÔê'}QKf2MÜÀ&B/Pa­Ë&šPÖ>Ìo©iÙ—Êû¾$oÔNO‚µ‹Üg€jv¨Q0d­Y4Tyñ?‚½ÂÙ,¾uÓ0hŠÐÓ¿îá…S'…Âv ÛÞhœzq#øìËvq2·ê¢£¹-EÉoXI216–WÇDŠ3­ ƒ[žºäÑÔ²}!âZÂòíÄ‚}æcÛˆC§› t<ÀýÁÑÍ-¤õ¨¸qÚ2™qFwªÀΔaÎÖæ €YŸ\ÂAš·—­9å_YUÄ{€Ü£”g&M-’qhª¶Ö‘h·©í»% Èå ‡t¨ZU¬K¸Ã_K™@ÀMb¶#ÅÖì„Ô!˜i¼’¶¢Ü–B Éï;…—¹b1ÙWM}wŽG”‹ª½[õ@6;âóë¥&Qï/>déT*‘d(5?ëŽ:¬—lDg°¿AÞêçyðU2«EhRt¾c«˜Q•Eºä†)9ùƒf£l:ßš’ 黀GÃáË2©i„»e¥5 ±–dÌ9€lâ^Jyâuª¢EY(n ¾2 î?brQ-ºXÉ/1 kÝu®¯ÖŸ}1B|—ý¬&SûœF Œâ>MÕw×díóië‹rgšZÑCM­Q’&ë›Þæ]æ K3ÙÜð*[ à 8¦U\ÞÞ¤ìØ«ºÎ©$KÛŽØ»‘8~ ºøFöî2åSWÚ™ £J!ËòÝÛ ³¼¥âöïË&‘%½”\ÉÌ\ûªD.r5£¬Ï9>ã²&¸YÑVc×õ©}}°Ñ0~>kßϺÜꥆ÷7û½XòX]³Î6Rroç A¬£ ~Ò-°³bFÕÔ«Iè0ZG™±$4Ì€ç„Yï ¥["ÂyæK6àV.KˆrQŠlj•IÐXr+©2@h8 Ø1MEs7Ñ‚/—C÷¤è-}[̯–xˆ? z4°?Û=â¨n®êWuÚ¶Ÿö Y‡ìÉ\ÅIZé0½Ê‡áeÝJ›èÅÂÊùÏ¢èI ÚrS2³›¢Õþ´+­±†Zvb‹ •>¨Ó[« ¶´¥AKí ڥϾ„ç($"Ó[¶Šë7¯ùÞr Èá`ªÜš£ˆò³=EŒÍOÐëCæTÀ­+zÊAÕë›LÁ¤ÐÛš,zŸµÔ?½be”ÿuâí?´jUž Ïwa͸Ú-²þaŠ#d²i«:m°TÝîDN3ù:—ÄE¦êäTÆKÈ¥Z1ɰnàBœ~ŒòÎBn$-øV" ×ÖÜnG=ºÊÕ§êû*:ã*Èt¹AtN@×]b‡»-ÈïI]/½ª¤Ëg‚ˆ* âèÏ5¥IùwGÓ±G¦¿ ß‘žÉÍÜõxØV§Äúù^é`É..$éKó×9êÌ­‹Ðò:2wµ‰_»Û’Ú3£)ÃÀ7£4õq.GÞÔp£"_ÅPNa{çm)Yæà7‹åÿ,:Púu”aÊ ´<úر¡‹¼‘ìÓ´rjmDƒ)­[¹Êµ+,S—®Õµ-«º¤0ºF‡½¡ð…¾z˜ÕwYHg¼{±-’y v{³]ÂÍ@NJ½J'¤¶IÑJåˆí\2÷¨B¼Ö’4Ó!?mäm,a&èØ4Á¹D}÷ê™P±)àY]ä+—õDLksWl1ó£ÓîQY%ô2QŒ÷–\êìPìøTm+Ù±vn¹ïéT$Q®¨÷^¬³ç$òŸ ½’Šm?&e óÙ^·ü/¦:r#=[(×“ÑøÖA¦È^è3~á»IÆôçØ‘+…;]Ær¿M(ßžV§’ÝеÀopâÔ8iÐZ$ĆèûY¾ ãX©Ó}è_v=cuÊq v±1.fAZš¢]áñ\M- QÅ3j“³ËÞ'cINzÓýÌ”LÔnHÌ£› °Îg.yIHxØ…Ø_êR”T—«)Š$³ó‡åU ›îÊJ{ö¸yî]'«<é¶è/û©½ ¡Wì5;Mh“1ٴ̓ qa€³ õ¶k¨ze1*푎Á±‹Ý3wº,§.O¹!tÏ›å¼ïBÑ1|ʨå@àU¥ªcá<ÛõÃÕ&$&™Îë[V¯ÇÆB‘òëX)W ïÎ Zg/i‰IÎÝÊ뤋Npqα@â£EÇ­î¥Ò·ÊímœQä||»· 8+-ý¬¢Š\tlmwÁ(»²š*ÇØÔÉ&Éî&ÙhX ¿¬ËÓtš OXLØ~k2¸ ÉxO)u dÚ-7D•|âg5HÐa~Àÿ÷ï{óÓ;.'´»ûÖh«´ @ŠÐýï“DðhDzXS­”µ¢­Âô¼¥»l-ªþ¶(®.ëßâ§>8ò§L}抋ÒÖº?xHóö‹˜¬€î á´AµªŠrRÛ¾pAVnÖ<£‰åGZéŒ$Ï.ùœÜW€aS­-€¨çÉ)ØhÁíÙ¥#5ðGÄK?»ðkCÜV!ÂÏp#bS¥ÑKʘª™XƒÕ\ˆù®×€FÖTüQÊŸ ”·…Ì’%ƒRŘ²P¹]¹–óyKë{Oég›w? ã\F-É9$·xÈòêä¤g D~;E˜ßze†Ú¿õûk¤úímT¹& j’v;™^]t-W¥8>óÐFûî£zsÞʱ|nA–¬/ÓHŸÆ Òu³rƒjÓ@R”•:ÝWOW'gLÈçêJïe!ª‘DTn$²¶^Qؽ²¼ùQë"v¹¡80’þ3­.—¯‹ÆÒˆáŠ…#‚ƒ&ƒÉ9D.ñ Y0z>ZNBqתw)j^6X;eGW¶ÔPG”Ó™¦Ïã4¥Ù:¾~ÖႚzСsm+¼Ò:»ÿ¢Kܸ`œ·5`Ÿ]]¨†@¹L.íÉg¯KiGaijµ,;Íõ£öLÏ^°»@51…k Q›‚­¤6Û"±Ïã¦yÁA†Jñ]ð·^?’“]2•kJ¿G#¢9Åüð=‰êL8›:åÃ÷¿ØZ¤.j@‘64-ü¼Þ7¯pi‹ªˆÚ@¡Ib”™Ò:j‹[:KÿŽ%Msy5S§'ñV÷ÆBÆO9¥IŒ ¤òéiT°]ú?‡‡÷N4v‡tdËKš'ÂÅYbu”XUÕ°2~Z}ÛÁ”ï‚¶ô¾ §³ºâ‘²QÆ[¶ XÄ©@§\ ì}e Ürü›­Hp%'æñé¼g„1C•©Õ´gðqö¢Eá#ÑŠGc¬–øÂ+ZÝ…œÄeeç¤ò æà‡XÍ^Oʯ©µeµDäMÍ¿oÅ‚ò"ü¥t^X/¹“ªVf´³5 ˆ ©d;TIþþ%”!6õ[R½gÞvOëUÄÏØF#¿„쨟2‹&H¶£äد¢†C é£# ËÆ•ðÒÃàØû„¡”q¥*;…QÛ‡¡z˩ӥó =¾w0¬Rïö!‰õÿÝUÿH»!¯IPM¦¶Wøà­^ºo+M 1_íå–ãˆ~u¦¸{eB4„shÒ»PÚ<â/yåΑ"çñ vJKNÏ«iGûuˆ µÆ”ªC½%A?]8lµ<%ºC#³~›ñHŽ 6€ˆZ²P-3PäãÖÜ4Öv/ØÎsÀÉójŠE£Â×]Z¨ÝÔ i-r8§FÅ×]®cŸ#Ù]«e?Ȳ}ôwšÐ%q1Éê^@òUU>íá“=?~È£83Ö"íÏÑ·š2L¸¦!YލÜÞq¥ÖX©gpÛ4vÝâö ,{’ÁµwTmåtãîzì 5Iœ+ùÎUDËà@hŒÿšL•ú';XV…páµOf¨ÚÉQš Lk•þqMâ¶›N Ñ6a{,WkW–òT\ßÕnù³¹Z#/QÅTvÑ(rrA|G«4~@ÿx¡>]eJ‚Íçd7xj #K'M6O9Ð4(Ççë“W©VXh0{æÜô5õŽZs®™.ÿ“¡<ÕBíKwnŠ#§'”ºxÀ%/Rè}õd?õšG¤t2lq^Ab÷5S"ÓžöcîhÄ d „œó¦~àÍÍ/:dS«ü×Ë߈½0®ŠG®ÒVî¡ÌåªÔp-Ü#ì°Õ”ʶ`аôÑ.î!)½8­·n„t6îîCMyµ%¾óÍñí»Âja²ès\úrí‡:¡® üÔ†kuÃ=8^ò­u…í$ßÏ-Ø™åpy¯ð¯KЦ^¥‹*‡}pN¶ ÊÃÞ&Øp­ µ*½xÙ´‹j£ƒËiNv=ô4« H©Q²#OÊù%%sÉô\]ÛhþP'd×>…BLÉÜ-7¯±ˆC¥wK-·*•ËÈA­®AFÚ¥·%^C¬‰…I¦Á[Œ¶,Q£3ïVÆqލMK¬ï’bPU¦>nÂ-sɘr¯CÝgéW @ãäîKIÒ¡OìÅZ ×Js†ÉtƒƒØýùÊ*J0ÙùóE&6¡^ôRéÔžJW|Úäˆ2ŠRý-[×#-H‚/k²Ô&!È*Ü•³øRçÆ% L<ùǢГiƒ{KÝ_ ÜÛ+ÖPHÀ^£Îau«!4qÜ8þÓ[~ABÃþ‘˜ÂÆúÄ’yý‚r"½­¢öq²ß¥.0æö”EmB‰É™õ)tˆ´B³¢ïßæþYãÿù·p@dWÅ©Ä1y=w ­€jñN7d9Z%uÉ:È—§D‹`uo7ëÓ„x3-®iðÕûÿ/óØÌ˜¡ú;Êc‰¡Ÿ\`ÑzíÁw-ŒýZIû…@n×8².é¶«ªˆbp&ØÞ*LÍú®–Qבî´œÈ评~+€OZÊ¿±…/©`§Û•¦Äü8ûß®s¶OlQºq*×Êõ] á‰]² H;_ý&gvàÄç¶Rê#Éh yµ4fSg €®#|˜S^­ÆJ†¸P#~EÄ0Õ¥C]N_Ü`.\ãþÙ;—/ľ"ß1vº4³|È „³7W£÷í°ô~µf‡ŽÖ­­rÅ¡‹k™x°ôâ `Òtñ®äfc<‹?\¢K7ë$ì?Q‰‚ ™% °f¯T:Ô£)3+é!Pb“”ÖAqåÑÍœ8ë¥Ôå¶ñe)ý¡#—ôü*©›³`˲Íva³Ž¢ˆR$/ñKκ:f÷øájS‘'mXl³uÉ j㣹ßÕm¿2jÀm††¶âoÃ0H„"Z ¶Š¿®)‡=ÛŠª›$2\^nU2RÛÊ[it|u’ûl€&¼”böÎŽå…6éZ°‚Ë«¥pŨ áÂæ-[ßó­ï85R/ÏÍy{d…é™_ô4DXèŽoJ]R§õÙÂ"ÍË«ÈôŽT:jÚ¤]áU{ŸéŽ"E ·…aHwDxDŸ ¹”•k&/m ¢é>5ä°·:6‡5¦šRGÂ<¦Ÿ-—W«ÎEÞ2 “Ho&ª;'ù#{(TÕEE‚›;ÆÍ*Ù{êbî8UŒû ®¤º¤³d‹šh<Šk,á»v Åc¨8¥Œ‰”èTm˜£™ÙeUT…öÛGžJ›¤k$ü6bá.”Éàä#øÄ…Hʼ ÎÝcVñ {ç‘ÅÙÒ»uq½’»Í#Úåi"+»q;£‡‚½ˆK¢½dx­Í¹™m¹k#5 Õ™;Hê |‡+¹ÆÉT¦ZÕO>¡(£–ÓIq{LiÁ$íÞÓ ¢Æ9 .’p}è¤8c¯Ì>ä‚éÆí€Ã=¦úÐ**áBÔ+LbW:"8o½’‘Ä)­}>U±¹—듌&»\­g§»8ùšíÃä:ò$âãc¤”7¦ßÛ5§#-+ÒÇ–?jŠ‘¿ŽŸ¾k#ˆÝ%¦„Äýׇ{GóÔØ§· àã“,ŽŠèÓë+‹ß»Fû­HVË9R“NKI›½£¶G¢% l]»aÒR¸Ò¿ª¯=—ˆi÷Ûp†‚Õ:1”ùÌP”¦«auy®Iœž%_/ãü» Ú îWbЇãE kVëU¤IÓÛ ,™|É…ÇW§w]Ô¿´ûCÒ|e³³x’Åq&{Ο ‘~Æ+×%Ô¯ªÇÖåG3P*þÆn$\“óÛjaÁ䇠SígÉŸ’:§µNeÖ%Ñ]”éŒ0œ $ñÝïµÉ°y ÞUrõ­ _²{fÇ2'–½}#ýÍ_Mù¹á‰Q|hï2@a)ùl”è-­&ws¤ò™«C Öpsô••Tþ¬@/¢åœŸ0)i«%†Z 9“ÙêúˈƥÇE£&ó…%ãW>gH”ü¨míJG+UÙ'.Ns›ê=ÿÝåõ ˜ýÜ’¿:³è»Œ IKØEÒÙRT"Ìì{Œ•\(UÇ5…ûäû.üö¾@^ïšÇ$‹HÔü쎇í–@h¤0hÂi¸RÁk°¿¨ï=}H¤¹Â©³Ú»È¾î|b©ï+¯æ/Å._§_“zgEt¿*ìš±ú‹÷é?¬?3KÈSzÞWth+ `õ£«ÄÁ¤¬»!‰b¢¸&ÿõᶦñ™‹}F™x„¾w^ÊTí´[L-D´“aç†AFï4þfE/ÏÒƒ«F–ʤÊ̇çƒíÂYƒ˜ñÔI3¤…Þ³”jˆÉ9”^rSÇâ’㛣Ìå:šŠâÙ)¸òš˜M~è¶L!÷ÉîȪâðÁ®Cd€'úùí›Ñ~¯ªÈÅu!EòÓí÷FNdÝS'ŒñlJZº¶߃j¼a-sáþ#çu»4 ÅCŸcªOöêÔê^O,WR#ù_BtÌ+ZCRRr®Vdí8”X,åÔ²ÔÕ‚æ}odÒ~èâs ªÉñ^ì°³ÙÖ_ý/]LœOã=€ä-sÚŸ·@ÄÔºõlòpìŒOJïݵ©á–mfÔò¶rÞÏŽï¿ °Nµ"â÷+˜¾¿TîìL®íðÿçFœˆ#´s[d¶IC¶6ñè× oàe{·|+y²Jã¾(œîa¥¥l‰V”/{¼•6ÍÏÔï]€üÅf£kQ’0 ªr—øÉÌïÎý® 6£þU•€¹¨Ø ;H¸á‚sÕ³ØÅ‚žÛŠQvvyŸ]ÉèììèÊx8Ê£ÚIĤŒûdâö)ïÕ€±: =÷G? ½Ñó•Ú4T¦FCè©%y°ó¤z_4²^+cÁ¯zˆkóæÇ;Ê4¡Kp}ÕØSf‹2Ê‹ëà®DÔóy¹äŠÅØ8_W/rз¾ 8±ðSr!Zݺ õy *ýaÉ›h(Þ•½7÷h‡z.'¶¯Tc€ýŸx;ðý;‚?<´¢>qÝšèÙå¥"ñ‘ã_w~³Ô8± J2G³J·ñ‹¸&êòQñsöu”@^Æ,¨Ä½jö“1MÁÍ)儨ß3µbí9w¢ùSô|ûZÞ[µˆvÝq‚èK¢j¶ri•®)n¥ãSc½Geäì&2üm!+mf{N„‹ÚþÙtêsŒ:òÎo¸.±‹ ÑÞzE¦å=ËrÎì+KΩI7¼º[Lü=ÁÑPÑK“­å#²ˆÎKœ‚)aïSG®à«1˜Æ-¿ÑÞá VE:µ.+ ð!ïÃhó®ù"P—RžÊ1ÐË>Œ û2—sß%Ôʾ4D{Ž~äaä^\«S‹tÄÝʉöǸRykןŽ2H[Aú?äëùß_ÝB{NíÍävô~&„±B&¦¦VîShØcWõ=ù†­¢Î_Sx/”ò?É‚+n(ÖØcšSµDï–LÇ×YF‚ªÜ Px–‘«áæçÑýçþ¹? oû>ò@‘îûu6»VàÇ̉°Á¾d©4P§ÀdÒSs•ì\K½UŸc÷š?ï5{X§¸B–_‘ï[º3œ.¸·òŒ]oT)(8Ëlà7‰iæÅOÃs TªŠäÐWŠ˜¾5óM *ÿ£Ê“ÌÉ@T$‰vú5ëÔtÔ= µB•aÔTng‰ôóÄ!ëøƒ×ĺý2ì“Ú°3¹Õ‘Ô“R1MàAÛrrùÙÂ.~¯}xÚ¥%Ó'\Q- —ãÁ+w¹¶(·å,9*¹'ž)ŽO¥}ên ÒÈE/Ç'±½•¼y8Þv5ñ¦{|h)¸ˆ9奪”*5ª·½ öæZÒj!¥W…”‹fûqlÜè!Îu5EÓÁ±œ ¶>…ø)Œng§aí5~Ò Ènë~<«Èpë]~:5Ɉu&WùˆÑÍÏÛ?qk³çÎîkS£êU%ØÐR泦¸ž|èË;ež&FA•З҈ƀhHöõ¼çC€>ÊÇF*…ŰU…EÍ&¡¥¾Ù'F*þ}Åm—²Î’ûJ“hÙ©l?ŸÝ¤2Ê t7Ô2{ŸX|v:jnØBQü3—Îú³SZœ¹šK9óôº‚gQ?Öjµ¸Ñwƒ¡–©Sèt¬H;Á)ƒÒmäcJKÑX#_®h#*L>øƒë¿< aæ±UÒÄ–BKÕTÞaŸò{<jUG_¡-”JÂÄBxù*®ÄC;é4-\^É阯Væü{õ5–ðl ݺ2±ÝÈ”—”£‡ßç¸'–úSEž–óµßŒ±M!=™/ÉA‘ŽS›JÎDÛ÷É­@¨V/éW‰Ki.`ǧ,„æ‘‚ºmˆþÏù3²”ôQ±$FÉÈŸ²sÊÝÏdçMm­"p@÷ÅGrÉ-M>ã’ªÇx*g4ë]¯ß®qÕ Z”cqÚúy)Ì‚ìÙ¼ºåË5i»žE9ã¶©$íG1É®XNúP3&m6I$¡&¯­K™Ç£p,ቻ:Ï6øÀ"Ë3KôTË]ø.ŽC‡5ˆ éòÙ8qN™K;Ë/vìZ H¶ü´«¿¥áŽ-ÑÀ¥éŒïÁ8!58æ÷Yò®H}±6²£¿Ó*ì“|þ~ØÉ—¦]¤æñKÔÿ&«±Y¹‹Óê"Å)í%ˈ–NÇ4CІ¨£ Õ0Ò2Ú]HšS‘ñuÞwíQ¾¿êÂ×/{ŒØ_Г±h ¤GBwÚh–z¾áƒT¯)ÞÜ/ú(te¥p’z·LnùžÌLX÷‹cƒ`u?Z¡Xb¿bYýæ6©¢Õ4röà·F0“" q@w ×pO.7äk!dž|ÓUsë’Ã*[?””V•4Å.è÷ã„5F Îܪ [L좊`ŒkîsvÛ׌êòÊ¡á(7ÉQ&…˜]qxhõ ”¬^7Z_j ¥æÔ[«èŠéýgÍÕ©ì¼ÑdiÝAîè=‚ý%»a#5ôk™"$Ífô>à:2LÚU¦†}†ÂXõ>½òKÙÉ3Ø%ü¨‚fxRG™ñX1ŽjÊÒ%!¹+YìÙRnqf¬ºâ’¶½»®Ÿÿ çu.ç¦í›)Ç^Ûèx¸x ŒœgÁ‡ÚFl<+ý˜»o“ñóSx½êÍv«kޑП±÷÷3 Ã;JU¡!šô.Cƒt_E4¶zRÉ(V"l® b‘Ÿ_Qïâ‡J Åù’VP{w´\ÊgÁ|°lIt'ÌìÑ»˜eÀê0ÅgPáVR: ŽN‹á7[<ÆmØB?"½ 7¦ŸÞx/j"6?ƒcr\ŽºÍ 4¤[!sôÞºä®-¡÷Á6úñݵ¡d³+†»ƒÎ{:Np}kÍSÇÜñì(2ûW|ï´Šp‹é{TÏÍE·®e0p†ÚWgBu©^:"˜yu ßú#Óš/CäB-o³9‹Ž¿çvñ­'‹ÅÇ?¨ï¿qscs¹6,ál2à9+¦{ôÇ™êà¨ÊÈ™i`"\Y›¢ »AmJn·^±Ÿ¾¼4b|oƒ2)¢KaÇB‹d¹9ÞC±6­Ã®Ä2<=‡”Å÷l“øTŽtÒ³Àìá;hq,ÑŒ¬Œú.¥'ø®b+¸øELd*“è$} ¤¶ý7ïùfó¨\#""«C§§6Z[Û] 4H(9’Ñȯ Z{ êf3CÅ—+â |~ã±sP‚©ägM}J´ï¢ö•ût´-ªóIN¬~?AO\_Vª»·,»»G…Œƒñ&_ÀSÇëïPa}!­ –…9qRN¥¢Ø'¥±A±j®ÚdzUƒÙÖÌgÑiß*Žo€HœÇ6ÄrIu}âo©É„ ýX'U°“~>ˆàq3šyÐw†öžœÅª]êµ´N‹æK. ðêô¯ˆ©4Tª•â‘SÕØïÄy¶dü>¯îý^ÀY¡½Ð¡vÿ^øbÎCÑUÈu4KÜ5'€L½%ÿ¡º5d{α­fPÇs²Ä½KA¢Ôl%ÇÃu ßAS|ر…Û<)âÞB¦ÏRqöý¹p½ËCÝ'½Ò\ ÛÍ àåbˆàVop† ‚aîÏg_@íî·%|²"Ø×ð.bL;‡¶®«^W}¯Ú’EZíUIÉÙCÊß­š:?ÁÏïÖYt=ª²u‘~b!£ã¾:àl}n+tëh´,;‹ƒc_x¦S!á>$âŸ;Xòôc·xõÅãþ¨^/ú€/´ÒJ¢]nª-’ ãW ŸüÔÞõÈñ1ƒÜ8Ä{·ü[.Ð/´ .î>ÎŽ]í²»Ò\è 9 3¬Ï0ÿ9XøÕ Å!qWP]rËÑï;šxœnÄ>2y1Ç9)¡.zcìèöÜ@´­Já&Øa~#“:¡3j§Rk‹›:E¦uynÊ8ç±jˆˆ¨Ž;²¾#ª=dÑ{ƒ)¸Å‡\;†KÛÒôpµƒˆ/*¢ì¯õì…z>£ÏÔ _•«ûÀ(ߦvÝ él ãïí%°ÑË©Û ®R™sšS¥†f ²‰ObŒÆrÓÕ!tÙ Œd·$¾o‰¿% ¨M¡Ó?L= ã îŽ+æHi¸²`—ºÈ?Ƀ˛¿GkYÜ#GÌ1&©c»<¸H=wXFïâS{‹aKÂi+#êngF ›š?.>¥Êtòh”fHª§Ž“Á¤$ g6¥ý+ 0ZnDöBœS—àì õ­è­ûŠÏ›‘Ñm8òûõFo¤®W_üN¤ÊÏU]9èܸ>g<“Îê“úÒâøni§,tmÛ«/*{õl#‚ˆÇ-Ê€ù¹ÚGèYÕhÁ¹«³/µ¬n|û ¼|?“àVSo]1Q.¡ÄµePx _Âê#{’眵ߜñ%âQ#Ztè˜ŽØ %Í#´ž+×ÛVÖïFd‰=¿ª.ú`ž/ÄÛÞˆuǼ’‡‡íY¶oç÷¤¶\mí€'!jiqv©«lÏ%…ŠþEýØ€q"`ã#±½¢áù "ÐM­¸ÞÎÏÀ ƒ • qý°8‘.Òu¼lVQ¡:_UÖ]aY¼ ¼tOC ²0Ûsr̸4xçìaÏ» ^íZË’¯·7¦!6B«}\‰Ù\M àûT‹] ™¹e~â ¨MÛo’1 Þ-gÀ]N#¤qê¼B/Ó8o³ð$óïSŒÝ:¾I '\£={RˆB0™yÔ_Â÷Dfò‘C£A³Me áÚ&BP£}ÅÜÐ#ÂÐ5­ý¤Ë/]àJfTÛHýœDFÆÊêK ו­gqQ>ÕDÊÔHÆy‘0#n¾ª‘:”ÍÓÂû8°çHŸ3áû7Z{I\¹éWD:<±êúX«Ùó¦éQ¶+ô¸CU¨C,ñŠ4Ñ}zcYö„eÐaeúÁò·¯t1¼Zmp§K2ûÈBÌŸУ4c‹íØ»8ƒ»3“Úp}·ýw÷n—Q³_% ˆ›ž¢6í½•¢›‘‘ÃÍÀò5 [‰VÌ"¯ '¾I#Д𳙋Ðã’ÖNÉVñ==3>¹ï& ñ¢ˆ°|1Ä9­¼ÞB$¾Eð#eõÄT¬EQU‹Ï§1¾O ôŸËŽ2ÚkÙCDêâ€,”Ž5OÁxZ°Ü¼öù„ ÊÔ;Èb*o¤óˆÚ"2Ûâ‚ß–‚ÈG´-MEOk¾vïŸUøRK’[#AœU€wHxedåÂ\Â竚 PþäÔÞ¿¶Ù4õ´:r‰.xßág%Ÿ>ÓΩ‰öàÀ²­«Ö×(UÕ‰Víâ2­‹BkM£JOrÌ…F­‚ꘆa¥ÅiÅNu_«ìfÓ¢±ʦޗdÅ$þ¿©œÎnÙ´5ª4`]ýM…ZW®†+¶–Ò÷˜Ú 3]uáBˆv5]ÙТWïÖn+½ÍdÛ]2ñ[„†<5ÔÈ:]-ç'¸û½×„ý~±‚¬ýt·9{4%>“äuMÝÄò5éß=2%¼f)¹€¦ç‡Ä"#'óqÊ1öÕþr×{`ACƒƒ²8óœêÈm%Ô‘¾ï[Éו6ûÑ0/T{œNOÞ[fÍÔ«lÓ}¶ädÃò1×Az¶]E o-¿oÙÙáBd=ƒ¿KO±Q°ÀžÚ>…!lÈ7»È%ãÊ…·IÞÁgœp¥·j{Z ¢‰•Þã>H»hÐÒ—¤*Ýu1-‹*@«¤<²Û 6Éší¥£Õ¶èŒØOÃß…¨ÉÞÒ—þp o—ÐMñ™­8U¬ùXŸÐöôº^üâÁåz' Ì?W;6y›zÒ‰“:ÖއTQ*¢%ÙÊP˜i(zö’{ÉÿÈÓxlJŒÂ!%«Aþv•Ï18¥@Ï^^ÙMW§‰@X¦Äh°{;q'µÖ$—W]Ó!4Û=)'!Éýkxd]B[¾FM«`ÌxNM]ž9JŠÿMAD%38&J Ueô§GNÈÇžõc¦!c¡ÉêÃ.YŸs$8çÙpjј(‹´Øî ZÊk¥¦:Õ×þ†©oÙw£9µ„7jhãøX6RFq·ºì¹—0ªæY5©•ìîù5Ï­†×Àѵ>¤ß „³,©ÁnŽ ÝÅ̳»‚/±©O#ɇFñ†²ªUàµ*¯¬’ÕwzLã§/MÙDqÈùwO¢-„^?ß_Úd@ß¼y(u¡¦4bkËïBæ|‚dï™ã”·³b?˜½ÍÏǤ|ã«Ð©=}m-M¢Öwöˆ«@­’Ï­[@Vp4ÚÄ@Q Û—¿wßÒ'›««Û—ùñÃtæ\Ðâ>à‡ZºÒ¿pÝÝ£êïe½Ù`ßyVy?lPDo©É[†¡Æ+$ÑSh–Z®ì9L,ýB¯ Spnï{õRT œ¾e8YI¡êOXqž&!B÷Ô·³6‚ø0®5!õXd3k¯&ú“å¬ [mâ_(koŽÓɨWè]ö”OJÙm‰|·–dÆ¥ Åõq¯à/ªäŸGR#®QMâ4ÄÓ¾UùxëÒ$:CtêÁÍòHù»«\ÈhWR'A¨iÓì^·44ÎÕ+]¶½IŸ¼²ëŤS§ì±þ¾˜%ŸªNq˜é¢JˆAž #ÀÂ,–)À›Â%1ä~JC'á­MѾZ“è–U¢aa¥3¾»› Ý>³m²œv.T€HV8ô4¯w0+¾Zý„Òãó@¬Ú]–4µÛm3¥–zËš‚’7Ë1`—ÅØ`ÉbtŒÒüàÔhc@vt~Š€ÿíhZ«´¢11Ú5¶½"Ÿt u<øKßÍ5ùLŸ“¢ž‡–ò‘‹“c®BÉx“'CB•ÈÉ:¦bÑP{¡õ“A·üUã‘ÉÛÅÛ;ÊçäàrŠd´ÊÏÄ•Ã:%ûâÀ6”3êáªÕ,¢¥Ðå_2 ÚÂq+ Hò_mÂŒ¤“.‰½µ€…ÍŽgQí‚Ùµ“‰v~k¨<ׇ¯éÄÕ>¹ú¸°°‹s5ïtÕV?×r*}7ÎÑ­40êü,™â[ôýßÑâ úaÅPGì&©e\;<ÐËà8(L·š+¿{›³ýHÞTO¾úÌkY…êÛâ@£bùªpÄ[ ¬µªÔ¸¿$í]…xHfý‡·_M&n_ž©ó¥anTƒÂzD ׌Ê'%åÜ5ÝqR“â³ã3ƒ=p„tBrŒã»Ê»œ°ü´S¦¶®ª$£ao} p5Õ@DXÍߊîå¬Útw‚Åô.Ëw¿Íä á*3¯ÆfmX+9¨¢ÜˆT´ˆÖLdÜÿ—k¹+©~¤ßgÜòWTýò•k“„ÔAž’ïí]ÄmóÖ2àŠÓ M(®9eè|Ç!Þµ•h¦²®¿ ϳëÈ|:¶‘=!gäsØ Yù‘UØXœuÞ`Š‰ïž¨ŽCjr(ØÏÚBÛÓw ¬aeßµ/æì>ùQ£5KE"%ÁˆˆÞåé°úöªá½U³“®8¨˜~O‘£”f¶÷Èç¯K/’|n͉;Þ”b¯ ø{“Í/úÃu4u@JvÜhx&ç`kß]Ö1nÏçûG›'-–ÎÊT5¥S4ÝmE£î`ÑÑ(ÜɦtF ô¯!œ þÍÓ²ÒK4¬¹š">æ‰;܃9å8ZZ„Nº<€vÇýŒãÜ_Â0Oô‚7(õ‘„ê"ììgg¤*î¥m—Ô×¶HL,ׂµ¶é»Xà⡤ÈHö†z)@Yç.=µsºøÃ „S•=íLÁÌ*4o‘ÖŒ+{Ä‚«Hå7«¥­ Ya‹ªÂNf‰½s;@~û›¾—~4ÄA9 çõiͳ„Á!cs²ÙwǦf™%mø ٕÚãk`è=`ÞäfIze0dªùµÞ]Ö¶ÏŒ‚¸U ‰Ë–NÃòàU6ÊuµišxŽ&cƒšÆÁ’t:£ÙJKß™Ê$ú‰ñT»)_Z,ï1tâÚTÃcilA•”gßâÎ:’$NÜ*õš6Ó™·Ëö6õû"¼yœ#IJºNí2·óÂ-ž—ZõM*>–Ù‡ð¯+d¡¢á¥DÜ FXKFÑîÓ­Ž~Fº 7¶Ð¨/ ýþ¦ªN²¤3ª£>Ü¥eÄ @la%Q¾~{áE"ÜZÆ9 w‡ µ³'Õ¡Œxí°˜›k,Ç&0BwÛ;ȉl“ý7P®{‚5=Ü›£4 ÜÝ"Ρ­›3Àb}úx¢ÍüO<èweÍ;w|a™—Ø-Çûi¨ö^l ‡*_G™nq|Ôí·*Ýoóýôv)Lý£k3ÓP>ÜΠ†CsdS•xØA-™çŒ­ж $C¦Êõ›¼G”¾êâm²Èùóï™HvX£ö-R]O1–£À\Ÿéw$•àÀG‹„º>ÁÕ÷=³{6éš dÔ=¤6öõ£‰65d ’Ó×— ~Ei¸L£²/µÆ»ÚJ«ê¼Lfì-Ôö½q½K;iL9‹¡T%ñ÷kþùE›!9FiLYA`ô¦ñ[ Å0ªH§§2b²ªE|õÛœÙÔ//ØÈC£|ú ™`*kÈYxˆ ö;{IŒ›ز ô(PFdËŸ¹’Bxñ§AÓv¶(\cy¡vòL µ,ïõȉí S云Ô`…Ù½}o!–§v—ñ.îÿœ GÒ˜-Pל…Uô\rõZH 9Flä (VaÙ¾4MIšÈâîPAµLvT?S£ˆŒÁÿ8„¼l£gzþþd“¿4ïÅE^ÑÄ>³%Íq–:ÓÅ'™I%ìPÞ{ªÎï^SžVÉ­¢òp™ýëJ³V‹ñ:…¡nö÷¡ÛÐ?1‡·TP”sRŒÄäM*GAµ÷áö¿g™ä?[Á$þ·^ .D÷½U>ËÄ É÷Ö¡›ðÄ._k0ÉÚm‚9xPÇÓnIzõ¦QœWCÓɆNÕV¿ï~À¹¬7žH3è®Î¨G  B̨’d·Äõò+ؼW£ìã†OL"‰WHÚ8Ÿ–€d1¼a@%ºs0-&_|0”ŽÌ'¨à=Ú'ÂX^÷˜@WW«æ)tª+¿‘ŽtÔÓ‘Øu–¹®ã»KÌòÛŒK£ é¤ãjäT_ ¤ŠÛ€Ä«Y0Uú(õ±É%‡qQò,JGêR?­žÓ„ˆuæt¤;FvuÊXÄ\nÚÒ\5QŽ=% Í]Ê’}E@ÞW,H'² çýÁ䫌t¢t¼¼é pê(s²"dj†¼ ÷ÕÌÖ}³ÎÄÙ` Qr¶tVdw%DK܇2¢ æ äÅÁê”ûéiÅëT-²‡’ZYs¥E1ËÉ5 ñU&jÜ­oP,Ò¯Á'CÑZKÂ} …OWÒf0ŸÊdc‰‚!"°䢧1‡sPu ÆvôT Ãèɽ[Ñ9¶*h½×êl¶¯„ŒØ+-Ó‰ÙÅ''`ßbÿ™;±ßKù¤»o‰GPH¶™(ü´?‚æãò1}+Ú•³t¥(y¾lË6Üí…îyƒác¿Ã º(|ß«.09])‹Áfôö‡ ìÖÑ×DŽtÆ™]™­7Ñ6æFÎÄ7Mè.ËÐ4­U7¶±ÙŒz*MBmËNí^Îõ]¥Ééñ&ˆ¤“Û¸iPŸVQÒ²¿¶ŒÒ k¤+쫇<|½“·Æl·W5±Û ŽŠËZDìóK¬Û†¥kMOá uú¡xâö4$BûH_'šK…^ì×Ud¬P;yOÉLI¡NÙš9q;&}›]•­žÀJ ·Òlÿ?±@ö;þ$&3žù¨XŸ,“¨½Äܧéí ”1s]æ»ì…ïô=z'X8xù VY±=8(½Ù‰WW‹!‡V´SQöƒÙ¾»£šÑu ’(òò÷H]ê(@¬[¾fNœ‰ÏјÔò|™!Gý_ëÍÊy"óá'”hECÙåÇ5PÃNê{O?K9µtAK ¼.{'·Šûs»‰5çÍ—0<¹ºšº•!ðéð¦ØG¶H·¦ôœ®Ã$¸7[›]-ªsÙ>.C'1–6ŸrÏ­§ü€”ÅJšÂ;ï?SG»Í>fÙVIQÿtFf?ç?º,¶;qƒÐa)½&Þ3$O„ FØ­ºV¤C³H¾¸ 1)ù²O¤P㪪W°4üÌ>e2cI©d$a'S%åÇNöŽtüTø8/IW^•6MÊR&™IOÍ*jÅO²õ‰øÄFY:kTm .£9÷Žc¨hñ]Á?êòðý.Ø;»ûÏNÝ—Y=(›+R§~¿&e.“7®òìpž(`‰âåÐu˜ŸnÖ¤b%–0 ôÅÄCû¤)ÄyëR´-¦ÍVàËwÔd³7RÑ×d{¿äñdi GæIkŸ‹›Õ¡È”8_#ªß˜òˆ—“:UͱŠf‘c¢¦øyÔ~ßð¬Jö$ PwÆ¢WŒã„d}X2G?CÐ'i¨xøkÔîß‚«o¨gÃhHÜíœEÐrö}DÊ»b<þ Œš/¹i׸‹iԎꢺrTPmÊ6¾„çîç@ êU¾+»¤ å£Ò/nƒøØ; Gbwë^ò}Kñå!°qÿL±sÒÚpCæ}®¼ïq) ÀfkJ{„0ÀÆyçãò Wjx2uè7í€ RwLnUr>3æx=ØìÙS³Ÿž˜¿ˆÃ¹ÉñÀ Xu>{+3vfǺÕ÷aûÊÞ>EîÁæL)ªÙÚ×í…E,måñ«*,]d‹»°ŽZ4òjÜ…s¤ŠL8»fN©Ÿú#Úi¯î šæ³œƒn”-ÄŒ€s·R‰[Ù¤Öæ£,€ê$nõ¤Aâñ€DBÜHø{‡0’¶dÐ3ŠÐºÚž­ÎÀÆ•…‘Kœ¬åæÌÂÈû’VaÊmY ºEÝY.±”üíJoÓ5=ØñžÐD˜)^~¬™õÓêá ‹y·fW/ž¢SxEÙ5†Ä®s‘ää”°f¶¶Š¥ ä»óSpŠã¥%³R²tg¬8 Ú†GkíEÙÜ®s”§‰8dgÛ-GjøvÍÑ˹½"?Ršž4¹]T …ìÀ,J±ë£±ŠA§Ã¨c:d~ {}ãdévÈÉ÷"ü÷ü ¡êj¦Oý*3ð;¨Á¼ÓÆuæÁ1QÏÏ”ò(iX²>ŒE8¤Rì‰`šTÑžSëdà‡SíŽÕE4”…e2iƒü£|ˆ,½•­:F\ޓе©œ/W÷*–œ¼¾¼î¤øjÐ÷Ó{Hc×…˜èW€çA?ø :ß!(âæ¶JY¾»‡TÇñYo ø3&ÀÏ @ƒôõËtÛ§MŽ+i{!0Õ´ò–Ôi…E´s%&ÒHɾ×’qni_¿o²2¤¬ÙÐÓ:Å— ÈgËÈ]0â@åÀÿÆ<±8†x~ÎÁC{²[ƒYª—–¡%õÒÝE¶ ù¯ívÿ´óÃБ´“¥ñ´âÊ’ºàÜR6»(KÚ^:©f}EžäLK@â—Ÿ½„ð¯÷^Iê\váî¢/¾÷±C® ¹b¨d£±dù²ÓPÚö`ßé#‡¿ û9®¾Ë-Ę»¥cŸ®½Ga²¦2ûi‘Iú¯PNBXìÚamWÙnÝ+D÷çô>².™þ¸L\|Ò7¼_ݬ‘N|…½Š›|‘‹j;UöV×:œ¾|_.PªÑ¿ÚNû~äe¨š6Dºµ+:çœúdæqþG½Kà¶:™-‰„Në÷A|Q*Çylª—¦ÏÇ¢¢»n]Ò?#Ð!–¢ê‘lôSxœ&s—ó©ûW3é‘ºŠ¤ÝÎÑUû0l=²kWâmwâ8øE8ÝÀ]¥îNñ±ÍÈm\YSò`xm»3ºR²v†ª+4ŸíÁ\(´x&£ÓÜ©=?™ TþÒ­ó|AýmŠK:¡Ð.0Žü$ßËÁÛ»ØSk,ùmªýq ËÓ´Æ?¡‡¤…£Ž"g™•ó 0^` ”Ìb©Íe‡-3ü!_û0ßâØã@¿ÇD¤ÛöškØ© 5¢7å­!Èqƒ >‘ç}þ!b0¹9«½:~v©ùœà0ðww_CŠ]d$ŠÜül&×2L?Ë#Ûª‰úKLS‡Ás”¶ +øwŽSéÊaeãÊåf­H¹ÔÄ2º)¼ò©Õ©&½­>ê¢ùÃyÿá}"U‡\áIÑg‡ñFcÝáoïm–Ê–)ÈL;âÆdþÒø¾_£W0^Y<Ï>}ÈV{ƒ‡pîÈ)¹ª¬Bßä¤DCAc·™#rÁN¬-P%Éú¹Ï‘e–X3_«C}ô#-5pމåyÚA®pdaqÍ+@jêÕØ–•Ó¶4“¼÷ßL(¡žÃ©‹²YM 3;)Z· cY5îÞmxÒœFmVäØ5$÷!8#|-"ˆO×—66Õ“!’ŸâŒØ!2Ëþ±uTµê L»KŠE…èÉå?ÿNd±HÜàÜœ+åš«™ïÕ's»I#‹ßÌÍçl<]Çò>Þÿø)âÅ&Oamï£<ç# òRˆ¥ÖE‡ ä”&°Y×kºA-¸U±ã$öF>Ì®ëj§MÑPK¨ySVz(GSìÚ8JÚìÈdÎ;A¯ßY ònÚÂtä}!îÁƱ•-›*!HôUW‹pœR1Þ~áe?¢a}ùü÷Ñ9¬¯}±)K]™ŠT±iÆŠ§ëúgQºö´DÁMWtÕºä1ªø] >™‚G¨B(Ó»vÂbÒsœ m@½wL·Ê‘2Ö•ÁÛÒî" Ò„m’·u “ ítáV×.a4ÙBÚ÷I.w^¬(Ž^÷J8Bü3¬'D³Jz-E4wõÁ #ƒ™ñAý"øOîvñ N`ñŒœù®ö¥²»Éû.mr y0Š%ÑÑ”&uQµ@¤õ¡!!'øjñÇ.ØÄø{#Îäj:ïý>úÈû6‡*Ä=i‰Êò7uE0±SY$õÞä9tò&éF“šKçÄ¾Ï±í¨‚Žº‚3 ùÀ} yÒú©‘h˜S^ÁöÈÕNèèQÜõ¤'ÂÁ=’•¾('ÎȾ«Wå)Ù¥Ã2A¤e.Û€&7”¸ÞòVÑ«ú npM*+i•X*§žÁ°T£±A¯ÎÌcÜh]c‚&+‡‘nšEºÐ{ÁÃXø« (Çý🅽[|ŸÞ|¨ö†ˆ³ÄL× ‚¬ÖÙq–ö5CâT_4on¶+Zš'±ëOùeK2ê^J–u%½À' ËÝw-fd)–(r;{Ô¸PÂÖƒfC÷ÂúX å¯Û§ÊŸF˜² Îz°[EK¦Âãî´®–ÄÁ\¾”Ž>äq´™¢j†f_ByQól'ò_”Õ.¥“›\&Ä‚i9—4cš ³í+ã½Ñ•±¹ÃÀóô#ÍAæ«mfʃÕàX6.JN­%mÁ.| ²ÿù¸F§Ò[š%ý×í)ª]ä=ÂH8”ÜÙ.¥VÕ` Uo‘Ç‚úä–nª%~‹rµÑ$¢2¤_Û©?I;ž8£ÎúY ñ5«$ê9'ì ƒ¡{š…RœËQûJ´Nr¼0Àà*ùóNœDL@do5FJ/HaûÇy$ë u(ºvn©ÜMø¯­x>mh¦¯öøV–7Ä‚îNÄ}ï}øëo>¯$NœG’q‘5 ð9Þ-HDŽ\H{à d³3‡qiD`vMEå§…ùÞ<0ÔU¤^Åég­$’}Ñ!òìGÄ Zª„A”“¸eê»TÀNCP™)¥cec“YêYUÑ5 -–ÞYÝr®²›X4š:ýóåŽ IçlÍÝB»Ã§Tj NúÎM®$HøHZ^—6^bá¯Tmw«I•Ї,iW\jiLxÕ6ÙýF©RïÁ &ý¹Ý ’Æ÷I‚޵„&®GëâuÅ ­k€úãÖµ“pê›’û¼ÀºÖ (Bi„4ºËÉŒƒpï!Š<°?ŒQ·åưò7ЉhåHéá*À…Y7¶Ð”¶ öTQÄr{o„$ÔOzbÔï««©ûµà#‹Æ”«P@¬ßiÏ.‹*÷¥¥ ÓøŽ#D—Rc­HáOúrS]û¾Ò ÂÄØó.-ø©AÛkÓC@ÝM¤(Ü[ ‰¤Ñ_iãå·Lù|&—dgbž6°7<û „[fŒlkÊ[¨É‚øC¬_x¡Æliরïò+Ô”»É ªaNàh15V,áÁñ$é®äõr©v'î=ùèÝ¢E…f2½JO‡_XD¡˜¤C´XÔe¶ "¦q—•JoVÙH†B0‹½úÂîŠÂ(^`ð.ÔþÞ«O‰ÌáX éCÖžb ÐP³Õ“ÚJSúeîuG-qaø^Œ{$ç¨Ní~’ßu$9á™L|fõBrþé?]í­ÝR¿‡ÍÒ]É2–£c‘à²ErέÛà†Š×ƒ0å/ÕAFŠÏÙy-ðh…X±M4™{£*ò¦UYföoF¼¢jÊOÝP>ÞDÜ®‡ÔïÎñ(±vû,—„~jÌP`]LÝ–^¥Ãì0Ÿ8}›œ¨;òMÀê*1õ+}¾yP{v…?µf(˜]}þ‰v¬Ó(»—˜åBñŽýÄe“KR–Ÿ^EgEsÅ/5u²¬"Êݦ„w±È&³‹rãõu¦äz+{vJKìHNCW¶cƈ«Çð`Ú éÍt©›yï"Nùžž4È›Îg41ëé0ä&F$ÎÍnžôDÔ´ô±×K æýùY¼¿¸²Ø-¹Ý‚“¨sžîƒ^ ú¥û36ÛNM>äŠ5-{â†Ò””ÓÝ­.&œJZÉ[ή/5PéµHÊé–(žÀÝø”\Pür‰+× ûÖR¯Ypì…ãɑ՞¿—åMLðGÞ)A}Zç*§ (L«x{QqI, Õwa´âJ2{A•ÐM1^÷ÒÕI„‹ÐóíBÞÜ-­åš Æ?¾ÐýÈF¨dÆxñǽ•Ã"±]W¨y<™šD¼¡Ô»ÖOY‰«asÜ#:*åXºe„Pʤ’ã¨Çàün8žÓóu²$7ÕàïÉxÿ¾b«4·«Ðšœue eÔRVt°pžë X:Y¯yjãÆô¶Õ.øSçEÆñ ð*Ï=0¤¬+kúŸ¯£ôð=™¤TзmÃàb­|­Â·Ô§ö!68¢XõôšóÄy#©š­Ý"j3EhaIkGŠÖÌLO˜*Êã~TƒŽÓÄûá}´6ÃoO˜ŒùW§’@ÕJ$ªo«_}Ò&‰Î.`²Wîuƒ$/•¼+9·öÔ‚Áά°¢fÑÌñ.ti à­¡w]É5±K%]h™L‡³•´¥É¥¦=Ô€^Õuwó‘ÓÄ©Á$t T´¦‹J‘þcߘþEÌ¢ˆ¹˜³÷*•?¯K•ˆ³àWZ;VPrç&Í4JwS™ŽUø¢³´A“sÊ&ÌçÌ­G•?¦-W"[}‹¿¡[ë8ŸJ·bn¬œÖ\ݭͯ#öšÅFÄžªò˜1%LãD›h³/ ¼[–Æ„NG3Çv¾äù„àD­…%’CçHÔHâwGÖ‹­7ÈÛ-P–ùB¾žUÜÈ=Á*ºE3á*TÉû93ü@ñ:F].%ªe«Bœ@Úö'¹ñ8¢÷”û§¿ÔU{0ƒË‚ÄúJ90_ÜÀôK ž] F0eºö?c_û矡€dç½^}ébëi çC¦ø©•E’%+8ªl/NãÕÞÁäT/ºvqÅŠlˆZ²Yʯ e˜œ¦¶ü”{œ7(€i¹r+ÇX©‹âÌ©GŒ¿t4~6;ŽÞµH i]åRɳž–xËü T¿Û˜žñóP(KWÕÝy AýS gãHøN?¬ÊmÒ¢À $²Òg©!YzOª© 1QJ¹¸»Ä¨¾õ‡¨ D¦·lô"Ô=&c!ÿÕµV˜)!qâI½”ã5ÜrÀ]7ÌÍ« ¬¢>sdöiò(etªíªî’L;À»šrÒÆoß׫ày¶] '‡ª„õi\E‰¾ºWßžÜí#nŸå}+³Íkܵ5byÑùà’û"/2ç«SÞ׫iM@øwÔD}Ü'cd zéññ]ž5´3»NCþ4®ÊIÞ¯£Åälæ€îÜ-Á Jõß™¿3nÚÊ8%Ç'1Ñt¶›PÜi÷žFlÞpÍl9Å,Õ¢g‰rÀ­„Þªö‘Ut8Í#7‡°}/KG>q±LþÜhü•ƒTÂmÛ§lb/‘IüíŽ B»:„%ž®[ÓÂÃÝW—Çék€¶~ïöŠì ~ÚM@b2xô[\É¥)%z‚Å]Q ¸ðl1_°Í¹ÀÕiAÎ3Õ³]¡RÅ]¶ß=ð§õZ:l·w-¨2ÍR15?ÐÒ¬aƻȶÁݬâDs' (ÏÌÙÊ>®4G`RÝü(—€ÌjÞN滼t…åH >1ºHðù>Up;J€e94%1MólšqgÄ‘´Å}JOשÏicp"ôß·DÚØVˆØOE$=ÇíÄÿŽØ/:è7S€æC­ØGŸÖ‚Èw‰•9:0´hEþ<}£Û¶4vA)û&V;Õ‘+Q£4™{y.Ð^cNô9`¾õÉœ|<=pÝ/.䤴J³Ð¹k)S]QÄ›b*•J{~¢HJ¬Ì;À³ÜÙPJ”ó®9xÑÐ>ü*Q‰mkâιӖ À©hrÚAF‰Ï‚¹:W&O±`,µðÁç —:Ø®…R~ìñNšR1ó:²[šæ¥å§½ðîÉHc‘ÙdýtŽ˜ÞB¼AA32q:óÈ£{a™û¡o€Q³ËÖ>&J±*Fù cë×1xaì js>n°\žda¿}¨qTÊÜÛå  °cmWdsZ͹V…üC_äóû æåÒˆuäŠ?[žnÐLdNB½;ÛñS~yùD´mjQÌð AúíSÚ¾›jÐ5+¢)éŠàâµÝ¸“ÎJ‚u„ËÙ6Ó¢\%‹[I" .G.KKb ÂÓXK‚ 3Õ¤,«@©b6‘›N"@sEþ(ï#%îZiî»3ÚÛ:^»@¤×}~yo97):úI¾»ô9]ÇHUÉþƒQFŽxj|ÍÝ$þ~ eÒ½Iïr3^€c)[gÊLºK‹QE_¿¬£kØðèr'iŒé-‰9 ‹ŽÝÿì•ôU¤²ÜÑ´~©€î¬cIéEu²ë ¯¾:Z{š¶wKêtϲ´uìK¨;®=ëI뻢µÔ ÐûIx¨7L‹}zA4”+ötb:º&Þhš® oßhMŸU¦ B¨#Ö¬˜·ÆÙhìw›ú”ô]Éö­Z [0Õ½ý^O”Iì@.’_¢¬ :“ ÎŒQ‡ œªY¿1>ð¾ 4±‹<’zÛSu66¼dŸ GU´„õ1ÝÙ[‘Á¯*Mç©·X¶_Ìz\Ÿ™pNGW,€n\s&R$S~àô}IAϾ'zÂ9•Û°þ*è±oXõR²\KÛ¯˜;÷ô.@›r;Ž&ÔÓÇDæQœZÅ·kl¸<J|EÖº¬+øoƒwï)­Üv“5#Ù¥-ñ,·úЦv9rã½Ûæ„»AÎð‡§;Ýäâô »# ¥ví €‹¤è­:]yW¨O]käåÕ- l[%šÐõIïOÙ„+dª¢-ç’ùU 4íˆdÜ£X>»Þ3"LŽOéâûî]íÍï*“ÐëÇ¿Éñ…¥|ÉXÁWVÜX»éÎ C$3‡ PÍ9q”õú€‰f‰5qLÑ£;,âS|³ÇAø®R§íÐeV Š|©ïÛ,²¼µ¦:1—Šæ Ýç­ðŠ«Û:šmVú§>áê®NSKPÊž¡íVãx°TϽ6ÔBbäû©,°$% ,Þl±ib{Ť$Ø7.¾zñ«Éëq]<˜R"8­KÄ–†p°Î“¼FÑÁ¹§NŸ D2¨kØÒ¸D‚TO÷ ªËoº¥#|Õ@¸&GïÇŠ¶* , ¬6ŸÖ%aVsúv%êÞúý¼}ßmU7®h ÇDÕmn÷É\“û }‘1¶‚ðsVö¯CÖ‡ŽR“æ€Zãœk‚wÝð¦ú{D:Ç>Á¥x¾U0j1%]i"š(øº²)£Y®Ç™$îµi,W™žW5-pT¤¹»4]«pçë2¨z\èÈJÅ*µ*ÕºÍ|´¥ÍZbóGÚMÙˆWüË|†"M¦ˆ¢TH¼]£µÙ‘8rÍ™÷4†š€9Ùîú¢»¥/ÑÚÕ¹¿šÅu™v.ÍCÜm$ªíO^€Ð*(_§µð r†ˆt +²ßH3¾;@4?Ÿ•AýÿMI’Ü0ïþ‹Ü—ÿÌU öÍM÷HY *1ÐIDD—Ó²±*XÖïûÚ­'.!ÓÓV¥¯õ¼#¡^ä¤Ê̘O\&ûŒë²ÀŽÂ9=7¶0x“šýÝøR1ž ™Qž-#7ÞÎäÞ÷CÐ'ºYݶzË3O#\wáù™'‚MyÃi篈ö¸Æî<±6ˆ ŸýÄÍ.âr]gs‰¸ì¢xî`zÉ›“ùíðs$³Ë›uÁô¤ªŒ¿Þ‘2U{ðö:™[hN{ ìÑûøˆrvbñÜÎfªŒÅ4¦Úá© 1„–ËXð>ßLn?Ë6pŸ–ëxô!+#˜øq ¨„™å=ðuD‘J‹fÏâ){PA‚4X‹j´'ëE‘Ž,"ÁË{g㵜¥Üm/¤A^€U*H˜ûéÛ2|páÅ ¼z¶ ð™WÑ<‡ "ÜÂ{¿ê`#ª<±vëÎßmYÅÚÒhÍŸ³« §wtí¥­ö}¥•›ì&¾MÝ“ÑM5ïëÊ'XæÓ¯=™°£¹¾Zì(©›ø2AÏ„¾,é#y¯Ç·QãÆT ðY³aAµ»îÏq„R²ô÷™‰ùÑs‘¼2DÛÞ-µÂvÇV9íò)RQ“Ó4\ï10š{XÝjÃsbÏ>|ŒH ñ]­ /TÄv Ì_¯9"+ˆ„Êv¿Fê9Q*EYû}•ŒŸyËž®Zì ç jkª·¶9LH¡†ä^)ÉÛV‡•Õ—=L>üÒ/]bà‘£Xä0¯6¾,ðä̾BÁû¿Ùðëh¡‹쟶JÙ ãæ¼¤eþyDíú%¡x^/ƒéƒ3u†Ýóe@ÿ‰Ud‰5§²´—xªsÄEÚs%Ÿ/QØ•¶ß½’CÖwŒ›rBÀI ò³|]‰º¦õ`ŸÛç¿«F|T9Tù‰ìÎEÜUi•]°Š’ë%coí×OSï„Ö#vÜ+ÎvÀC‘£I™<²³eÑâÈÆqH hØï"C?Å íÉúTšÛˆ¤ˆTýÊ«QÖ„"z’Ì9¿—_MEêìÉ>ŽÝÑ®Òw¢Ýp†T/5ž•N€]«è#æZ†2¸ãù¾Æ(·†#±kà (ï’‚ZE˜;ÞMù›ayMÑïÖI6hQfø¹V+1ŠmS¶Qµ™p¢ÍJ¡/?Bcß'™÷(„?Zœ„½~Yt¼?sƳOj¹ÊÆæ$Ùh|ÒOˆ=w5ŽýÊÙ p8£†LÃîo0Ó0¡b¿•Ú ¥£7g/j?„2‚¦l<œªu0㺡þŒga>©zHiÆ­b¸ó˜˜­XÏ#"m|N²ÙËs¯ÈŽ)îb­äV3† õŒÒ%Mt¬Ãäæ Žçkô¯€Íd˜Íy@CÌsV$…ŠÑb=‘š #include // for NULL #include /* in ./llhGarch.f : * SUBROUTINE GARCHLLH(N, Y, Z, H, NF, X, DPARM, MDIST, MYPAR, F) */ extern void F77_NAME(garchllh)(int *N, double *Y, double *Z, double *H, int *NF, double *X, double *DPARM, int *MDIST, int *MYPAR, double *F); static const R_FortranMethodDef FortranEntries[] = { {"garchllh", (DL_FUNC) &F77_NAME(garchllh), 10}, {NULL, NULL, 0} }; void R_init_fGarch(DllInfo *dll) { R_registerRoutines(dll, NULL, NULL, FortranEntries, NULL); R_useDynamicSymbols(dll, FALSE); } fGarch/src/Makevars0000644000176200001440000000005615104730075013732 0ustar liggesusersPKG_LIBS=$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) fGarch/src/llhGarch.f0000644000176200001440000001044715104730075014136 0ustar liggesusers SUBROUTINE GARCHLLH(N, Y, Z, H, NF, X, DPARM, MDIST, MYPAR, F) IMPLICIT NONE C DECLARATION OF ARGUMENTS INTEGER N DOUBLE PRECISION Y(N), Z(N), H(N) INTEGER NF DOUBLE PRECISION X(NF) DOUBLE PRECISION DPARM(3) INTEGER MDIST INTEGER MYPAR(11) DOUBLE PRECISION F C LOCAL VARIABLES INTEGER INITREC, LEVERAGE, INCMEAN, INCDELTA ,INCSKEW, INCSHAPE INTEGER NR, NS, NP, NQ, NORM DOUBLE PRECISION XMEAN, XOMEGA, XDELTA, XSKEW, XSHAPE INTEGER IAR, IMA, IOMEGA, IALPHA, IBETA, IDELTA, ISKEW, ISHAPE INTEGER I, NEXT, IP, IQ, IR DOUBLE PRECISION SUMALPHA, SUMBETA, PERSISTENCE DOUBLE PRECISION VAR, ZI, ZZ, HH, LLH, DD DOUBLE PRECISION XINVD C EXTERNAL FUNC DOUBLE PRECISION DLOG, DIST C MYPAR INITREC = MYPAR(1) LEVERAGE = MYPAR(2) INCMEAN = MYPAR(3) INCDELTA = MYPAR(4) INCSKEW = MYPAR(5) INCSHAPE = MYPAR(6) NR = MYPAR(7) NS = MYPAR(8) NP = MYPAR(9) NQ = MYPAR(10) NORM = MYPAR(11) C DPARM XDELTA = DPARM(1) XSKEW = DPARM(2) XSHAPE = DPARM(3) C VECTOR START POSITIONS: IAR = INCMEAN + 1 IMA = INCMEAN+NR + 1 IOMEGA = INCMEAN+NR+NS + 1 IALPHA = INCMEAN+NR+NS+1 + 1 IBETA = INCMEAN+NR+NS+1+NP*(1+LEVERAGE) + 1 IDELTA = INCMEAN+NR+NS+1+NP*(1+LEVERAGE)+NQ + 1 ISKEW = INCMEAN+NR+NS+1+NP*(1+LEVERAGE)+NQ+INCDELTA + 1 ISHAPE = INCMEAN+NR+NS+1+NP*(1+LEVERAGE)+NQ+INCDELTA+INCSKEW+1 C TODO C INCLUDE MEAN? IF (INCMEAN.EQ.1) THEN XMEAN = X(1) ELSE XMEAN = 0.0D0 END IF C INCLUDE DELTA ? IF (INCDELTA.EQ.1) THEN XDELTA = X(IDELTA) END IF XINVD = 1.0D0/XDELTA C INCLUDE SKEW ? IF (INCSKEW.EQ.1) THEN XSKEW = X(ISKEW) END IF C INCLUDE SHAPE ? IF (INCSHAPE.EQ.1) THEN XSHAPE = X(ISHAPE) END IF C POSTION OMEGA: XOMEGA = X(IOMEGA) C ARMA RECURSION: DO I = 1, MAX(NR,NS) Z(I) = 0.0D0 END DO DO I = MAX(NR,NS)+1, N Z(I) = Y(I) - XMEAN NEXT = IAR DO IR = 1, NR, 1 Z(I) = Z(I) - X(NEXT)*Y(I-IR) NEXT = NEXT + 1 END DO NEXT = IMA DO IR = 1, NS, 1 Z(I) = Z(I) - X(NEXT)*Z(I-IR) NEXT = NEXT + 1 END DO END DO C COMPUTE (UNLEVERAGED) PERSISTENCE: SUMALPHA = 0.0D0 NEXT = IALPHA DO IP = 1, NP, 1 SUMALPHA = SUMALPHA + X(NEXT) NEXT = NEXT + 1 END DO NEXT = IBETA SUMBETA = 0.0D0 DO IP = 1, NQ, 1 SUMBETA = SUMBETA + X(NEXT) NEXT = NEXT + 1 END DO PERSISTENCE = SUMALPHA + SUMBETA C INITIALZE RECURSION - 1 (FCP) | 2 (TSP) LIKE: VAR = -99.D0 ! -Wall IF (INITREC.EQ.1) THEN VAR = 0.0D0 DO I = 1, N VAR = VAR + Z(I)**2 END DO VAR = VAR/N END IF IF (INITREC.EQ.2) THEN VAR = XOMEGA/(1.0D0-PERSISTENCE) END IF C ITERATE H: DO I = 1, MAX(NP,NQ) H(I) = XOMEGA + PERSISTENCE*VAR END DO IF (LEVERAGE.EQ.1) THEN DO I = MAX(NP,NQ)+1, N H(I) = XOMEGA NEXT = IALPHA DO IP = 1, NP, 1 ZI = DABS(Z(I-IP))-X(NEXT+NP)*Z(I-IP) H(I) = H(I) + X(NEXT)*DABS(ZI)**XDELTA NEXT = NEXT + 1 END DO NEXT = IBETA DO IQ = 1, NQ, 1 H(I) = H(I) + X(NEXT)*H(I-IQ) NEXT = NEXT + 1 END DO END DO ELSE DO I = MAX(NP,NQ)+1, N H(I) = XOMEGA NEXT = IALPHA DO IP = 1, NP, 1 H(I) = H(I) + X(NEXT)*DABS(Z(I-IP))**XDELTA NEXT = NEXT + 1 END DO NEXT = IBETA DO IQ = 1, NQ, 1 H(I) = H(I) + X(NEXT)*H(I-IQ) NEXT = NEXT + 1 END DO END DO END IF C COMPUTE LIKELIHOOD: LLH = 0.0D0 DO I = 1, N ZZ = Z(I) HH = DABS(H(I))**XINVD DD = DLOG( DIST(ZZ, HH, XSKEW, XSHAPE, MDIST) ) LLH = LLH - DD END DO F = LLH RETURN END fGarch/ChangeLog0000644000176200001440000001433015104730075013221 0ustar liggesusers2013-04-30 chalabi * DESCRIPTION, R/zzz.R, src/llhGarch.f: fix array bound warning in Fortran code 2012-09-18 chalabi * ChangeLog, DESCRIPTION: Updated ChangeLog and DESC files. * DESCRIPTION: Changed maintainer field to comply with the new CRAN policy. * inst/unitTests/runit.garchSolver.R: Removed superfluous unitTest. * NAMESPACE, R/loglik-aparch.R: Removed .filter2() to avoid external .Call calls. 2012-06-04 chalabi * R/garch-Hessian.R, inst/unitTests/runit.garchSolver.R: using now optimHess to calculate the Hessian * ChangeLog, DESCRIPTION: updated DESCRIPTION and ChangeLog files * DESCRIPTION, R/garch-Hessian.R: using now optimHess to calculate the Hessian 2011-09-23 mmaechler * DESCRIPTION: remove deprecated "LazyLoad" entry 2010-10-26 chalabi * NAMESPACE: updated NAMESPACE 2010-07-23 chalabi * inst/DocCopying.pdf: removed DocCopying.pdf license is already specified in DESCRIPTION file 2010-04-14 chalabi * NAMESPACE: updated NAMESPACE 2009-12-08 wuertz * inst/unitTests/runit.snorm.R: norm test obsolete * NAMESPACE, R/absMoments.R, R/dist-norm.R, R/dist-normFit.R, R/dist-snig.R, R/dist-snigFit.R, R/dist-stdSlider.R, man/absMoments.Rd, man/dist-absMoments.Rd, man/dist-ged.Rd, man/dist-gedFit.Rd, man/dist-gedSlider.Rd, man/dist-sged.Rd, man/dist-sgedFit.Rd, man/dist-sgedSlider.Rd, man/dist-snorm.Rd, man/dist-snormFit.Rd, man/dist-snormSlider.Rd, man/dist-sstd.Rd, man/dist-sstdFit.Rd, man/dist-sstdSlider.Rd, man/dist-std.Rd, man/dist-stdFit.Rd, man/dist-stdSlider.Rd: distribution functions updated * R/dist-stdSlider.R: stdslider added 2009-12-07 wuertz * R/dist-absMoments.R, R/dist-ged.R, R/dist-gedFit.R, R/dist-gedSlider.R, R/dist-norm.R, R/dist-normFit.R, R/dist-sged.R, R/dist-sgedFit.R, R/dist-sgedSlider.R, R/dist-snig.R, R/dist-snigFit.R, R/dist-snorm.R, R/dist-snormFit.R, R/dist-snormSlider.R, R/dist-sstd.R, R/dist-sstdFit.R, R/dist-sstdSlider.R, R/dist-std.R, R/dist-stdFit.R: distribution functions updated * man/dist-ged.Rd, man/dist-gedFit.Rd, man/dist-gedSlider.Rd, man/dist-sged.Rd, man/dist-sgedFit.Rd, man/dist-sgedSlider.Rd, man/dist-snorm.Rd, man/dist-sstd.Rd, man/sged.Rd, man/snorm.Rd, man/sstd.Rd: man pages updated 2009-11-09 chalabi * DESCRIPTION: updated version number * ChangeLog, DESCRIPTION: updated DESC and Changelog file 2009-11-05 chalabi * R/methods-predict.R: small changes in predict,fGARCH-method to correct its output when n.ahead=1 since addition of conditional errors. 2009-09-28 chalabi * DESCRIPTION: updated version number * ChangeLog, DESCRIPTION: updated DESCR and ChangeLog 2009-08-21 wuertz * DESCRIPTION, NAMESPACE, R/methods-plot.R, R/methods-show.R, R/mgarch-FitFromFormula.R: .gogarchFit function added, show and plot adapted, NAMESPACE and DESCRIPTION updated * R/methods-plot.R: Merge branch 'devel-fGarch' * man/methods-predict.Rd: cosmetic changes in help page * NAMESPACE: new NAMESPACE structure which should ease maintenance of packages. 2009-06-25 chalabi * DESCRIPTION, NAMESPACE: Merge branch 'devel-timeSeries' Conflicts: pkg/timeSeries/R/base-Extract.R pkg/timeSeries/R/timeSeries.R 2009-05-21 wuertz * NAMESPACE, R/garch-Distribution.R, R/garch-FitFromFormula.R, R/garch-FitFromSpec.R, R/garch-FitInternal.R, R/garch-LogLik.R, R/loglik-aparch.R, R/loglik-egarch.R, R/loglik.R, man/garchFit.Rd: working on new specification * DESCRIPTION, R/garch-Distribution.R, R/garch-FitFromFormula.R, R/garch-FitInternal.R, R/garch-Hessian.R, R/garch-LogLik.R, R/garch-Solver.R, man/garchFit.Rd: different recursion methods added, new method to calculate hessian added * R/garch-FitInternal.R, R/garch-LogLik.R: LLH function disentangled in shorter parts 2009-05-20 wuertz * R/garch-FitFromFormula.R, R/garch-FitFromSpec.R, R/garch-FitInternal.R: alternative garchFit interface (still hidden) now runs * NAMESPACE, R/fGarchEnv.R, R/garch-FitFromFormula.R: NAMESPACE updated * R/garch-FitFormula.R, R/garch-FitFromFormula.R, R/garch-FitInternal.R: R scripts disentangled and renamed * R/garch-FitFromFormula.R: script file renamed * R/garch-Fit.R, R/garch-FitControl.R, R/garch-FitFormula.R, R/garch-FitFromSpec.R, R/garch-FitInternal.R, R/garch-GlobalVars.R, R/garch-SolverControl.R: new interface for garchFit added, spec() based * NAMESPACE, R/garch-Distribution.R, R/garch-LogLik.R: some smaller fixes and NAMESPACE adapted * R/garch-Fit.R, R/garch-LogLik.R: garchLogLIk disentangled from script file garch-Fit.R * R/garch-Distribution.R, R/garch-Fit.R, R/garch-Initialization.R: Initialization disentangled from garch-Fit script file * R/dist-sged.R, R/dist-snig.R, R/dist-snorm.R, R/dist-sstd.R, R/garch-Distribution.R, R/garch-Fit.R, R/garch-FitControl.R, R/garch-Gradient.R, R/garch-Hessian.R, R/garch-Sim.R, R/garch-Solver.R, R/garch-Spec.R, R/garch-Stats.R, R/garchFit.R, R/garchFitControl.R, R/garchGradient.R, R/garchHessian.R, R/garchSim.R, R/garchSolver.R, R/garchSpec.R, R/garchStats.R, R/sged.R, R/snorm.R, R/sstd.R: script file renamed and disentangled 2009-05-15 chaussep * R/methods-predict.R, man/methods-predict.Rd: added a plot option to predict and adapted the manual 2009-05-15 chalabi * DESCRIPTION: added Pierre Chausse in DESC file for contribution 2009-05-14 chaussep * R/garchSim.R, man/garchSim.Rd: Just changed the definition of mu. It is the intercept, not the mean * R/methods-predict.R, man/methods-predict.Rd: Added conditional errors to predict and updated nthe manual 2009-04-19 chalabi * DESCRIPTION: added explicit version number in Depends field for key packages 2009-04-02 chalabi * DESCRIPTION: more explicit depends and suggests field in DESC file. 2009-04-01 chalabi * DESCRIPTION: updated DESC file 2009-01-30 chalabi * R/garchSpec.R: 2009-01-28 chalabi * DESCRIPTION: updated version number * DESCRIPTION: changed version number to match version on CRAN + 1 2009-01-12 chalabi * NAMESPACE, R/methods-update.R, man/class-fGARCH.Rd, man/class-fGARCHSPEC.Rd: added update method for fGARCH and fGARCHSPEC object 2009-01-07 chalabi * src/dist.f: fixed conditional distribution thanks to comments of Michal Miklovic. fGarch/NAMESPACE0000644000176200001440000000757615116750327012711 0ustar liggesusersuseDynLib("fGarch", .registration=TRUE) ## imports importFrom("timeDate", timeDate, timeSequence) importFrom("timeSeries", as.timeSeries, timeSeries ##, dummyDailySeries # in Examples and tests , description , isUnivariate, isMultivariate) importFrom("fBasics", Heaviside, jarqueberaTest ##, teffectPlot # used in test , dsnig, qsnig , volatility # we will re-export, as we define an S3 method , distCheck, .sliderMenu) ## importFrom("fastICA", fastICA)# only used in R/mgarch-FitFromFormula.R .gogarchFit() importFrom("cvar", VaR, ES) importFrom(Matrix, Matrix) # only in R/garch-Hessian.R importFrom("graphics", abline, grid, hist, legend, lines, par, polygon, title) importFrom("methods", new, show, slot, slotNames, is) importFrom("stats", Box.test, acf, arima, as.formula, ccf, tsdiag, density, dnorm, dt, filter, integrate, lm, model.frame, na.omit, nlminb, optim, optimHess, pchisq, pgamma, pnorm, ppoints, printCoefmat, pt, qgamma, qnorm, qt, quantile, rgamma, rnorm, rt, runif, sd, shapiro.test, summary.lm, terms, var) importFrom("utils", capture.output, menu) ## Exports S3method(print, summary_fGARCH) S3method(print, tsdiag_fGARCH) S3method(tsdiag, fGARCH) S3method(volatility, fGARCH) S3method(VaR, fGARCH) S3method(ES, fGARCH) exportClasses("fGARCH", "fGARCHSPEC", "fUGARCHSPEC" ) exportMethods("coef", "fitted", "formula", "plot", "predict", "residuals", "show", "summary", "update" ) export(timeSeries) # we import it from timeSeries export(volatility) # we import it from fBasics export(VaR, ES) # we import them from cvar export( ## export these '.xxx' for now ".gogarchFit", ".ugarchFit", ".ugarchSpec", "absMoments", "dged", "pged", "qged", "rged", "gedFit", "gedSlider", "dsged", "psged", "qsged", "rsged", "sgedFit", "sgedSlider", "dsnorm", "psnorm", "qsnorm", "rsnorm", "snormFit", "snormSlider", "dsstd", "psstd", "qsstd", "rsstd", "sstdFit", "sstdSlider", "dstd", "pstd", "qstd", "rstd", "stdFit", "stdSlider", "garchFit", "garchFitControl", "garchKappa", "garchSim", "garchSpec" ) ## ".aparchLLH.filter", ".aparchLLH.internal", ".aparchLLH.testing", ## ".gedFit", ".gedCondDist", ## ".QMLECondDist", ## ".normCondDist", ## ".dsged", ".psged", ".qsged", ".rsged", ".sgedFit", ".sgedCondDist", ## ".dsnorm", ".psnorm", ".qsnorm",".rsnorm", ".snormFit", ".snormCondDist", ## ".dsstd", ".psstd", ".qsstd", ".rsstd", ".sstdFit", ".sstdCondDist", ## ".stdFit", ".stdCondDist", ## ".snigCondDist", ## ".garchArgsParser", ## ".garchFit", ## ".garchInitParameters", ## ".garchInitSeries", ## ".garchKappaFun", ## ".garchLLH", ## ".garchModelSeries", ## ".garchNames", ## ".garchOptimizeLLH", ## ".garchOptimizerControl", ## ".garchRCDAGradient", ## ".garchRCDAHessian", ## ".garchRlbfgsb", ## ".garchRnlminb", ## ".garchRnm", ## ".garchRoptimhess", ## ".garchSetCondDist", ## ".garchTSHessian", ## ".getfGarchEnv", ".setfGarchEnv", ## ".hessian2sided", ## ".interactiveGarchPlot", ## GNB: these two may be worth exporting ## ".multGarchPlot", ## ".plot.garch.1", ## ".plot.garch.10", ## ".plot.garch.11", ## ".plot.garch.12", ## ".plot.garch.13", ## ".plot.garch.2", ## ".plot.garch.3", ## ".plot.garch.4", ## ".plot.garch.5", ## ".plot.garch.6", ## ".plot.garch.7", ## ".plot.garch.8", ## ".plot.garch.9", ## ".qqDist", ".qqLine", ## ".truePersistence", fGarch/NEWS.md0000644000176200001440000002355415116751326012562 0ustar liggesusers## CHANGES in fGarch VERSION 4052.93 (2024-12-12, svn r6482–r6544) - emphasised that the skew normal distribution in fGarch is different from what is usually called skew normal distribution. Similarly for the other skew distributions. - replaced a call to 'warnings' (plural) with 'warning' (singular, a different function) in `garchSpec`. The old one was clearly a typo and was not issuing the intended warning about the violation of the stationarity condition for GARCH models. - improved the layout of the reference section of the pkgdown site. - edited the help page of class `"fGARCH"`. In particular, added cross-references to the help pages of the individual methods. ## CHANGES in fGarch VERSION 4033.92 (2024-03-26, svn r6481–r6481) - added VaR and ES plots to the `plot` method for fitted GARCH models. - documented with examples that argument `which` of the plot method for fitted GARCH objects can be of length greater than one. - added a link to the website created with pkgdown to file 'DESCRIPTION'. ## CHANGES in fGarch VERSION 4032.91 (2024-02-02, svn r6436–r6479) - added computation of Value-at-Risk (VaR) and expected shortfall (ES) for fitted GARCH and APARCH models (in-sample and in the predict method). Just use something like `Var(fitted_object)`, `ES(fitted_object)` or `predict(fitted_object, ..., p_loss = 0.05)`. ## CHANGES in fGarch VERSION 4022.90 (2023-10-15, svn r6333–r6435) - added `"fGARCH"` method for `stats::tsdiag`. The method produces diagnostic plot for fitted GARCH/APARCH models and computes some diagnostic tests. The plots can be chosen interactively and/or via arguments. The test results are in the returned value. The method is in development in that more plots may be made available and additional tests included in the returned value. - refactored the `"fGARCH"` method for 'summary' to return an object from S3 class 'summary\_fGARCH' equipped with a 'print' method. The printout is the same as before, except that now the numbers in the statistics column for the residual diagnostics are aligned on the decimal point (previously they were left-aligned due to a buglet). - the `"fGARCH"` method for `fitted` was returning the data, not the fitted values. Fixes issue 6789, reported by Kouhei Hashinokuchi (hakoshie). - the help pages for the `"fGARCH"` methods for `fitted()` and `residuals()` were stating that the returned results have the same class as the input time series. Actually, they return numeric vectors. (todo?: to make the returned values as previously documented, `garchFit()` would need to put the original data or the necessary information in the fitted object, e.g., `object@fit$data`. - some tests were using deprecated `fBasics::.distCheck()` (notice the leading dot). Replaced such calls with the equivalent `fBasics::distCheck()`. ## CHANGES in fGarch VERSION 4022.89 (2022-11-05, from svn r6316–r6326) - in `absMoments`, the absolute moments for the standardized Student-t distribution were wrong. - in README, linked to the paper by Wuertz et al. - substantially revised the documentation and filled gaps in it. - removed the functions with suffix '\_orig' which were kept temporarilly after the bug fix in v4021.87 since there were no reported problems with the fix. ## CHANGES in fGarch VERSION 4021.88 (2022-09-28, svn r6276) - require Matrix (>= 1.5-0) to avoid problems for users who have earlier versions of Matrix on their devices (thanks to Mikael Jagan for checking for not strict enough dependency on Matrix and alerting the maintainer). ## CHANGES in fGarch VERSION 4021.87 (2022-08-06, svn r6215–r6265) ### NEW MAINTAINER - Georgi N. Boshnakov ### VERSION NUMBERS - We continue to use the traditional Rmetrics scheme for numbering the versions of the package as Mmmr.n, where 'M' is the current major R version at the time of submission of the package to CRAN, 'mm' is the minor one and 'r' is the revision. 'n' is the sequential number of the CRAN submission of the package. For example, this release has version 4021.87 since it was released when R 4.2.1 was current and 'n' in the previous version was 86. ### BUG FIXES Fixed issue 6061 raised by William Scott, who also supplied examples. - The quantile function, `qsnorm`, was wrong around 0.5. The error was in `.qsnorm`. For now its version before the fix is kept as `.qsnorm_orig`. Basically, branching was done w.r.t. `p = 0.5`, which is correct only for the symmetric case, `\xi = 1`, and should be `1/(1+\xi^2)` instead. More details in the source code. The error was affecting the central part of the distrbution with the interval becoming larger for `\xi` further away from 1. - The cdf, `psnorm`, had an error at a single point, coinciding with the wrong value for `p = 0.5` returned by `qsnorm(0.5)` before the fix. The result was that `psnorm(qsnorm(0.5))` was returning 0.5, falsely giving reassurance that `qsnorm(0.5)` was correct. - Not mentioned in issue 6061 but the same problems held for the other skewed distributions: `qsstd`, `psstd`, `qsged`, `psged`. The original versions of the relevant internal functions are kept for now with a suffix `_orig`, as above: `qsstd_orig`, `psstd_orig`, `qsged_orig`, `psged_orig`. ### Documentation - Edited the documentation of `"garchSpec"` and `garchSim`. It was somewhat incomplete and contained leftovers, apparently from old versions of the functions. - Documented the datasets. Previously the help page for them was a placeholder, without the names of the available datasets. There is no information about the time span of the data or how the returns were calculated. ## CHANGES in fGarch VERSION 4021.86 (2022-06-23, svn r6188) ### NEW MAINTAINER - Tobias Setz ### Notes - This is a CRAN release of version 4001.1, with trivial changes in ‘DESCRIPTION’. ## CHANGES in fGarch VERSION 4001.1 (2022-06-23, svn r6184–r6185) ### NEW MAINTAINER - ad interim: Martin Maechler ### NEW FEATURES - Packages [timeSeries](https://CRAN.R-project.org/package=timeSeries), [timeDate](https://CRAN.R-project.org/package=timeDate) and [fBasics](https://CRAN.R-project.org/package=fBasics) are no longer in `Depends`, but only in `Imports` and hence no longer automatically attached to the `search()` path whenever fGarch is. This may require updates in your code, e.g., adding stopifnot(require("timeSeries")) as it has been done in our own fGarch's examples and tests. - `.gogarchFit()` is at least *mentioned* in the documentation. ### BUG FIXES - Added registration of compiled functionality for speed up and as good practice. - Removed all `Depends:` entries and checked exactly which parts of packages, notably fBasics, timeDate, and timeSeries, are needed and imported only these. - Eliminated warning about 'length > 1' character formula in `garchFit()`, i.e., `.garchFit()`. - Replaced the error-prone checking for 'class()' equality by 'inherits(\*, <class>)'. ### Misc - Exporting practically everything seems “wrong†(according to MM): Several `.` functions have *no* documentation and hence should either be (renamed and) documented or no longer be exported. - a `data` argument should never have a default: hence removed from `garchFit()`. ## CHANGES in fGarch, VERSION 3042.83.2 (2020-03-07, CRAN team) ### Misc - in ‘dist-norm.Rd’, removed the description of argument `...`, which is not in the argument list of any function described there. ## CHANGES in fGarch, VERSION 3042.83.1 (2019-01-31, CRAN team) ### Misc - in ‘NAMESPACE’ and ‘R/methods-plot.R’ renamed functions `.plot.garch.1`, ..., `.plot.garch.13` to `.plot.garch_1`, ..., `.plot.garch_13`. - compressed datasets ‘data/dem2gbp.csv’ and ‘data/sp500dge.csv’ to ‘data/dem2gbp.csv.bz2’ ‘data/sp500dge.csv.bz2’, respectively. ## CHANGES in fGarch, VERSION 3042.83 (2017-11-16, svn r...) ### Misc - Startup message removed - Incorporate fixes by CRAN team (Brian Ripley?) - Checks and adaptions for R 3.4.2, e.g., ‘DESCRIPTION’, ... ## CHANGES in fGarch, VERSION 3010.82.1 (2016-08-14, CRAN team.) ### Misc - in ‘NAMESPACE’, import (selectively) from utils. - changed a couple of calls to `Matrix()` from package Matrix and `fastICA()` from fastICA to the fully qualified forms `Matrix::Matrix()` and `fastICA::fastICA`. - removed some flag settings in ‘Makevars’. - in ‘math.f’, move a `DATA` command out of the body of an `"if"` block putting it towards the beginning of the file. ## CHANGES in fGarch, VERSION 3010.82 (2013-04-30, svn r5509) – and earlier ### ChangeLog - Changes up to April 2013, by Yohan Chalabi, Diethelm Wuertz, Pierre Chausse and Martin Maechler are all in file ‘ChangeLog’. fGarch/inst/0000755000176200001440000000000015104730075012423 5ustar liggesusersfGarch/inst/THANKS0000644000176200001440000000035515104730075013341 0ustar liggesusersThe Rmetrics core team would like to thank the following people for ideas, testing and feedback regarding fGarch: Michal Miklovic Kris Kris Spencer Graves fGarch/inst/pkgdown.yml0000644000176200001440000000032015105323016014604 0ustar liggesuserspandoc: 3.1.3 pkgdown: 2.1.3 pkgdown_sha: ~ articles: {} last_built: 2025-11-13T09:34Z urls: reference: https://geobosh.github.io/fGarchDoc/reference article: https://geobosh.github.io/fGarchDoc/articles fGarch/inst/_pkgdown.yml0000644000176200001440000000357115104730075014764 0ustar liggesusersurl: https://geobosh.github.io/fGarchDoc/ deploy: install_metadata: true template: bootstrap: 5 search: exclude: ['news/index.html'] reference: - title: "Overview of package fGarch" contents: - "fGarch-package" - fGarch - fGarchData - garchSim - dem2gbp - sp500dge - title: "Fit GARCH-type models" contents: - garchFit - .gogarchFit - garchKappa - garchSpec - garchFitControl - title: "Classes" contents: - "fGARCH-class" - "show,fGARCH-method" - "fGARCHSPEC-class" - "show,fGARCHSPEC-method" - title: "Exploring and computing on 'fGARCH' objects" contents: - tsdiag.fGARCH - "plot,fGARCH,missing-method" - "summary-methods" - "summary,fGARCH-method" - "coef-methods" - "coef,fGARCH-method" - "coef,fGARCHSPEC-method" - "fitted-methods" - "fitted,fGARCH-method" - "formula-methods" - "formula,fGARCH-method" - "predict,fGARCH-method" - "residuals,fGARCH-method" - volatility - VaR.fGARCH - ES.fGARCH - title: "Standardized distributions" contents: - absMoments - dstd - pstd - qstd - rstd - dged - pged - qged - rged - title: "Skewed standardized distributions" contents: - dsnorm - psnorm - qsnorm - rsnorm - dsstd - psstd - qsstd - rsstd - dsged - psged - qsged - rsged - title: "Fit standardized distributions" contents: - stdFit - gedFit - snormFit - sstdFit - sgedFit - title: "Visualize standardized distributions" contents: - stdSlider - gedSlider - snormSlider - sstdSlider - sgedSlider - title: "Internal functions and classes" contents: - "fUGARCHSPEC-class" fGarch/inst/unitTests/0000755000176200001440000000000015104730075014425 5ustar liggesusersfGarch/inst/unitTests/runit.garchFit.R0000644000176200001440000000625515104730075017447 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ # garchFit( # formula, # data, # init.rec = c("mci", "uev"), # delta = 2, # skew = 1, # shape = 4, # cond.dist = c("dnorm", "dsnorm", "dged", "dsged", "dstd", "dsstd"), # include.mean = TRUE, # include.delta = NULL, # include.skew = NULL, # include.shape = NULL, # leverage = NULL, # trace = TRUE, # algorithm = c("sqp", "nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), # control = list(), # title = NULL, # description = NULL, # ...) # ------------------------------------------------------------------------------ test.garchInputSeries <- function() { # Numeric Vector RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate normal GARCH(1, 1) numeric Vector: model = list(omega = 1e-06, alpha = 0.1, beta = 0.8) spec = garchSpec(model) print(spec) N = 10 # UNIVARIATE: # A numeric Vector: x.vec = as.vector(100*garchSim(spec, N)) print(head(x.vec)) x.tS = timeSeries::dummyDailySeries(matrix(x.vec), units = "GARCH11") print(head(x.tS)) # x.zoo = zoo(as.vector(x.vec), order.by = as.Date(rownames(x.tS))) # print(head(x.zoo)) x.ts = ts(x.vec) print(head(x.ts)) # MULTIVARIATE: # A numeric matrix: X.mat = cbind(GARCH11 = x.vec, R = rnorm(N)) print(head(X.mat)) X.tS = timeSeries::dummyDailySeries(X.mat, units = c("GARCH11", "R")) print(head(X.tS)) # X.zoo = zoo(X.mat, order.by = as.Date(rownames(x.tS))) # print(head(X.zoo)) X.mts = ts(X.mat) print(head(X.mts)) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchFit.init.R0000644000176200001440000000427415104730075020410 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ test.garchFit.init <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate Garch(1,1) Series: x = garchSim(n = 250) # Modify Start Values - mci default: fit = garchFit( ~ garch(1,1), x, init.rec = "mci", trace = FALSE) # default print(coef(fit)) # Modify Start Values - uev alternative: # fit = garchFit( ~ garch(1,1), x, init.rec = "uev", trace = FALSE) # Error in .garchFit(formula.mean = args$formula.mean, formula.var = args$formula.var, : # Algorithm only supported for mci Recursion # coef(fit) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/Makefile0000644000176200001440000000041715116751403016070 0ustar liggesusersPKG=fGarch TOP=../.. SUITE=doRUnit.R R=R all: inst test inst: # Install package -- but where ?? -- will that be in R_LIBS ? cd ${TOP}/..;\ ${R} CMD INSTALL ${PKG} test: # Run unit tests export RCMDCHECK=FALSE;\ cd ${TOP}/tests;\ ${R} --vanilla --slave < ${SUITE} fGarch/inst/unitTests/runit.sstd.R0000644000176200001440000001071515104730075016671 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: VARIANCE-1 STUDENT-T DISTRIBUTION: # dstd Density for the Student-t Distribution # pstd Probability function for the Student-t Distribution # qstd Quantile function for the Student-t Distribution # rstd Random Number Generator for the Student-t # FUNCTION: SKEW VARIANCE-1 STUDENT-T DISTRIBUTION: # dsstd Density for the skewed Student-t Distribution # psstd Probability function for the skewed STD # qsstd Quantile function for the skewed STD # rsstd Random Number Generator for the skewed STD # stdSlider Displays Variance-1 Student-t Distribution and RVS # FUNCTION: PARAMETER ESTIMATION: # stdFit Fit the parameters for a Sudent-t distribution # sstdFit Fit the parameters for a skew Sudent-t distribution ################################################################################ test.sstdDist <- function() { # Standardized Student-t Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Test: test = fBasics::distCheck("std", mean = 0, sd = 1, nu = 5, robust = FALSE) print(test) # Skew Standardized Student-t Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Test: test = fBasics::distCheck("sstd", mean = 0, sd = 1, nu = 5, xi = 1.5, robust = FALSE) print(test) # Return Value: return() } # ------------------------------------------------------------------------------ test.stdFit <- function() { # Fit the parameters for a Student-t distribution # stdFit - Fit the parameters for a Sudent-t distribution # Standardized Student-t Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Series: x = rstd(n = 2500, mean = 0, sd = 1, nu = 5) # Fit: fit = stdFit(x) print(fit) # Fit the parameters for a skew Sudent-t distribution # sstdFit - Fit the parameters for a Sudent-t distribution # Skew Standardized Student-t Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Series: x = rsstd(n = 2500, mean = 0, sd = 1, nu = 5, xi = 1.5) # Fit: fit = sstdFit(x) print(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.sstdSlider <- function() { # Try Distribution: # sstdSlider(type = "dist") NA # Try Random Variates: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # sstdSlider(type = "rand") NA # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchFit.algorithm.R0000644000176200001440000001050115104730075021421 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ test.garchFit.nlminb <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Load Data: x = garchSim(n = 100) # Algorithms: # "nlminb", "sqp", "lbfgsb", "nlminb+nm", "lbfgsb+nm" # nlminb: fit = garchFit( ~ garch(1,1), data = x, algorithm = "nlminb", trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.sqp <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Load Data: x = garchSim(n = 100) # Algorithms: # "nlminb", "sqp", "lbfgsb", "nlminb+nm", "lbfgsb+nm" ### # sqp: ### fit = garchFit( ~ garch(1,1), data = x, ### algorithm = "sqp", trace = FALSE) ### print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.lbfgsb <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Load Data: x = garchSim(n = 100) # Algorithms: # "nlminb", "sqp", "lbfgsb", "nlminb+nm", "lbfgsb+nm" # lbfgsb: fit = garchFit( ~ garch(1,1), data = x, algorithm = "lbfgsb", trace = FALSE) coef(fit) # nlminb+nm: fit = garchFit( ~ garch(1,1), data = x, algorithm = "nlminb+nm", trace = FALSE) coef(fit) # lbfgsb+nm: fit = garchFit( ~ garch(1,1), data = x, algorithm = "lbfgsb+nm", trace = FALSE) coef(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.nlmin.nm <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Load Data: x = garchSim(n = 100) # Algorithms: # "nlminb", "sqp", "lbfgsb", "nlminb+nm", "lbfgsb+nm" # nlminb+nm: fit = garchFit( ~ garch(1,1), data = x, algorithm = "nlminb+nm", trace = FALSE) coef(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.lbfgsb.nm <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Load Data: x = garchSim(n = 100) # Algorithms: # "nlminb", "sqp", "lbfgsb", "nlminb+nm", "lbfgsb+nm" # lbfgsb+nm: fit = garchFit( ~ garch(1,1), data = x, algorithm = "lbfgsb+nm", trace = FALSE) coef(fit) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchSim.R0000644000176200001440000001224615104730075017452 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: SIMULATION: # garchSim Simulates a GARCH/APARCH process ################################################################################ test.garchSim.arch = function() { # Simulation of ARCH Models: # ARCH(1) - default omega and alpha spec = garchSpec(model = list()) garchSim(n = 10, spec = spec) # ARCH(1) - default omega spec = garchSpec(model = list(alpha = 0.1)) garchSim(n = 10, spec = spec) # ARCH(1) spec = garchSpec(model = list(omega = 1e-6, alpha = 0.1)) garchSim(n = 10, spec = spec) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchSim.arma.arch = function() { # Simulation of ARMA-ARCH Models: # AR(1)-ARCH(1) spec = garchSpec(model = list(ar = 0.5)) garchSim(n = 10, spec = spec) # AR([1,5])-ARCH(1) spec = garchSpec(model = list(ar = c(0.5, 0, 0, 0 ,0.1))) garchSim(n = 10, spec = spec) # ARMA(1,2)-ARCH(1) spec = garchSpec(model = list(ar = 0.5, ma = c(0.3,-0.3))) garchSim(n = 10, spec = spec) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchSim.dist.arch = function() { # Simulation of non-normal ARCH Models: # rsnorn-ARCH(2) spec = garchSpec(model = list(alpha = c(0.12, 0.04), dist = 2/3), cond.dist = "snorm") garchSim(n = 10, spec = spec) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchSim.garch = function() { # Simulation of GARCH Models: # GARCH(1,1) spec = garchSpec() garchSim(n = 10, spec = spec) # GARCH(1,1) spec = garchSpec(model = list(alpha = 0.1, beta = 0.8)) garchSim(n = 10, spec = spec) # GARCH(1,1) spec = garchSpec(model = list(omega = 1e-6, alpha = 0.1, beta = 0.8)) garchSim(n = 10, spec = spec) # GARCH(1,2) spec = garchSpec(model = list(alpha = 0.1, beta = c(0.4, 0.4))) garchSim(n = 10, spec = spec) # GARCH(2,1) spec = garchSpec(model = list(alpha = c(0.12, 0.04), beta = 0.08)) garchSim(n = 10, spec = spec) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchSim.dist.garch = function() { # Simulation of non-normal GARCH Models: # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Normal - GARCH(1,1) spec = garchSpec(model = list(), cond.dist = "norm") garchSim(n = 10, spec = spec) # Skewed Normal - GARCH(1,1) spec = garchSpec(model = list(parm = 2), cond.dist = "snorm") garchSim(n = 10, spec = spec) # GED - GARCH(1,1) spec = garchSpec(model = list(parm = 4), cond.dist = "ged") garchSim(n = 10, spec = spec) # Skewed GED - GARCH(1,1) spec = garchSpec(model = list(parm = c(4, 2)), cond.dist = "sged") garchSim(n = 10, spec = spec) # Normalized Student t - GARCH(1,1) spec = garchSpec(model = list(parm = 4), cond.dist = "std") garchSim(n = 10, spec = spec) # Skewed Normalized Student t - GARCH(1,1) spec = garchSpec(model = list(parm = c(4, 2)), cond.dist = "sstd") garchSim(n = 10, spec = spec) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchSim.aparch = function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Taylor Schwert Normal GARCH(1,1) spec = garchSpec(list(alpha = 0.1, delta = 1)) garchSim(n = 10, spec = spec) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchFit.garch.R0000644000176200001440000000735215104730075020531 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ # garchFit( # formula, # data, # init.rec = c("mci", "uev"), # delta = 2, # skew = 1, # shape = 4, # cond.dist = c("dnorm", "dsnorm", "dged", "dsged", "dstd", "dsstd"), # include.mean = TRUE, # include.delta = NULL, # include.skew = NULL, # include.shape = NULL, # leverage = NULL, # trace = TRUE, # algorithm = c("sqp", "nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), # control = list(), # title = NULL, # description = NULL, # ...) # ------------------------------------------------------------------------------ test.garchFit.garch11 <- function() { # Use Simulated Series - an Object of class 'ts' ... # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Normal GARCH(1, 1) x = garchSim(n = 250) # Fit: fit = garchFit( ~ garch(1,1), data = x, trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.garch21 <- function() { # Use Simulated Series - an Object of class 'ts' ... # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Normal-GARCH(2, 1) model = list(omega = 1e-06, alpha = c(0.1, 0.2), beta = 0.6) spec = garchSpec(model) x = garchSim(spec = spec, n = 250) # Fit fit = garchFit( ~ garch(2,1), data = x, trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.ar1garch11 <- function() { # Use Simulated Series - an Object of class 'ts' ... # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Normal AR(1)-GARCH(1,1): model = list(omega = 1e-06, ar = -0.1, alpha = c(0.1, 0.2), beta = 0.6) spec = garchSpec(model) x = garchSim(spec = spec, n = 250) # Fit: fit = garchFit(~ arma(1,0) + garch(1,1), data = x, trace = FALSE) print(coef(fit)) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runTests.R0000644000176200001440000000452615104730075016406 0ustar liggesuserspkg <- "fGarch" if(require("RUnit", quietly = TRUE)) { library(package=pkg, character.only = TRUE) if(!(exists("path") && file.exists(path))) path <- system.file("unitTests", package = pkg) ## --- Testing --- ## Define tests testSuite <- defineTestSuite(name = paste(pkg, "unit testing"), dirs = path) if(interactive()) { cat("Now have RUnit Test Suite 'testSuite' for package '", pkg, "' :\n", sep='') str(testSuite) cat('', "Consider doing", "\t tests <- runTestSuite(testSuite)", "\nand later", "\t printTextProtocol(tests)", '', sep = "\n") } else { ## run from shell / Rscript / R CMD Batch / ... ## Run tests <- runTestSuite(testSuite) if(file.access(path, 02) != 0) { ## cannot write to path -> use writable one tdir <- tempfile(paste(pkg, "unitTests", sep="_")) dir.create(tdir) pathReport <- file.path(tdir, "report") cat("RUnit reports are written into ", tdir, "/report.(txt|html)", sep = "") } else { pathReport <- file.path(path, "report") } ## Print Results: printTextProtocol(tests, showDetails = FALSE) printTextProtocol(tests, showDetails = FALSE, fileName = paste(pathReport, "Summary.txt", sep = "")) printTextProtocol(tests, showDetails = TRUE, fileName = paste(pathReport, ".txt", sep = "")) ## Print HTML Version to a File: ## printHTMLProtocol has problems on Mac OS X if (Sys.info()["sysname"] != "Darwin") printHTMLProtocol(tests, fileName = paste(pathReport, ".html", sep = "")) ## stop() if there are any failures i.e. FALSE to unit test. ## This will cause R CMD check to return error and stop tmp <- getErrors(tests) if(tmp$nFail > 0 | tmp$nErr > 0) { stop(paste("\n\nunit testing failed (#test failures: ", tmp$nFail, ", R errors: ", tmp$nErr, ")\n\n", sep="")) } } } else { cat("R package 'RUnit' cannot be loaded -- no unit tests run\n", "for package", pkg,"\n") } ################################################################################ fGarch/inst/unitTests/runit.bugfix_6061.R0000644000176200001440000000105615104730075017652 0ustar liggesuserstest.bugfix_6061 <- function() { ## 2022-07-27 GB check fixes related to issue #6061, see NEWS and the source code stopifnot( all( diff(qsnorm(c(0.49, 0.5, 0.51))) > 0) ) stopifnot( all( diff(psnorm(qsged(c(0.49, 0.5, 0.51)))) > 0) ) stopifnot( all( diff(qsstd(c(0.49, 0.5, 0.51))) > 0) ) stopifnot( all( diff(psstd(qsged(c(0.49, 0.5, 0.51)))) > 0) ) stopifnot( all( diff(qsged(c(0.49, 0.5, 0.51))) > 0) ) stopifnot( all( diff(psged(qsged(c(0.49, 0.5, 0.51)))) > 0) ) # Return Value: return() } fGarch/inst/unitTests/runit.snorm.R0000644000176200001440000000707215104730075017054 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: SKEW NORMAL DISTRIBUTION: # dsnorm Density for the skew normal Distribution # psnorm Probability function for the skew NORM # qsnorm Quantile function for the skew NORM # rsnorm Random Number Generator for the skew NORM # FUNCTION: PARAMETER ESTIMATION: # snormFit Fit the parameters for a skew Normal distribution # FUNCTION: SLIDER: # snormSlider Displays Normal Distribution and RVS ################################################################################ test.snormDist <- function() { # Normal Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Test: test = fBasics::distCheck("norm", mean = 0, sd = 1, robust = FALSE) print(test) checkTrue(sum(test) == 3) # Skew Normal Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Test: test = fBasics::distCheck("snorm", mean = 0, sd = 1, xi = 1.5, robust = FALSE) print(test) checkTrue(sum(test) == 3) # Return Value: return() } # ------------------------------------------------------------------------------ test.snormFit <- function() { # Parameter Estimation: # snormFit - Fit the parameters for a skew Normal distribution # Skew Normal Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Series: x = rsnorm(n = 1000, mean = 0, sd = 1, xi = 1.5) # Fit: fit = snormFit(x) print(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.snormSlider <- function() { # Try Distribution: # snormSlider(type = "dist") NA # Try Random Variates: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # snormSlider(type = "rand") NA # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchSpec.R0000644000176200001440000000777215104730075017624 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: SPECIFICATION: # 'garchSpec' S4: garchSpec Class representation # garchSpec S4: Creates a 'garchSpec' object from scratch # show.garchSpec S4: Print method for an object of class 'garchSpec' ################################################################################ test.garchSpec = function() { # ARCH(1) - use default omega and default alpha[1] garchSpec(model = list()) # ARCH(1) - use default omega and specify alpha garchSpec(model = list(alpha = 0.2)) # ARCH(1) - specify omega and alpha garchSpec(model = list(omega = 3.0e-6, alpha = 0.3)) # AR(1)-ARCH(1) - use default omega/alpha and specify alpha[1] garchSpec(model = list(ar = 0.5)) # AR([1,5])-ARCH(1) - use default omega, specify alpha and subset ar[.] garchSpec(model = list(ar = c(0.5,0,0,0,0.1), alpha = 0.25)) # ARMA(1,2)-ARCH(1) - use default omega/alpha and specify ar[1]/ma[2] garchSpec(model = list(ar = 0.5, ma = c(0.3, -0.3))) # ARMA(2,2)-ARCH(1) use default omega/alpha and specify ar[2]/ma[2] garchSpec(model = list(ar = c(0.5, -0.5), ma = c(0.3,-0.3))) # ARCH(2) - use default omega and specify alpha[2] garchSpec(model = list(alpha = c(0.12, 0.04))) # GARCH(1,1) - use just defaults garchSpec() # GARCH(1,1) - use default omega and specify alpha/beta garchSpec(model = list(alpha = 0.2, beta = 0.7)) # GARCH(1,1) - specify omega/alpha/beta garchSpec(model = list(omega = 1e-6, alpha = 0.1, beta = 0.8)) # GARCH(1,2) - use default omega and specify alpha[1]/beta[2] garchSpec(model = list(alpha = 0.1, beta = c(0.4, 0.4))) # GARCH(2,1) - use default omega and specify alpha[2]/beta[1] garchSpec(model = list(alpha = c(0.12, 0.04), beta = 0.08)) # rsnorm-ARCH(1) - use defaults with skew Normal garchSpec(model = list(dist = 2), cond.dist = "snorm") # rged-ARCH(1) using default omega and alpha[1] garchSpec(model = list(dist = 4), cond.dist = "ged") # rsged-ARCH(1) using default omega and alpha[1] garchSpec(model = list(dist = c(4, 2)), cond.dist = "sged") # rstd-ARCH(1) using default omega and alpha[1] garchSpec(model = list(dist = 4), cond.dist = "std") # rsstd-ARCH(1) using default omega and alpha[1] garchSpec(model = list(dist = c(4, 2)), cond.dist = "sstd") # TS-GARCH(1,1) garchSpec(model = list(delta = 1)) # AR(1)-t-APARCH(2, 1) garchSpec(model = list(mu = 1.0e-4, ar = 0.5, omega = 1.0e-6, alpha = c(0.10, 0.05), gamma = c(0, 0), beta = 0.8, delta = 1.8, dist = c(nu = 4, xi = 0.5)), cond.dist = "sstd") # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garch-methods.R0000644000176200001440000000524515104730075020443 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # METHODS: DESCRIPTION: # show.fGARCH S4 print method for an object of class 'fGARCH' # summary.fGARCH S3 summary method for an object of class 'fGARCH' # plot.fGARCH S3 plot method for an object of class 'fGARCH' # residuals.fGARCH S3 residuals method for an object of class 'fGARCH' # fitted.fGARCH S3 fitted values for an object of class 'fGARCH' # predict.fGARCH S3 prediction method for an object of class 'fGARCH' # STATISTICS: Description: # .truePersistence Compute persistence ################################################################################ test.garch.methods.show <- function() { # show.fGARCH - S4 print method for an object of class 'fGARCH' # Garch(1,1) Default Model: x = garchSim(n = 250) # Fit: fit = garchFit( ~ garch(1,1), data = x, trace = FALSE) # Note: # Does also work: # fit = garchFit(dem2gbp ~garch(1,1), data = dem2gbp, trace = FALSE) # Note: # fit = garchFit(DEM2GBP ~garch(1,1), data = dem2gbp, trace = FALSE) # [1] "DEM2GBP" # [1] "dem2gbp" # Error in .garchArgsParser(formula = formula, data = data, trace = FALSE) : # Formula and data units do not match. # Print: print(fit) show(fit) # Summary: summary(fit) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.plot-methods.R0000644000176200001440000001423215104730075020331 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ test.plot.methods1 <- function() { # Load data: data(dem2gbp) dem2gbp = as.vector(dem2gbp[, 1]) # Fit to normal Conditional Distribution: fit = garchFit( ~ garch(1, 1), data = dem2gbp, trace = FALSE) print(fit) # garchFit 1: # 1: # 2: # Graph Frame: par(mfrow = c(2, 1)) # Plot 1: plot(fit, which = 1) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 2: plot(fit, which = 2) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Return Value: return() } # ------------------------------------------------------------------------------ test.plot.methods2 <- function() { # Load data: data(dem2gbp) # Fit to normal Conditional Distribution: fit = garchFit( ~ garch(1, 1), data = dem2gbp, trace = FALSE) print(fit) # garchFit 2: # Graph Frame: par(mfrow = c(1, 1)) # Plot 3: plot(fit, which = 3) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Return Value: return() } # ------------------------------------------------------------------------------ test.plot.methods3 <- function() { # Load data: data(dem2gbp) # Fit to normal Conditional Distribution: fit = garchFit( ~ garch(1, 1), data = dem2gbp, trace = FALSE) print(fit) # garchFit3: # 3: # 4: # 5: # Graph Frame: par(mfrow = c(2, 1)) # Plot 4: plot(fit, which = 4) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 5: plot(fit, which = 5) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Return Value: return() } # ------------------------------------------------------------------------------ test.plot.methods4 <- function() { # Load data: data(dem2gbp) # Fit to normal Conditional Distribution: fit = garchFit( ~ garch(1, 1), data = dem2gbp, trace = FALSE) print(fit) # garchFit4: # 6: Cross Correlation # 7: Residuals # 8: Conditional SDs # 9: Standardized Residuals # Graph Frame: par(mfrow = c(2, 2)) # Plot 6: plot(fit, which = 6) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 7: plot(fit, which = 7) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 8: plot(fit, which = 8) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 9: plot(fit, which = 9) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Return Value: return() } # ------------------------------------------------------------------------------ test.plot.methods5 <- function() { # Load data: data(dem2gbp) # Fit to normal Conditional Distribution: fit = garchFit( ~ garch(1, 1), data = dem2gbp, trace = FALSE) print(fit) # garchFit5: # 10: ACF of Standardized Residuals # 11: ACF of Squared Standardized Residuals # 12: Cross Correlation between r^2 and r # 13: QQ-Plot of Standardized Residuals # Graph Frame: par(mfrow = c(2, 2)) # Plot 10: plot(fit, which = 10) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 11: plot(fit, which = 11) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 12: plot(fit, which = 12) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Plot 13: plot(fit, which = 13) mtext("norm-GARCH(1,1) Modeling", line = 0.5, cex = 0.8) mtext("DEM2GBP Data Vector", side = 4, adj = 0, cex = 0.7, col = "darkgrey") # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.sged.R0000644000176200001440000001075115104730075016636 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: GED DISTRIBUTION: # dged Density for the Generalized Error Distribution # pged Probability function for the GED # qged Quantile function for the GED # rged Random Number Generator for the GED # FUNCTION: SKEW GED DISTRIBUTION: # dsged Density for the skewed GED # psged Probability function for the skewed GED # qsged Quantile function for the skewed GED # rsged Random Number Generator for the skewed GED # FUNCTION: GED DISTRIBUTION SLIDER: # sgedSlider Displays Generalized Error Distribution and RVS # FUNCTION: PARAMETER ESTIMATION: # gedFit Fit the parameters for a GED distribution # sgedFit Fit the parameters for a skew GED distribution # FUNCTION: MOMENTS: ################################################################################ test.sgedDis <- function() { # Generalized Error Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Test: test = fBasics::distCheck("ged", mean = 0, sd = 1, nu = 2, robust = FALSE) print(test) # Skew Generalized Error Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(1953, kind = "Marsaglia-Multicarry") test = fBasics::distCheck("sged", mean = 0, sd = 1, nu = 2, xi = 0.8, robust = FALSE) print(test) ## 2022-07-27 GB check fixes related to issue #6061, see NEWS and the source code stopifnot( all( diff(qsged(c(0.49, 0.5, 0.51))) > 0) ) stopifnot( all( diff(psged(qsged(c(0.49, 0.5, 0.51)))) > 0) ) # Return Value: return() } # ------------------------------------------------------------------------------ test.sgedFit <- function() { # Parameter Estimation: # gedFit - Fit the parameters for a GED distribution # Generalized Error Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Series: x = rged(1000, mean = 0, nu = 2) # Fit: fit = gedFit(x) print(fit) # Fit the parameters for a skew GED distribution # sgedFit - Fit the parameters for a skew GED distribution # Skew Generalized Error Distribution: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") x = rsged(1000, mean = 0, sd = 1, nu = 2, xi = 1.5) fit = sgedFit(x) print(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.sgedSlider <- function() { # Try Distribution: # sgedSlider(type = "dist") NA # Try Random Variates: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # sgedSlider(type = "rand") NA # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchFit.aparch.R0000644000176200001440000001023615104730075020676 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ # garchFit( # formula, # data, # init.rec = c("mci", "uev"), # delta = 2, # skew = 1, # shape = 4, # cond.dist = c("dnorm", "dsnorm", "dged", "dsged", "dstd", "dsstd"), # include.mean = TRUE, # include.delta = NULL, # include.skew = NULL, # include.shape = NULL, # leverage = NULL, # trace = TRUE, # algorithm = c("sqp", "nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), # control = list(), # title = NULL, # description = NULL, # ...) # ------------------------------------------------------------------------------ test.aparch11 <- function() { # Use Simulated Series - an Object of class 'ts' ... # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Leveraged normal APARCH(1, 1) model = list(omega = 1e-06, alpha = 0.1, beta = 0.8, gamma = 0.1) spec = garchSpec(model) x = garchSim(spec, n = 250) # Fit: fit = garchFit(x ~ garch(1,1), data = x, leverage = TRUE, trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.aparch11delta <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Leveraged normal APARCH(1, 1) delta = 1.5 model = list(omega = 1e-05, alpha = 0.1, beta = 0.8, gamma = 0.1, delta = 1.5) spec = garchSpec(model) x = garchSim(spec, n = 250) print(var(x)) # Fit: fit = garchFit(x ~ garch(1,1), data = x, leverage = TRUE, include.delta = TRUE, delta = 2, trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.ar1aparch21 <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Leveraged normal AR(1)-APARCH(2, 1) delta = 1 model = list(omega = 1e-06, ar = -0.1, alpha = c(0.1, 0.2), beta = 0.6, delta = 1) spec = garchSpec(model) x = garchSim(spec, n = 250) # Taylor Plot: taylor <- fBasics::teffectPlot(x) init.delta = mean(taylor$maxDelta) init.delta ## fit = garchFit(x ~ ar(1) + garch(2,1), data = x, include.delta = TRUE, ## delta = init.delta, trace = FALSE) ## print(coef(fit)) ## Error in solve.default(fit$hessian) : ## Lapack routine dgesv: system is exactly singular ## CHECK !!! # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchFit.faked.R0000644000176200001440000001401015104730075020504 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ test.garchFit.faked <- function() { # Numeric Vector RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate normal GARCH(1, 1) numeric Vector: model = list(omega = 1e-06, alpha = 0.1, beta = 0.8) spec = garchSpec(model) print(spec) N = 250 # UNIVARIATE: x.vec = as.vector(100*garchSim(spec, N)) print(head(x.vec)) x.tS = timeSeries::dummyDailySeries(matrix(x.vec), units = "GARCH11") print(head(x.tS)) # x.zoo = zoo(as.vector(x.vec), order.by = as.Date(rownames(x.tS))) # print(head(x.zoo)) x.ts = ts(x.vec) print(head(x.ts)) # FIT FROM UNIVARIATE DATA SERIES: fit = garchFit( ~ garch(1,1), data = x.tS, trace = FALSE) print(fit) formula(fit) fit = garchFit( ~ garch(1,1), data = as.vector(x.tS), trace = FALSE) print(fit) formula(fit) a = 2 b = 2 fit = garchFit( ~ garch(1,1), data = a*as.vector(0+b*x.tS), trace = FALSE) print(fit) formula(fit) # WHAT HAPPENS WHEN WE (MIS)SPECIFY LHS ? # ... lhs will be ignored for the univariate case: fit = garchFit(any ~ garch(1,1), data = x.vec, trace = FALSE) print(fit) formula(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.mult.faked <- function() { # Numeric Vector RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate normal GARCH(1, 1) numeric Vector: model = list(omega = 1e-06, alpha = 0.1, beta = 0.8) spec = garchSpec(model) print(spec) N = 250 # UNIVARIATE: x.vec = as.vector(100*garchSim(spec, N)) print(head(x.vec)) x.tS = timeSeries::dummyDailySeries(matrix(x.vec), units = "GARCH11") print(head(x.tS)) # x.zoo = zoo(as.vector(x.vec), order.by = as.Date(rownames(x.tS))) # print(head(x.zoo)) x.ts = ts(x.vec) print(head(x.ts)) # MULTIVARIATE: X.mat = cbind(GARCH11 = x.vec, R = rnorm(N)/1000) print(head(X.mat)) X.tS = timeSeries::dummyDailySeries(X.mat, units = c("GARCH11", "R")) print(head(X.tS)) # X.zoo = zoo(X.mat, order.by = as.Date(rownames(x.tS))) # print(head(X.zoo)) X.mts = ts(X.mat) print(head(X.mts)) # FIT FROM MULTIVARIATE DATA SET: fit = garchFit(GARCH11 ~ garch(1,1), data = X.tS, trace = FALSE) print(fit) formula(fit) fit = garchFit(GARCH11 ~ garch(1,1), data = as.matrix(X.tS), trace = FALSE) print(fit) formula(fit) a = 2 b = 2 fit = garchFit(GARCH11 ~ garch(1,1), data = a*as.matrix(0+b*X.tS), trace = FALSE) print(fit) formula(fit) a = 2 b = 2 fit = garchFit(GARCH11 ~ garch(1,1), data = a*as.matrix(0+b*X.tS), trace = FALSE) print(fit) formula(fit) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.mult.lhs.faked <- function() { # Numeric Vector RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate normal GARCH(1, 1) numeric Vector: model = list(omega = 1e-06, alpha = 0.1, beta = 0.8) spec = garchSpec(model) print(spec) N = 250 # UNIVARIATE: x.vec = as.vector(100*garchSim(spec, N)) print(head(x.vec)) x.tS = timeSeries::dummyDailySeries(matrix(x.vec), units = "GARCH11") print(head(x.tS)) # x.zoo = zoo(as.vector(x.vec), order.by = as.Date(rownames(x.tS))) # print(head(x.zoo)) x.ts = ts(x.vec) print(head(x.ts)) # MULTIVARIATE: X.mat = cbind(GARCH11 = x.vec, R = rnorm(N)/1000) print(head(X.mat)) X.tS = timeSeries::dummyDailySeries(X.mat, units = c("GARCH11", "R")) print(head(X.tS)) # X.zoo = zoo(X.mat, order.by = as.Date(rownames(x.tS))) # print(head(X.zoo)) X.mts = ts(X.mat) print(head(X.mts)) # LEFT HAND SIDE FORMULA FAKED FIT: fit = garchFit(GARCH11 + R ~ garch(1,1), data = X.tS, trace = FALSE) print(fit) formula(fit) ### head(fit@data$data) ### head(fit@data$Data) ### head(rowSums(fit@data$Data)) # LEFT HAND SIDE FORMULA FAKED AND DATA FAKED FIT: fit = garchFit(GARCH11 + R ~ garch(1,1), data = as.matrix(X.tS), trace = FALSE) print(fit) formula(fit) ### head(fit@data$data) ### head(fit@data$Data) ### head(rowSums(fit@data$Data)) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchHessian.R0000644000176200001440000000302215104730075020304 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # .garchRCDAHessian Computes R coded CDA Hessian matrix # .garchFCDAHessian Computes Fortran coded CDA Hessian matrix # .garchFFDAHessian Computes Fortran coded FDA Hessian matrix ################################################################################ fGarch/inst/unitTests/runit.formula-methods.R0000644000176200001440000001411015104730075021013 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ test.formula.methods.univariate <- function() { # Numeric Vector RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate normal GARCH(1, 1) numeric Vector: spec = garchSpec() N = 250 # Univariate Data Simulation: x.vec = 100*garchSim(spec, N) print(head(x.vec)) x.tS = timeSeries::dummyDailySeries(matrix(x.vec), units = "GARCH11") print(head(x.tS)) # x.zoo = zoo(as.vector(x.vec), order.by = as.Date(rownames(x.tS))) # print(head(x.zoo)) x.ts = as.ts(x.vec) print(head(x.ts)) # Univariate Modeling: # A numeric Vector: fit = garchFit(~ garch(1,1), data = x.vec, trace = FALSE) print(formula(fit)) fit = garchFit(x.vec ~ garch(1,1), data = x.vec, trace = FALSE) print(formula(fit)) # An univariate timeSeries object with dummy dates: fit = garchFit(~ garch(1,1), data = x.tS, trace = FALSE) print(formula(fit)) fit = garchFit(x.tS ~ garch(1,1), data = x.tS, trace = FALSE) print(formula(fit)) ### # An univariate zoo object with dummy dates: ### fit = garchFit(~ garch(1,1), data = x.zoo, trace = FALSE) ### print(formula(fit)) ### fit = garchFit(x.zoo ~ garch(1,1), data = x.zoo, trace = FALSE) ### print(formula(fit)) # An univariate "ts" object: fit = garchFit(~ garch(1,1), data = x.ts, trace = FALSE) print(formula(fit)) fit = garchFit(x.ts ~ garch(1,1), data = x.ts, trace = FALSE) print(formula(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.formula.methods.multivariate <- function() { # Numeric Vector RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Simulate normal GARCH(1, 1) numeric Vector: spec = garchSpec() N = 250 # Univariate Data Simulation: x.vec = 100*garchSim(spec, N) print(head(x.vec)) x.tS = timeSeries::dummyDailySeries(matrix(x.vec), units = "GARCH11") print(head(x.tS)) # Multivariate Data Simulation: X.mat = cbind(GARCH11 = x.vec, R = rnorm(N)) colnames(X.mat) <- c("GARCH11", "R") print(head(X.mat)) X.tS = timeSeries::dummyDailySeries(X.mat, units = c("GARCH11", "R")) print(head(X.tS)) # X.zoo = zoo(X.mat, order.by = as.Date(rownames(x.tS))) # print(head(X.zoo)) X.mts = as.ts(X.mat) print(head(X.mts)) # head doesn't wor for mts !!! # Multivariate Modeling: # A numeric matrix: fit = garchFit(GARCH11 ~ garch(1,1), data = X.mat, trace = FALSE) print(formula(fit)) fit = garchFit(100*GARCH11 ~ garch(1,1), data = X.mat, trace = FALSE) print(formula(fit)) # A multivariate timeSeries object with dummy dates: fit = garchFit(GARCH11 ~ garch(1,1), data = X.tS, trace = FALSE) print(formula(fit)) fit = garchFit(100*GARCH11 ~ garch(1,1), data = X.tS, trace = FALSE) print(formula(fit)) ### # A multivariate zoo object without column names: ### fit = garchFit(GARCH11 ~ garch(1,1), data = X.zoo, trace = FALSE) ### print(formula(fit)) ### fit = garchFit(100*GARCH11 + R/100 ~ garch(1,1), data = X.zoo, trace = FALSE) ### print(formula(fit)) # A multivariate "mts" object without column names: fit = garchFit(GARCH11 ~ garch(1,1), data = X.mts, trace = FALSE) print(formula(fit)) fit = garchFit(100*GARCH11 + R/100 ~ garch(1,1), data = X.mts, trace = FALSE) print(formula(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.formula.methods.spread <- function() { # MODELING THE PERCENTUAL SPI/SBI SPREAD FROM LPP BENCHMARK: # Series: stopifnot(require("timeSeries")) # for the data() and as.timeS.. X.tS = as.timeSeries(data(LPP2005REC)) print(head(X.tS)) X.mat = as.matrix(X.tS) print(head(X.mat)) # X.zoo = zoo(X.mat, order.by = as.Date(rownames(X.tS))) # print(head(X.zoo)) X.mts = ts(X.mat) print(head(X.mts)) # Fit: fit = garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.tS, trace = FALSE) print(formula(fit)) ## fit = garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.mat, trace = FALSE) ## print(formula(fit)) ## fit = garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.zoo, trace = FALSE) ## print(formula(fit)) ## fit = garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.mts, trace = FALSE) ## print(formula(fit)) # MODELING HIGH/LOW SPREADS FROM MSFT PRICE SERIES: # Series: X.tS = MSFT # Fit: fit = garchFit(Open ~ garch(1,1), data = returns(X.tS), trace = FALSE) print(formula(fit)) fit = garchFit(100*(High-Low) ~ garch(1,1), data = returns(X.tS), trace = FALSE) print(formula(fit)) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchSolver.R0000644000176200001440000002402015104730075020165 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: SOLVER: # .garchRnlminb R coded solver nlmin # .garchRlbgfsb R coded solver optim using method lbgfsb # .garchRnm R coded solver nm as hybrid addon # .garchFsqp Fortran coded solver sqp # .garchRdonlp2 R coded solver donlp2 # .garchFmnfb Fortran coded solver mnfb ################################################################################ ## test.garchSolver.dem2gbp <- ## function() ## { ## # Note, Default has changed: "cda" -> "fda" ## # Loda Data ## data(dem2gbp) ## garchFit(~ garch(1,1), dem2gbp, hessian = "fda", algorithm = "nlminb") ## # Time difference of 2.969 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu -0.006190 0.008464 -0.731 0.464545 ## # omega 0.010761 0.003081 3.492 0.000479 *** ## # alpha1 0.153134 0.027720 5.524 3.31e-08 *** ## # beta1 0.805974 0.035761 22.537 < 2e-16 *** ## # --- ## # Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 ## # ## # Log Likelihood: ## # 1106.608 normalized: 0.5605916 ## garchFit(~ garch(1,1), dem2gbp, hessian = "cda", algorithm = "nlminb") ## garchFit(~ garch(1,1), dem2gbp, algorithm = "lbfgsb") ## # Time difference of 4.75 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu -0.006187 0.008462 -0.731 0.464720 ## # omega 0.010785 0.002860 3.771 0.000163 *** ## # alpha1 0.153306 0.026556 5.773 7.79e-09 *** ## # beta1 0.805706 0.033612 23.971 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 1106.608 normalized: 0.5605916 ## garchFit(~ garch(1,1), dem2gbp, hessian = "cda", algorithm = "nlminb+nm") ## # Time difference of 6.094 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu -0.006190 0.008462 -0.732 0.464447 ## # omega 0.010761 0.002853 3.772 0.000162 *** ## # alpha1 0.153134 0.026523 5.774 7.76e-09 *** ## # beta1 0.805974 0.033553 24.021 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 1106.608 normalized: 0.5605916 ## # ## garchFit(~ garch(1,1), dem2gbp, hessian = "cda", algorithm = "lbfgsb+nm") ## garchFit(~ garch(1,1), dem2gbp, hessian = "cda", algorithm = "donlp2") ## # Time difference of 7.094 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu -0.006190 0.008462 -0.732 0.464447 ## # omega 0.010761 0.002853 3.772 0.000162 *** ## # alpha1 0.153134 0.026523 5.774 7.76e-09 *** ## # beta1 0.805973 0.033553 24.021 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 1106.608 normalized: 0.5605916 ## # ## garchFit(~ garch(1,1), dem2gbp, hessian = "cda", algorithm = "sqp") ## # Time difference of 1.906 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu -0.006190 0.008462 -0.732 0.464437 ## # omega 0.010761 0.002853 3.772 0.000162 *** ## # alpha1 0.153134 0.026523 5.774 7.76e-09 *** ## # beta1 0.805974 0.033553 24.021 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 0.5605916 normalized: 0.0002839877 ## # ## garchFit(~ garch(1,1), dem2gbp, hessian = "cda", algorithm = "mnfb") ## # Time difference of 1.344 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu -0.006190 0.008461 -0.732 0.464384 ## # omega 0.010761 0.002853 3.772 0.000162 *** ## # alpha1 0.153134 0.026523 5.774 7.75e-09 *** ## # beta1 0.805974 0.033552 24.021 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 0.5605916 normalized: 0.0002839877 ## # Return Value: ## return() ## } # ------------------------------------------------------------------------------ test.garchSolver2.dem2gbp <- function() { # Note, Default has changed: "cda" -> "fda" # Loda Data data(dem2gbp) ## garchFit(~ garch(1,1), dem2gbp, hessian = "fcd", algorithm = "nlminb") garchFit(~ garch(1,1), dem2gbp, hessian = "rcd", algorithm = "nlminb") garchFit(~ garch(1,1), dem2gbp, algorithm = "lbfgsb") ## garchFit(~ garch(1,1), dem2gbp, hessian = "fcd", algorithm = "nlminb+nm") garchFit(~ garch(1,1), dem2gbp, hessian = "rcd", algorithm = "lbfgsb+nm") # garchFit(~ garch(1,1), dem2gbp, hessian = "fcd", algorithm = "donlp2") # garchFit(~ garch(1,1), dem2gbp, hessian = "rcd", algorithm = "sqp") ## garchFit(~ garch(1,1), dem2gbp, hessian = "fcd", algorithm = "mnfb") # Return Value: return() } # ------------------------------------------------------------------------------ ## test.garchSolver.sp500dge <- ## function() ## { ## # Loda Data: ## data(sp500dge) ## sp500dge = 100 * sp500dge ## garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "cda", ## algorithm = "lbfgsb") # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "cda", # algorithm = "sqp") ## # Time difference of 48.954 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu 0.020646 0.006350 3.251 0.00115 ** ## # ma1 0.144745 0.008358 17.319 < 2e-16 *** ## # omega 0.009988 0.001085 9.201 < 2e-16 *** ## # alpha1 0.083803 0.004471 18.742 < 2e-16 *** ## # gamma1 0.373092 0.027997 13.326 < 2e-16 *** ## # beta1 0.919401 0.004093 224.614 < 2e-16 *** ## # delta 1.435124 0.067203 21.355 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 1.264345 normalized: 7.413338e-05 ## # # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "fda", # algorithm = "sqp") # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "cda", # algorithm = "mnfb") ## # Time difference of 35.156 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu 0.020646 0.006351 3.251 0.00115 ** ## # ma1 0.144745 0.008358 17.319 < 2e-16 *** ## # omega 0.009988 0.001086 9.201 < 2e-16 *** ## # alpha1 0.083803 0.004472 18.741 < 2e-16 *** ## # gamma1 0.373092 0.027997 13.326 < 2e-16 *** ## # beta1 0.919401 0.004093 224.606 < 2e-16 *** ## # delta 1.435124 0.067204 21.355 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 1.264345 normalized: 7.413338e-05 ## # # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "fda", # algorithm = "mnfb") ## # Time difference of 31.516 secs ## # Error Analysis: ## # Estimate Std. Error t value Pr(>|t|) ## # mu 0.020646 0.006342 3.255 0.00113 ** ## # ma1 0.144745 0.008363 17.307 < 2e-16 *** ## # omega 0.009988 0.001113 8.975 < 2e-16 *** ## # alpha1 0.083803 0.004534 18.485 < 2e-16 *** ## # gamma1 0.373092 0.027798 13.422 < 2e-16 *** ## # beta1 0.919401 0.004102 224.141 < 2e-16 *** ## # delta 1.435124 0.066283 21.652 < 2e-16 *** ## # --- ## # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 ## # ## # Log Likelihood: ## # 1.264345 normalized: 7.413338e-05 ## # ## # Return Value: ## return() ## } # ------------------------------------------------------------------------------ test.garchSolver.sp500dge <- function() { # Loda Data: data(sp500dge) sp500dge = 100 * sp500dge # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "fcd", # algorithm = "lbfgsb") ### garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "fcd", ### algorithm = "sqp") ### garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "rcd", ### algorithm = "sqp") # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "fcd", # algorithm = "mnfb") # garchFit(~ arma(0,1) + aparch(1,1), sp500dge, hessian = "rcd", # algorithm = "mnfb") garchFit(~ arma(0,1) + aparch(1,1), sp500dge) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.predict-methods.R0000644000176200001440000000435215104730075021007 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: FORECASTING: # garchKappa Computes Expection for APARCH Models # .funE Internal function used by kappa() ################################################################################ test.predict.methods <- function() { # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") print(NA) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchKappa <- function() { # garchKappa( # cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd"), # gamma = 0, delta = 2, skew = NA, shape = NA) garchKappa() garchKappa("norm", gamma = 0.3) garchKappa("ged", skew = 0.95, shape = 1) # CHECK !!! garchKappa("dstd", skew = 0.95, shape = 1) # Return Value: return() } ################################################################################ fGarch/inst/unitTests/runit.garchFit.dist.R0000644000176200001440000001356315104730075020411 0ustar liggesusers # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General # Public License along with this library; if not, write to the # Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # Copyrights (C) # for this R-port: # 1999 - 2008, Diethelm Wuertz, Rmetrics Foundation, GPL # Diethelm Wuertz # info@rmetrics.org # www.rmetrics.org # for the code accessed (or partly included) from other R-ports: # see R's copyright and license files # for the code accessed (or partly included) from contributed R-ports # and other sources # see Rmetrics's copyright file ################################################################################ # FUNCTION: PARAMETER ESTIMATION: # 'fGARCH' S4: fGARCH Class representation # garchFit Fits GARCH and APARCH processes ################################################################################ test.garchFit.snorm <- function() { # Conditional Densities: # "norm", "snorm", "ged", "sged", "std", "sstd" # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # skewed normal GARCH(1, 1) model = list(omega = 1e-04, alpha = 0.1, beta = 0.8, skew = 0.9) spec = garchSpec(model, cond.dist = "snorm") x = garchSim(spec = spec, n = 250) # Fit: fit = garchFit( ~ garch(1,1), data = x, include.skew = TRUE, cond.dist = "snorm", trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.snorm.fixed <- function() { # Conditional Densities: # "norm", "snorm", "ged", "sged", "std", "sstd" # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # skewed normal GARCH(1, 1) model = list(omega = 1e-04, alpha = 0.1, beta = 0.8, skew = 0.9) spec = garchSpec(model, cond.dist = "snorm") x = garchSim(spec = spec, n = 250) # Fit: Skewed Normal GARCH(1, 1) with fixed skew ... fit = garchFit(~garch(1,1), data = x, skew = 0.9, include.skew = FALSE, cond.dist = "snorm", trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.ged <- function() { # Conditional Densities: # "norm", "snorm", "ged", "sged", "std", "sstd" # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # GED-GARCH(1, 1) model = list(omega = 1e-06, alpha = 0.1, beta = 0.8, shape = 2) spec = garchSpec(model, cond.dist = "ged") x = garchSim(spec = spec, n = 250) # Fit: fit = garchFit(~garch(1,1), data = x, include.shape = TRUE, cond.dist = "ged", trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.sged <- function() { # Conditional Densities: # "norm", "snorm", "ged", "sged", "std", "sstd" # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Skewed GED-GARCH(1, 1) model = list(omega = 1e-05, alpha = 0.1, beta = 0.8, shape = 4, skew = 0.9) spec = garchSpec(model, cond.dist = "sged") x = garchSim(spec = spec, n = 250) # Fit fit = garchFit( ~ garch(1,1), data = x, include.shape = TRUE, include.skew = TRUE, cond.dist = "sged", trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.std <- function() { # Conditional Densities: # "norm", "snorm", "ged", "sged", "std", "sstd" # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Student t-GARCH(1, 1) model = list(omega = 1e-06, alpha = 0.1, beta = 0.8, shape = 5) spec = garchSpec(model, cond.dist = "std") x = garchSim(spec = spec, n = 250) # Fi fit = garchFit( ~ garch(1,1), data = x, include.shape = TRUE, cond.dist = "std", trace = FALSE) print(coef(fit)) # Return Value: return() } # ------------------------------------------------------------------------------ test.garchFit.sstd <- function() { # Conditional Densities: # "norm", "snorm", "ged", "sged", "std", "sstd" # RVs: RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion") set.seed(4711, kind = "Marsaglia-Multicarry") # Skewed Student t-GARCH(1, 1) model = list(omega = 1e-06, alpha = 0.1, beta = 0.8, shape = 5, skew = 0.9) spec = garchSpec(model, cond.dist = "std") x = garchSim(spec = spec, n = 250) # Fit: fit = garchFit( ~ garch(1,1), data = x, include.shape = TRUE, include.skew = TRUE, cond.dist = "sstd", trace = FALSE) print(coef(fit)) # Return Value: return() } ################################################################################ fGarch/inst/NEWS.Rd0000644000176200001440000003154015116751354013477 0ustar liggesusers% Convert this to NEWS.md: % 1. inst/NEWS.Rd to NEWS.html: % tools:::Rd2HTML("inst/NEWS.Rd", "NEWS.html") % % 2. NEWS.html to NEWS.md (https://www.r-bloggers.com/2018/12/rstudio-pandoc-html-to-markdown/) % rmarkdown::pandoc_convert("NEWS.html", to = "markdown_strict", output = "NEWS.md") % % 3. Manually remove everything up to the first line containing: % ## CHANGES in fGarch VERSION ... % % 4. Bring the markdown sections one level up, i.e. remove one '#' from % each section level. For example using regex ^#\(#+\) with replacement value \1 \name{NEWS} \title{News for \R Package \pkg{fGarch}} \encoding{UTF-8} \section{CHANGES in fGarch VERSION 4052.93 (2024-12-12, svn r6482--r6544)}{ \itemize{ \item emphasised that the skew normal distribution in fGarch is different from what is usually called skew normal distribution. Similarly for the other skew distributions. \item replaced a call to `warnings` (plural) with `warning` (singular) in \code{garchSpec}. The old one was clearly a typo and was not issuing the intended warning about the violation of the stationarity condition for GARCH models. \item improved the layout of the reference section of the pkgdown site. \item edited the help page of class \code{"fGARCH"}. In particular, added cross-references to the help pages of the individual methods. } } \section{CHANGES in fGarch VERSION 4033.92 (2024-03-26, svn r6481--r6481)}{ \itemize{ \item added VaR and ES plots to the \code{plot} method for fitted GARCH models. \item documented with examples that argument \code{which} of the plot method for fitted GARCH objects can be of length greater than one. \item added a link to the website created with pkgdown to file 'DESCRIPTION'. } } \section{CHANGES in fGarch VERSION 4032.91 (2024-02-02, svn r6436--r6479)}{ \itemize{ \item added computation of Value-at-Risk (VaR) and expected shortfall (ES) for fitted GARCH and APARCH models (in-sample and in the predict method). Just use something like \code{Var(fitted_object)}, \code{ES(fitted_object)} or \code{predict(fitted_object, ..., p_loss = 0.05)}. } } \section{CHANGES in fGarch VERSION 4022.90 (2023-10-15, svn r6333--r6435)}{ \itemize{ \item added \code{"fGARCH"} method for \code{stats::tsdiag}. The method produces diagnostic plot for fitted GARCH/APARCH models and computes some diagnostic tests. The plots can be chosen interactively and/or via arguments. The test results are in the returned value. The method is in development in that more plots may be made available and additional tests included in the returned value. \item refactored the \code{"fGARCH"} method for 'summary' to return an object from S3 class 'summary_fGARCH' equipped with a 'print' method. The printout is the same as before, except that now the numbers in the statistics column for the residual diagnostics are aligned on the decimal point (previously they were left-aligned due to a buglet). \item the \code{"fGARCH"} method for \code{fitted} was returning the data, not the fitted values. Fixes issue 6789, reported by Kouhei Hashinokuchi (hakoshie). \item the help pages for the \code{"fGARCH"} methods for \code{fitted()} and \code{residuals()} were stating that the returned results have the same class as the input time series. Actually, they return numeric vectors. (todo?: to make the returned values as previously documented, \code{garchFit()} would need to put the original data or the necessary information in the fitted object, e.g., \code{object@fit$data}. \item some tests were using deprecated \code{fBasics::.distCheck()} (notice the leading dot). Replaced such calls with the equivalent \code{fBasics::distCheck()}. } } \section{CHANGES in fGarch VERSION 4022.89 (2022-11-05, from svn r6316--r6326)}{ \itemize{ \item in \code{absMoments}, the absolute moments for the standardized Student-t distribution were wrong. \item in README, linked to the paper by Wuertz et al. \item substantially revised the documentation and filled gaps in it. \item removed the functions with suffix `_orig` which were kept temporarilly after the bug fix in v4021.87 since there were no reported problems with the fix. } } \section{CHANGES in fGarch VERSION 4021.88 (2022-09-28, svn r6276)}{ \itemize{ \item require Matrix (>= 1.5-0) to avoid problems for users who have earlier versions of Matrix on their devices (thanks to Mikael Jagan for checking for not strict enough dependency on Matrix and alerting the maintainer). } } \section{CHANGES in fGarch VERSION 4021.87 (2022-08-06, svn r6215--r6265)}{ \subsection{NEW MAINTAINER}{ \itemize{ \item Georgi N. Boshnakov } } \subsection{VERSION NUMBERS}{ \itemize{ \item We continue to use the traditional Rmetrics scheme for numbering the versions of the package as Mmmr.n, where 'M' is the current major R version at the time of submission of the package to CRAN, 'mm' is the minor one and 'r' is the revision. 'n' is the sequential number of the CRAN submission of the package. For example, this release has version 4021.87 since it was released when R 4.2.1 was current and 'n' in the previous version was 86. } } \subsection{BUG FIXES}{ Fixed issue 6061 raised by William Scott, who also supplied examples. \itemize{ \item The quantile function, \code{qsnorm}, was wrong around 0.5. The error was in \code{.qsnorm}. For now its version before the fix is kept as \code{.qsnorm_orig}. Basically, branching was done w.r.t. \eqn{p = 0.5}, which is correct only for the symmetric case, \eqn{\xi = 1}, and should be \eqn{1/(1+\xi^2)} instead. More details in the source code. The error was affecting the central part of the distrbution with the interval becoming larger for \eqn{\xi} further away from 1. \item The cdf, \code{psnorm}, had an error at a single point, coinciding with the wrong value for \eqn{p = 0.5} returned by \code{qsnorm(0.5)} before the fix. The result was that \code{psnorm(qsnorm(0.5))} was returning 0.5, falsely giving reassurance that \code{qsnorm(0.5)} was correct. \item Not mentioned in issue 6061 but the same problems held for the other skewed distributions: \code{qsstd}, \code{psstd}, \code{qsged}, \code{psged}. The original versions of the relevant internal functions are kept for now with a suffix \code{_orig}, as above: \code{qsstd_orig}, \code{psstd_orig}, \code{qsged_orig}, \code{psged_orig}. } } \subsection{Documentation}{ \itemize{ \item Edited the documentation of \code{"garchSpec"} and \code{garchSim}. It was somewhat incomplete and contained leftovers, apparently from old versions of the functions. \item Documented the datasets. Previously the help page for them was a placeholder, without the names of the available datasets. There is no information about the time span of the data or how the returns were calculated. } } } \section{CHANGES in fGarch VERSION 4021.86 (2022-06-23, svn r6188)}{ \subsection{NEW MAINTAINER}{ \itemize{ \item Tobias Setz } } \subsection{Notes}{ \itemize{ \item This is a CRAN release of version 4001.1, with trivial changes in \file{DESCRIPTION}. } } } \section{CHANGES in fGarch VERSION 4001.1 (2022-06-23, svn r6184--r6185)}{ \subsection{NEW MAINTAINER}{ \itemize{ \item ad interim: Martin Maechler } } \subsection{NEW FEATURES}{ \itemize{ \item Packages \CRANpkg{timeSeries}, \CRANpkg{timeDate} and \CRANpkg{fBasics} are no longer in \code{Depends}, but only in \code{Imports} and hence no longer automatically attached to the \code{search()} path whenever \pkg{fGarch} is. This may require updates in your code, e.g., adding \preformatted{ stopifnot(require("timeSeries"))} as it has been done in our own \pkg{fGarch}'s examples and tests. \item \code{.gogarchFit()} is at least \emph{mentioned} in the documentation. } } \subsection{BUG FIXES}{ \itemize{ \item Added registration of compiled functionality for speed up and as good practice. \item Removed all \code{Depends:} entries and checked exactly which parts of packages, notably \pkg{fBasics}, \pkg{timeDate}, and \pkg{timeSeries}, are needed and imported only these. \item Eliminated warning about 'length > 1' character formula in \code{garchFit()}, i.e., \code{.garchFit()}. \item Replaced the error-prone checking for `class()` equality by `inherits(*, )`. } } \subsection{Misc}{ \itemize{ \item Exporting practically everything seems \dQuote{wrong} (according to MM): Several \code{.} functions have \emph{no} documentation and hence should either be (renamed and) documented or no longer be exported. \item a \code{data} argument should never have a default: hence removed from \code{garchFit()}. } } } \section{CHANGES in fGarch, VERSION 3042.83.2 (2020-03-07, CRAN team)}{ \subsection{Misc}{ \itemize{ % MM: add by comparing the directory trees (after "untar") % GNB: added by looking at the commit at https://github.com/cran/fGarch/ % \item in \file{dist-norm.Rd}, removed the description of argument \code{...}, which is not in the argument list of any function described there. } } } %% CRAN Versions of fGarch .../CRAN/src/contrib/Archive/fGarch -- 22.Jun 2022 %% Size Date tarball-filename %% ------ ------------ ---------------------- %% 143455 7. Mar 2020 fGarch_3042.83.2.tar.gz Packaged: 2020-03-07 10:25:26 UTC; hornik %% - - - - - - - - - - - - - - - - - - - - - - %% 145810 31. Jan 2019 fGarch_3042.83.1.tar.gz Packaged: 2019-01-31 16:42:21 UTC; hornik %% 160314 16. Nov 2017 fGarch_3042.83.tar.gz Packaged: 2017-11-16 17:28:34 UTC; Tobias Setz %% 160484 15. Aug 2016 fGarch_3010.82.1.tar.gz Packaged: 2016-08-15 09:24:21 UTC; ripley %% 152081 1. May 2013 fGarch_3010.82.tar.gz Packaged: 2013-04-30 20:07:14 UTC; yankee (Yohan Ch) \section{CHANGES in fGarch, VERSION 3042.83.1 (2019-01-31, CRAN team)}{ \subsection{Misc}{ % MM: add by comparing the directory trees (after "untar") % GNB: added by looking at the commit at https://github.com/cran/fGarch/ % \itemize{ \item in \file{NAMESPACE} and \file{R/methods-plot.R} renamed functions \code{.plot.garch.1}, \ldots, \code{.plot.garch.13} to \code{.plot.garch_1}, \ldots, \code{.plot.garch_13}. \item compressed datasets \file{data/dem2gbp.csv} and \file{data/sp500dge.csv} to \file{data/dem2gbp.csv.bz2} \file{data/sp500dge.csv.bz2}, respectively. } } } \section{CHANGES in fGarch, VERSION 3042.83 (2017-11-16, svn r...)}{ \subsection{Misc}{ \itemize{ \item Startup message removed \item Incorporate fixes by CRAN team (Brian Ripley?) \item Checks and adaptions for R 3.4.2, e.g., \file{DESCRIPTION}, ... } } } \section{CHANGES in fGarch, VERSION 3010.82.1 (2016-08-14, CRAN team.)}{ \subsection{Misc}{ \itemize{ \item in \file{NAMESPACE}, import (selectively) from \pkg{utils}. \item changed a couple of calls to \code{Matrix()} from package \pkg{Matrix} and \code{fastICA()} from \pkg{fastICA} to the fully qualified forms \code{Matrix::Matrix()} and \code{fastICA::fastICA}. \item removed some flag settings in \file{Makevars}. \item in \file{math.f}, move a \code{DATA} command out of the body of an \code{"if"} block putting it towards the beginning of the file. } } } \section{CHANGES in fGarch, VERSION 3010.82 (2013-04-30, svn r5509) -- and earlier}{ \subsection{ChangeLog}{ \itemize{ \item Changes up to April 2013, by Yohan Chalabi, Diethelm Wuertz, Pierre Chausse and Martin Maechler are all in file \file{ChangeLog}. % = ../ChangeLog } } } %% CRAN-Archive for fGarch -- older ones %% Size Date tarball-filename %% ------ ------------ ---------------------- %% 152081 1. Mai 2013 fGarch_3010.82.tar.gz %% 151484 18. Sep 2012 fGarch_2150.81.tar.gz %% 199196 4. Jun 2012 fGarch_2110.80.1.tar.gz %% 198030 10. Nov 2009 fGarch_2110.80.tar.gz %% 190133 28. Sep 2009 fGarch_2100.79.tar.gz %% 183635 20. Apr 2009 fGarch_2100.78.tar.gz %% 183616 16. Apr 2009 fGarch_290.77.tar.gz %% 178881 28. Jan 2009 fGarch_290.76.tar.gz %% 177761 27. Okt 2008 fGarch_280.75.tar.gz %% 177703 25. Okt 2008 fGarch_280.74.tar.gz %% 177695 23. Okt 2008 fGarch_280.73.tar.gz %% 127399 8. Okt 2007 fGarch_260.72.tar.gz %% 127396 2. Okt 2007 fGarch_260.71.tar.gz fGarch/README.md0000644000176200001440000000375115104730075012733 0ustar liggesusers [![CRANStatusBadge](http://www.r-pkg.org/badges/version/fGarch)](https://cran.r-project.org/package=fGarch) [![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/fGarch)](https://www.r-pkg.org/pkg/fGarch) [![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/grand-total/fGarch?color=blue)](https://r-pkg.org/pkg/fGarch) Analyze and model heteroskedastic behavior in financial time series with GARCH, APARCH and related models. Package `fGarch` is part of the Rmetrics suite of R packages and is developed on R-forge at [fGarch devel](https://r-forge.r-project.org/scm/viewvc.php/pkg/fGarch/?root=rmetrics). The root of Rmetrics is at [R-forge](https://r-forge.r-project.org/projects/rmetrics). # Installing fGarch Install the [latest stable version](https://cran.r-project.org/package=fGarch) of `fGarch` from CRAN: install.packages("fGarch") You can install the [development version](https://r-forge.r-project.org/scm/viewvc.php/pkg/fGarch/?root=rmetrics) of `fGarch` from R-forge: install.packages("fGarch", repos = "http://R-Forge.R-project.org") To report bugs visit [Rmetrics](https://r-forge.r-project.org/projects/rmetrics/). # Documentation You can view the documentation of `fGarch` at [fGarchDoc](https://geobosh.github.io/fGarchDoc/) (rendered with pkgdown) or download the [reference manual](https://cran.r-project.org/package=fGarch/fGarch.pdf) of the latest release from CRAN. A comprehensive overview of the models and conditional distributions employed in package `fGarch`, along with worked examples, is available in the following paper by the original authors of the package: [WurtzEtAlGarch.pdf](https://github.com/GeoBosh/fGarchDoc/blob/master/WurtzEtAlGarch.pdf). (*This is an unpublished manuscript. Some online sources, confusingly, attribute it to JSS, vol 55, issue 2, but this seems to have taken the placeholders `VV` and `II` in the heading on the first page as being the Roman numbers 55 and 2.*) fGarch/build/0000755000176200001440000000000015116751403012546 5ustar liggesusersfGarch/build/partial.rdb0000644000176200001440000001560315116751403014700 0ustar liggesusers‹í]kwÓH¶5vBbB4žÕ¤É´“á1CCHwxt wÚÓŒlɉYrK2!ÃewÝÏóç7Üw͘¾u¤-§ìH&%)kÝf-±Oì²Î®:§N=TUz},“Éd3]ÝÙL6Gâ)þß‘L&GXØý;{ÂîLžãqÇU\gÂuT]ÙÌdº²ÂwG×Õ7.}šÑõjy}±5¥c—m­ÂuõÓ_¾žLpòP˯zø¯*º¡ÑM3þ¿µ$É-›åýÝ/_¬LÜnI׫™eKÕÍV²™–tyW¯j<ËÕ¿÷}±ðχÿ3¸ñ´$ì.ŠãànÙ€ðóg«¯ËnkïO—Kÿn¥CÙ2•ªÖBçÞ”[­M­óÿžº?½}¥L­—꺡ÎÜœ›½uç¶rSUg§*»¼5UUÌ)Ñ6“ëj‹’ì¶Úrûñ}ßÞçðîý¥åF‚e¢’4L.ÞèHkªî¢_ ôeö—ÿ®S»Hér<]×/ûUÛäÍGŽEðèz±üúEÓâŠAcŸ•k/³ÝêÔÄŒ,Ý <9V…j=ZT ]q"ô %ÓiÃú/ÄÕi9”@€¸Rò£±<£ Þ@ع¿žÑ…ü@è¼IHý €¸R2I?¢måÑÂúÒcIËtÃݨ;½q뎤eºanT”#‡SYHýqušF×[š™NÓz?=‰i„ùé­‡ÜKMËqõ2«–ë0ÅTµ7:}æ°Še³ŠîºšÊB'^ì Åä“ÝÍ™Ì00¢¬¨£Ÿ@ŽÕ ‡sj?jÃé$ð äX#€P­=E¿…PŒQOæ,䳉ý÷Ú˜UúI+»¶iU& e“ÝcO_®­Q,~Ëå•…µå“õ*"yxò½Ø^•‰R_TyK¡þà"ääíÀ°ßµà¥R›ã%t“_·Öx³%]éˆ×ðÈ?$æw†ùÿüÆ †—&wÎu¦YNm@Tw”ͰQ08÷!µ¤>+à!µçP&k'N%¥3œñûíâJX*YÆ$yœGQœÏ4Íã¦Ý\ùA1·<0ys•x K4N ˆ+i¤£˜Ì/!V±­*ó$ÉZò¬w^uÄÇ”&z¯ú­ûUÙèGtð:äë©E¿îb™¦#ÔžŽAKl¬“ÞÊÖܺmò‘WiGÖ‡ˆÎ8ðä;‰iu‘I2¹!¦é¸K¨ÛlÒ£Ã]¶ê_Dý"<ù\Š^cèæÛµ}Àaȱꜳ’ºnàyÈç{En2²#Õ®Ø//A¾t­Ò%8$a¢V)º«U#"|js»W§»*¤¾K@\·Âe”üå¤VhÛ7èÁ@)¹‹qÚ3…d?ÓÂ@YŸ"FóÀUÈ«‰™="ŸRµŠR7\¬ôZŽÖe€ŸXa'›™ëp8ÂG%ÎÌ2e¦±ÖÏ[ºè­‰cÎÏu…Þ´ZNaß?á-Nlã¯ä”ÍÊè.C^N§®‹Ky‘»¶^ªÓŸÒ ù8x'®ëâ·òMÈo ›°ƒ 9ÅŽÔbCN껌݇j=Vl4!º‡QÚ_i¥È×0|€Ù¸à5:¯’Ò)düµ–âêt©LÀ ¦c —¬j­îj^$ôä¨Õë ëO&–°Ëfeô Ó‹†Ò%*ŒVR,Qù€wºod’ö™Åo—F÷î,h¬èßóK\=¾öSÝÜœX´Þ"2Ò³ôìÉ“å§QyÉ—!‚iIýŠ€¸:nÚi˜s:UÓ.޲5}âIyMã–¥jËm5ñ\×ì²6¾Ïmò–†5 B~ØyËNñ\NÅÁä-;kΤjÙÇ£‘½ê}lO¶…ÈÛw6%üò··/©ÿN@\·ï,l:›ª}¿µ_'Ø'#oÕYX’ðä·*©_WÇ­:KÎ¥jÕìh6–Vaxü\&fG?™eH}·€¸:n™›°ÆÍT-󨩤ÛʎêÊ[oÜ‹²e ²AŒUµM[Ó¼[á‚jUñ¼yo¤„«“ÏÄH›—Ô+ ®Ž›w&OÕ¼+£a=YÛªon;zÐáza•‡X2¯Y¯–4ïQ O¨W•`P#oÝyX”ð1ää›T¥­‹é½®¦âdòÖ½‹ÞJÕºÔX*¶Â+/ºŒO²§¥º[ŠË¼‰ÙÞ9wïú[à>2ÕÒóºËÑK£±¼K>ÈZcIêL§±”¦q† ð°†Çw ûNbç’]‡ùܨä‰"„«zîp>IØ9Ö²æµù¬¬˜¬¤Å±Ë0ØIïè˜ÔV•‹À+™ÆÂ·NØå Af‰í2Jã;Ú-JSp´ø{[\t [©‰â—ÀeÈɇÏ+lïâ,9Ø¡Æ×âÉ‘7håcYÍždKuÞ3]c‡ÚgÙ¼ÜõÝÆÃÈÉ'yF/p𶉸UÃ̉-,”¸+Kô· G(,—èx$ýt&Ф9<œoû>kGÍ2µãG1훌¿»9—‰¹»Ùãóe+Ÿé8å• Ÿ¶«4»Š®R:Píâ·}l½ñìó³,Ž\±lw¬4¤;EC#Çf>OctÖ7O²%áaöÆÃ_=ô3òÐÙÏÓõÐsl#XÜògMý5”~ŽŽ:÷y£³Žz…-,­ÐLׯþú¹ûëÍÏÓõ×ë õVá©¿úígï·óŸ§1:ë·£lɶ‡w\OìYIs·5Ídö3Þ’ éU׿zíÁyí­ÏÓõÚ«´¬ù9-kŽì!V)…jí¥Ò©Êÿ ׺¶ºñ"âYz½Çž tÇÙ>ðp-îb²¼#lð¿8û[¤&Kÿ¾—ÆÇ;ï$¦¿Ê¤w:4-Öj¬å‘ÍÎdpòjÖˆÚÕ½—€±Ué©  ¼Ø©=·[@i.A^J­’F>"uw!'_:ÙÅti—"ËÀÇ“¯[± ÌBΦçqž•<°ƒÏtI]˜Þ3ÝáÛ±ênKJÉØa¦¦Ñò'ÇŠc¨à5È×R3Ô1ÿ0ܸæšÎCžïŒ¹®oA¾•¼Io¡ ý·w 'oê¤{=K¾Q˜Î‘¯¹ v*ɺìCðx˜Iú²¡ÔÚ¢ò08¾9̓M"œ•Ô ‡!'¶Îow¨dh榻ÅÜmËëB{yÙ¶nªÖ6%rj†îʺ‘=| 9yõ£… ›aÚϼ_FK}žÎ$[ˆéhÂÖ%ñô”­ý÷HW#2_o@¾qð®FêF3»[3F}Lhµ3ÞÒ$ÇÕyÿ¹¤yg 1×’õ(â4|9ù>⋌•·s“–$êÎd¢µï!d=ÌETF€× ÇjøåüˆÔ]^‡ë˜à–§!M!Ë2µ¦%ëPDn,³»³ rB’—™:é-/|2Å¥Å_ÒaÃ|Š»¹sLú,Yá>â;YàõÍ÷Í0Gs›èð¤æÕÞ6ùšC\l“Œ pqd›0çvOæ¡c¤coÁˆP8áþ0Q¹¼ ùêÁR7 œ|­Ýµqª”7F&¼Qjö0߯d}Š8~\…œ|‚çQ‹OS¼ºbŒÿLÅÍŽü©Ÿºéïñ·Åø³A¶#ÝoûnG˜Þiwñ®«àœ38.ÓÎËô·Gu§§Èò_gBaei§GTO :ÀtFT},v/÷)H ïÍ;Ü^.‘ž…ë¥=rÁ…Ôžƒ/ÌŠßN ðÑ¿ÝíW6*.œœ\» ëQDvøròŠ¹Ê¼Écí½R­±®qž4D[ã‘Ñãë^Kì‘Ö—}ËŸÁ Ó›çãCg˪*ÙÇgY•d‡g=;ÂtƇò5¨·ß@~bÚ}±BãÃüºúÆÂËìš7 ýðy˜Þ†|;nöÜùkàäX=¹ðBêF‹»öQ¿Æ(Ü%àcÈñ¦aœ¶ç~¼¸Olž_B~Ùì_A~•Ø0ò³¾¤ÿ÷À×_'æÑÏØC‹vN–i—‘$¥ï}ëzØ9Þó‹»Dæ4pr¬‰O97!uÀàeUÉOpþšå8šQ)øçA(t°#7”ÐKˆ;‘AD/—!'ß v†ž÷¿ÓËônZ­ª¸u[3v¤}}ÎDxò™ÄÜbL`l@9aªt2AÙ?|K¥|Tæï4k¼XjL7ßéŽ^2vÆé8H>Õi„Åm.ýß N˜ÞÆ·µNgKi&··÷Ö2I^/Á…pòPj¤¿i“¸l!NÃÀQÈ£GHÝ)à5ÈñºŠß^Ä6Ì`Ÿ¼ïe?ªÒ•“˜].fDS*˜Þ¢ê¿ì"Ds.ò*“`|ÜÔ/íSwL¥ª—W¼—5±£!E(=š'–YqÅtîÁ¤t¨¿Ð+`ü—‹ß^blL{ÏÇ{: •£ÀªÊš§ÈפFQ|â'¼ùRbŠç›ÏD¦¨k™4®“ÞËûàD(¼43iWPzÍ ûðªd+hèaá3oÇ\J´òÀ“OÆ¡Jkd ïb> œ‡<Ÿb¨8u–Ôå€Âñ# ÝI:0úÛâê¸WÿOþá@½:·iUbË“¿—«;©½ˆÆ€€¸:í6E˜(Àt&«GÇZoZ–jjŽ3aU&*ºëŸíT …«™Þ¡y»gyæ·¦µmJOŽþ¬ …ã:]?Bu€é¤|ý{Ýo’Ö?¹(HnœƒÚÜîÕi+ú.quÜ BÉÿ)©ÚFÁ~ßx=!‡›%Å<ð ȱÿIçULD㜀¸:í@ Œ`:Õx%22Wy‹óC-¦”ËVÝtý"ïiQS€”ÍK ü W ¯$ÎË å¥qúžô¸³ "„ƒ;ogª<¬p­A7aÃ5Õ²Ôb¸&õ]¦®¥iTPð¦ã {f;ÂPÕ¯ØÞITe—qð¥7{HŸúÇ kj!8.ÚSí7‘BaéVÂÜ 1öôåÚšwxY‰–oH×ü-p!‚<”š«-¾SŒzØ\Üï¡KOÕºÒNFê³âê4ŸPÆ/°É©Gšeoêìé$+YΖ©¼µÞI|›ñû"„ ÇzIo¨Öž¢Rw·,;Bñ`²%¼‰ Dê/ ˆ«Ó4 ”@€ÉüäXR:Uÿ& Lç.òíµ‰¢ LÞ±\Rñ^Òƒ[8 y:žÄ_Z_¸ç-òiªºãðNí„hwŒ\ Ç!ÇÍÅž;ç3gR,ŸˆgA¤.œ…<›ØuG¢ÇXÖDLæ€÷!ßO­ ˆµÖ˜¨¬W!¯vÆ6€ßBNápuéI,Òÿp ò!¼lÝòÍÙÀÃÕ ›ð£lÛGÊí¸^€œ^ÿ¤m”íö…Çà;Ä#HÂâ)Ý1¼9V‡I®Î’ºðäCè ‘úËâJ)÷½EGÓh»wD_ˆjÄÏ™CÐú¬€‡4 ±Q&ë¨æ÷K'²%ãõÓ{¾ ®„ÅrÊÑÜIîêØÌ™ÙóÓ3‘Ïå#™¹(BÄÃx‘ ‰ÙÙ÷ìwlS±Ë[zuÌd÷ØÌòìê`Dxr¬ Mìi¦5à·¢»c¼»T­ gùÿñé›/0UqéÓ÷FoѸ¸²°¶±,Ÿ‘w O¸y1qFÎñŒ¼¡)cÊßpñäémƒa²fâ·ù€ž4Ÿ÷àðÞ¯}žœ?¸0ÉcºL'ª~72ÂfÞϰªâÚú{¼Ï»\ñö4¼óå,Ó{[g^f4føG㬤´‰Ô-x›¦~þÙ;êG:GF.…½] sôx×ùü7òšR›+°ù»U`7yU–—{Þz1?ëcÓwyÓæùâb|\Þq? „‰æ5CÕæ‹Áæ–ˆ˜Nêþ3UßnêH}VÀCjq?¢Lw 1+ÝÃýKÆŸ"샫Å艽Õv¶-[Ð|xr¬‡’„Ô÷ ˆ+%ƒtoQ\—¤ôWØpò@GlòWØpò`çmòW¤ WJ6é^ð,Iìo°áiȧS´LÙ2ËZÍÐ|øäx¯JdRF@\)YæÄ®eü}Ì’ìþ“Cîˆyþ“¦·.VÚ<¤þ‚€¸âÀžTÞQ›{tÿþ ÙÎdb´h”â8¥ÖŸÓg»©«JÙ¶¨/Ñ­ø¯Ìòî]wËÌ?c6Ðpd $M¾¨Z¦ë‡ìFÂÞV*EÅÐGHq4ôVšY¶h©ž°«%Q/×W~±SÓšÓˆVh¤í)Vôͺ-&=Ý’Ä?ÓXÌakî4§lë%ñ'[uMË áÓ’HÕ~6›™„’î+:õ’ã¿fTH~j7yÈOLm»lU«¼û.üäl›ŸôƒµäÇCYoù$ú¢ùžÑ÷Ñ+¦ÚôÓ«{Ê–¼Æ2fÏi{ßnnRC,ë¾ÐD%ËP÷& )½¢Žx¿3{XnÌ–ÂŒÑr?ǵ­&ÿVvצ$Çx}¨W5[ir®!7âldÅGDÝ{**–54R î‰ ¼’¶!ÝU¬½ ɳ–Z‘+úÆÈž»¼SìOÜ%˜±mõ–’iLl¶­žýE[‹ªD-v žèG–ôÑbÝQ6EfÝNp´h¨^›Ý6ÄRZÃAOÄ#`µVîV޼ðt7¤…´uz-›%Bâ?méû„%xÜ“ÕÖš6UÓZÊ£q¸÷'kä±bãD†f§ɨ·o¸5†Þ•[„ÌQŒæ<ï©(ï>YpΖµý‰‚ë)®«ÏjMüµáÖUT+¢åûBPÓµëfnýÅû–]Uè”ç6 )ð´Ö˜°ºÚST¿¯[ûr¸£EWwý4ï½Eêà˜;ÕO(?ÊÛ¢=MQÛÒ"FýÏ!17$mc`øI¶Ùâzçï.:<8‡»_kgC©ŠÜÂzR¼jSÜaý$ÏÖ{sÑ¢Ú_ÞÙH4®ÚªÛåýد»¨”J!Q>"ñ;Í;£aÝ•c¼ªðdNsì +¡£E­ªèF¸òÖúì-m[:ǽG©seCqœLtý ¹6ô‡Ü,_tvL«æè-}æ–Ê¡«ø¶Ô.ôñÛº?UT<4Fu…Û^ä/EÐ;U¬)å·¼Ù}(¶Ù@Åpݰ¹ëÜìLø>~üøÁBòxù" 9G/a{‹%½ä÷²Ò0gvd:$ ÷@›pòpœ,´45ÛÚ4O¦Á=ÔB|þÞu*F¦ÉHüÿìÍ#KóÍYg¡½ÖñG"gñ-ÖéY'[\=HÒw@”0dõDLҽťõ…§Þ= êóÞôЇ-×­9w§¦èÞ“ëÜkâÖIËÞœBûw;Öšðü,$»CÈ"áÈORq1Þ!u8 -(w>¬ý…×–+aÁƒæâ‡¶y ”ð Д†U¿‘ïÞxC¶èŽÍäP8‡"Y9ìkr0(ŸUSÕ½ži%ô@¾„t_týåBø#äSkw»ÇËKë«Ï_¬>{šNYÄè ¢Ëã:Ê€0¤33å°€Y¼4Šà¾|ø“ˆÑ¹ÿ9&MH!vUKO'ßûèÛreѹœ@Î@~ØÆCŸ(ºÉ‡î¦–’—äí\mPˆ.…¯sBa£pÊѱeðÜé«yà±®bˆ&æçÞ¾‡€|PiNy«Ó'üåaqånO§fk5z1p/õ¹ÿ¿™àßž¹%šRsZØ î¹æßÿùk<÷ÖfGarch/man/0000755000176200001440000000000015104730075012221 5ustar liggesusersfGarch/man/garchSpec.Rd0000644000176200001440000001577115104730075014422 0ustar liggesusers\name{garchSpec} \alias{garchSpec} \concept{GARCH model} \concept{APARCH model} \concept{asymmetric power ARCH model} \concept{ARMA-GARCH model} \concept{ARMA-APARCH model} \title{Univariate GARCH/APARCH time series specification} \description{ Specifies an univariate ARMA-GARCH or ARMA-APARCH time series model. } \usage{ garchSpec(model = list(), presample = NULL, cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd"), rseed = NULL) } \arguments{ \item{model}{ a list of GARCH model parameters, see section \sQuote{Details}. The default \code{model=list()} specifies Bollerslev's GARCH(1,1) model with normal conditional distributed innovations. } \item{presample}{ a numeric three column matrix with start values for the series, for the innovations, and for the conditional variances. For an ARMA(m,n)-GARCH(p,q) process the number of rows must be at least max(m,n,p,q)+1, longer presamples are truncated. Note, all presamples are initialized by a normal-GARCH(p,q) process. } \item{cond.dist}{ a character string naming the desired conditional distribution. Valid values are \code{"norm"}, \code{"ged"}, \code{"std"}, \code{"snorm"}, \code{"sged"}, \code{"sstd"}. The default value is \code{"norm"}, the standard normal distribution. } \item{rseed}{ single integer argument, the seed for the intitialization of the random number generator for the innovations. If \code{rseed=NULL}, the default, then the state of the random number generator is not touched by this function. } } \details{ \code{garchSpec} specifies a GARCH or APARCH time series model which can be used for simulating artificial GARCH and/or APARCH time series. This is very useful for testing the GARCH parameter estimation results, since the model parameters are known and well specified. Argument \code{model} is a list of model parameters. For the GARCH part of the model they are: \describe{ \item{\code{omega}}{the constant coefficient of the variance equation, by default \code{1e-6};} \item{\code{alpha}}{the value or vector of autoregressive coefficients, by default 0.1, specifying a model of order 1;} \item{\code{beta}}{the value or vector of variance coefficients, by default 0.8, specifying a model of order 1.} } If the model is APARCH, then the following additional parameters are available: \describe{ \item{delta}{a positive number, the power of sigma in the volatility equation, it is 2 for GARCH models;} \item{gamma}{the leverage parameters, a vector of length \code{alpha}, containing numbers in the interval \eqn{(0,1)}.} } The values for the linear part (conditional mean) are: \describe{ \item{\code{mu}}{the mean value, by default NULL;} \item{\code{ar}}{the autoregressive ARMA coefficients, by default NULL;} \item{\code{ma}}{the moving average ARMA coefficients, by default NULL.} } The parameters for the conditional distributions are: \describe{ \item{\code{skew}}{the skewness parameter (also named "xi"), by default 0.9, effective only for the \code{"dsnorm"}, the \code{"dsged"}, and the \code{"dsstd"} skewed conditional distributions;} \item{\code{shape}}{the shape parameter (also named "nu"), by default 2 for the \code{"dged"} and \code{"dsged"}, and by default 4 for the \code{"dstd"} and \code{"dsstd"} conditional distributions.} } For example, specifying a subset AR(5[1,5])-GARCH(2,1) model with a standardized Student-t distribution with four degrees of freedom will return the following printed output: \preformatted{ garchSpec(model = list(ar = c(0.5,0,0,0,0.1), alpha = c(0.1, 0.1), beta = 0.75, shape = 4), cond.dist = "std") Formula: ~ ar(5) + garch(2, 1) Model: ar: 0.5 0 0 0 0.1 omega: 1e-06 alpha: 0.1 0.1 beta: 0.75 Distribution: std Distributional Parameter: nu = 4 Presample: time z h y 0 0 -0.3262334 2e-05 0 -1 -1 1.3297993 2e-05 0 -2 -2 1.2724293 2e-05 0 -3 -3 0.4146414 2e-05 0 -4 -4 -1.5399500 2e-05 0 } Its interpretation is as follows. \sQuote{Formula} describes the formula expression specifying the generating process, \sQuote{Model} lists the associated model parameters, \sQuote{Distribution} the type of the conditional distribution function in use, \sQuote{Distributional Parameters} lists the distributional parameter (if any), and the \sQuote{Presample} shows the presample input matrix. If we have specified \code{presample = NULL} in the argument list, then the presample is generated automatically by default as norm-AR()-GARCH() process. } \value{ an object of class \code{"\linkS4class{fGARCHSPEC}"} } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{garchSim}}, \code{\link{garchFit}} } \examples{ # Normal Conditional Distribution: spec = garchSpec() spec # Skewed Normal Conditional Distribution: spec = garchSpec(model = list(skew = 0.8), cond.dist = "snorm") spec # Skewed GED Conditional Distribution: spec = garchSpec(model = list(skew = 0.9, shape = 4.8), cond.dist = "sged") spec ## More specifications ... # Default GARCH(1,1) - uses default parameter settings garchSpec(model = list()) # ARCH(2) - use default omega and specify alpha, set beta=0! garchSpec(model = list(alpha = c(0.2, 0.4), beta = 0)) # AR(1)-ARCH(2) - use default mu, omega garchSpec(model = list(ar = 0.5, alpha = c(0.3, 0.4), beta = 0)) # AR([1,5])-GARCH(1,1) - use default garch values and subset ar[.] garchSpec(model = list(mu = 0.001, ar = c(0.5,0,0,0,0.1))) # ARMA(1,2)-GARCH(1,1) - use default garch values garchSpec(model = list(ar = 0.5, ma = c(0.3, -0.3))) # GARCH(1,1) - use default omega and specify alpha/beta garchSpec(model = list(alpha = 0.2, beta = 0.7)) # GARCH(1,1) - specify omega/alpha/beta garchSpec(model = list(omega = 1e-6, alpha = 0.1, beta = 0.8)) # GARCH(1,2) - use default omega and specify alpha[1]/beta[2] garchSpec(model = list(alpha = 0.1, beta = c(0.4, 0.4))) # GARCH(2,1) - use default omega and specify alpha[2]/beta[1] garchSpec(model = list(alpha = c(0.12, 0.04), beta = 0.08)) # snorm-ARCH(1) - use defaults with skew Normal garchSpec(model = list(beta = 0, skew = 0.8), cond.dist = "snorm") # sged-GARCH(1,1) - using defaults with skew GED garchSpec(model = list(skew = 0.93, shape = 3), cond.dist = "sged") # Taylor Schwert GARCH(1,1) - this belongs to the family of APARCH Models garchSpec(model = list(delta = 1)) # AR(1)-t-APARCH(2, 1) - a little bit more complex specification ... garchSpec(model = list(mu = 1.0e-4, ar = 0.5, omega = 1.0e-6, alpha = c(0.10, 0.05), gamma = c(0, 0), beta = 0.8, delta = 1.8, shape = 4, skew = 0.85), cond.dist = "sstd") } \keyword{models} \keyword{ts} fGarch/man/stats-tsdiag.Rd0000644000176200001440000001041415104730075015117 0ustar liggesusers\name{stats-tsdiag} \alias{stats-tsdiag} \alias{tsdiag} \alias{tsdiag.fGARCH} \title{Diagnostic plots and statistics for fitted GARCH models} \description{ Produce diagnostics for fitted GARCH/APARCH models. The method offers several tests, plots of autocorrelations and partial autocorrelations of the standardised conditional residuals, ability to control which graphs are produced (including interactively), as well as their layout. } \usage{ \method{tsdiag}{fGARCH}(object, gof.lag = NULL, ask = FALSE, \dots, plot = c(4L, 5L, 7L), layout = NULL) } \arguments{ \item{object}{ an object from class \code{"fGARCH"}, as returned by \code{\link{garchFit}}. } \item{gof.lag}{maximal lag for portmanteau tests.} \item{ask}{if \code{TRUE} present a menu of available plots, see Details.} \item{\dots}{not used.} \item{plot}{ if \code{TRUE} all available plots; a vector of positive integers specifies a subset of the available plots. } \item{layout}{ a list with arguments for \code{graphics::layout} for the plots. The default plots the autocorrelations of the standardised conditional residuals and their squares, as well as a QQ-plot for the fitted conditional distribution. } } \details{ Compute and graph diagnostics for fitted ARMA-GARCH/APARCH models. % The method offers several portmanteau tests (including Ljung-Box, % Li-McLeod and Box-Pierce), plots of autocorrelations and partial % autocorrelations of the residuals, ability to control which graphs are % produced (including interactively), as well as their layout. % % The method always makes a correction of the degrees of freedom of the % portmanteau tests (roughly, subtracting the number of estimated ARMA % parameters). Note that \code{stats::tsdiag} doesn't do that. \code{plot} can be \code{TRUE} to ask for all plots or a vector of positive integers specifying which plots to consider. Currently the following options are available: \Sexpr[stage=build,results=rd]{paste0("\\\\tabular{rl}{", paste0(1:length(fGarch:::.tsdiag_choices), " \\\\tab ", fGarch:::.tsdiag_choices, collapse = " \\\\cr\n "), "}\n")} The default produces plots of autocorrelations and partial autocorrelations of the standardised conditional residuals, as well as a QQ-plot for the fitted conditional distribution. If \code{plot} is \code{TRUE}, you probably need also \code{ask = TRUE}. If argument \code{plot} is of length two the graphics window is split into 2 equal subwindows. Argument \code{layout} can still be used to change this. If argument \code{plot} is of length one the graphics window is not split at all. In interactive sessions, if the number of requested graphs (as specified by argument \code{plot}) is larger than the number of graphs specified by the layout (by default 3), the function makes the first graph and then presents a menu of the requested plots. Argument \code{layout} can be used to change the layout of the plot, for example to put two graphs per plot, see the examples. Currently it should be a list of arguments for \code{\link[graphics]{layout}}, see \code{?layout}. Don't call \code{layout} youself, as that will change the graphics device prematurely. The computed results are returned (invisibly). This is another difference from \code{stats::tsdiag} which doesn't return them. } \value{ (experimental, may change) a list with components: \item{residuals}{standardised conditional residuals,} \item{gof}{ goodness-of-fit tests, pretending parameters are known, } \item{gof_composite}{ goodness-of-fit tests taking into account that the parameters are estimated. } Only components that are actually computed are included, the rest are NULL or absent. } \author{Georgi N. boshnakov} \seealso{ \code{\link[=plot,fGARCH,missing-method]{fGARCH}} method for \code{plot}, \code{\link[stats]{tsdiag}} } \examples{ set.seed(20230612) x <- garchSim(n = 200) fit <- garchFit(formula = ~ garch(1, 1), data = x, trace = FALSE) fit_test <- tsdiag(fit) fit_test ## 2x2 matrix with acf of r, r^2 on diag, cor(r,r^2) below it, and qq-plot tsdiag(fit, plot = c(4, 6, 7, 5), layout = list(matrix(1:4, nrow = 2))) } \keyword{ts} \keyword{htest} \concept{diagnostics} \concept{diagnostic plots} fGarch/man/methods-coef.Rd0000644000176200001440000000210215104730075015060 0ustar liggesusers\name{coef-methods} \alias{coef-methods} \docType{methods} \alias{coef} \alias{coef,fGARCH-method} \alias{coef,fGARCHSPEC-method} \title{GARCH coefficients methods} \description{ Coefficients methods \code{coef()} for GARCH Models. } \section{Methods}{ Methods for \code{coef} defined in package \pkg{fGarch}: \describe{ \item{object = "fGARCH"}{ Extractor function for coefficients from a fitted GARCH model. } \item{object = "fGARCHSPEC"}{ Extractor function for coefficients from a GARCH specification structure. } } } \note{ \code{\link{coef}} is a generic function which extracts coefficients from objects returned by modeling functions. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \examples{ # Use default parameters beside alpha: spec <- garchSpec(model = list(alpha = c(0.05, 0.05))) spec coef(spec) ## Simulate an univariate "timeSeries" series from specification 'spec': x <- garchSim(spec, n = 2000) x <- x[,1] fit <- garchFit( ~ garch(1, 1), data = x, trace = FALSE) coef(fit) } \keyword{models} fGarch/man/class-fGARCH.Rd0000644000176200001440000001101615104730075014604 0ustar liggesusers\name{fGARCH-class} \alias{fGARCH-class} \docType{class} \alias{show,fGARCH-method} \alias{update,fGARCH-method} \concept{GARCH model} \concept{APARCH model} \concept{ARMA-GARCH model} \concept{ARMA-APARCH model} \concept{AR-GARCH model} \concept{AR-APARCH model} \concept{MA-GARCH model} \concept{MA-APARCH model} \title{Class "fGARCH" - fitted ARMA-GARCH/APARCH models} \description{ Class 'fGARCH' represents models fitted to heteroskedastic time series, including ARCH, GARCH, APARCH, ARMA-GARCH and ARMA-APARCH models. } \section{Objects from the Class}{ Objects from class \code{"fGARCH"} can be created by calls of the function \code{\link{garchFit}}. } \section{Slots}{ \describe{ \item{\code{call}:}{Object of class \code{"call"}, the call used to fit the model and create the object. } \item{\code{formula}:}{Object of class \code{"formula"}, a formula object representing the mean and variance equations. } \item{\code{method}:}{Object of class \code{"character"}, a string denoting the optimization method, by default \code{"Max Log-Likelihood Estimation"}. } \item{\code{data}:}{Object of class \code{"list"}, a list with one entry, \code{x}, containing the data of the time series to which the model is fitted. } \item{\code{fit}:}{Object of class \code{"list"}, a list with the results from the parameter estimation. The entries of the list depend on the selected algorithm, see below. } \item{\code{residuals}:}{Object of class \code{"numeric"}, the raw, unstandardized residuals. } \item{\code{fitted}:}{Object of class \code{"numeric"}, the fitted values. } \item{\code{h.t}:}{Object of class \code{"numeric"}, the conditional variances (\eqn{h_t = \sigma_t^\delta}{h.t = sigma.t^delta}). } \item{\code{sigma.t}:}{Object of class \code{"numeric"}, the conditional standard deviations. } \item{\code{title}:}{Object of class \code{"character"}, a title string. } \item{\code{description}:}{Object of class \code{"character"}, a string with a brief description. } } } % \item{volatility}{\code{signature(object = "fGARCH")}: % extracts conditional volatility from an object of class \code{"fGARCH"}. % } \section{Methods}{ Besides the S4 methods described below, the are \code{"fGARCH"} methods (S3) for \code{tsdiag} (\code{\link{tsdiag}}), VaR (\code{\link{VaR}}), expected shortfall (\code{\link{ES}}), volatility (\code{\link{volatility}}), and maybe others. \describe{ \item{plot}{\code{signature(x = "fGARCH", y = "missing")}: plots an object of class \code{"fGARCH"}, see the \code{\link[=plot,fGARCH,missing-method]{help page}} of the method for details and options. } \item{show}{\code{signature(object = "fGARCH")}: prints the object. } \item{summary}{\code{signature(object = "fGARCH")}: summarizes the object. The \code{\link[=summary-methods]{help page}} of the \code{"fGARCH"} method gives details on the output, as well as interpretation of the results. } \item{predict}{\code{signature(object = "fGARCH")}: Computes forecasts of the mean and some measures of risk (such as volatility, value-at-risk and expected shortfall), see the method's \code{\link[=predict-methods]{help page}} for full details. } \item{fitted}{\code{signature(object = "fGARCH")}: extracts fitted values from the object (\code{\link[=fitted-methods]{help page}}). } \item{residuals}{\code{signature(object = "fGARCH")}: returns residuals from the fitted model (\code{\link[=residuals-methods]{help page}}). } \item{coef}{\code{signature(object = "fGARCH")}: extracts the estimated coefficients (\code{\link[=coef-methods]{help page}}). } \item{formula}{\code{signature(x = "fGARCH")}: extracts the formula expression, see the method's \code{\link[=formula-methods]{help page}}. } \item{update}{\code{signature(object = "fGARCH")}: ... } } } \author{ Diethelm Wuertz and Rmetrics Core Team } \seealso{ \code{\link{garchFit}}, \code{\link{garchSpec}}, \code{\link{garchFitControl}} } \examples{ ## simulate a time series, fit a GARCH(1,1) model, and show it: x <- garchSim( garchSpec(), n = 500) fit <- garchFit(~ garch(1, 1), data = x, trace = FALSE) coef(fit) summary(fit) fit # == print(fit) and also == show(fit) } \keyword{programming} \keyword{ts} fGarch/man/00fGarch-package.Rd0000644000176200001440000001346215104730075015441 0ustar liggesusers\name{fGarch-package} \alias{fGarch-package} \docType{package} \alias{fGarch} \concept{GARCH model} \concept{APARCH model} \concept{ARMA-GARCH model} \concept{ARMA-APARCH model} \concept{skew distribution} \concept{fit skew distribution} \concept{volatility} \title{Modelling heterskedasticity in financial time series} \description{ The Rmetrics package \pkg{fGarch} is a collection of functions to analyze and model heteroskedastic behavior in financial time series. The website \url{https://geobosh.github.io/fGarchDoc/} contains the documentation of the package with a reference section in which the functions are grouped by topic. } \author{ Diethelm Wuertz [aut] (original code), Yohan Chalabi [aut], Tobias Setz [aut], Martin Maechler [ctb] (), Chris Boudt [ctb] Pierre Chausse [ctb], Michal Miklovac [ctb], Georgi N. Boshnakov [cre, aut] Maintainer: Georgi N. Boshnakov } % \details{ % % } \section{1 Introduction}{ GARCH, Generalized Autoregressive Conditional Heteroskedastic, models have become important in the analysis of time series data, particularly in financial applications when the goal is to analyze and forecast volatility. For this purpose, the family of GARCH functions offers functions for simulating, estimating and forecasting various univariate GARCH-type time series models in the conditional variance and an ARMA specification in the conditional mean. The function \code{\link{garchFit}} is a numerical implementation of the maximum log-likelihood approach under different assumptions, Normal, Student-t, GED errors or their skewed versions. The parameter estimates are checked by several diagnostic analysis tools including graphical features and hypothesis tests. Functions to compute n-step ahead forecasts of both the conditional mean and variance are also available. The number of GARCH models is immense, but the most influential models were the first. Beside the standard ARCH model introduced by Engle [1982] and the GARCH model introduced by Bollerslev [1986], the function \code{garchFit} also includes the more general class of asymmetric power ARCH models, named APARCH, introduced by Ding, Granger and Engle [1993]. The APARCH models include as special cases the TS-GARCH model of Taylor [1986] and Schwert [1989], the GJR-GARCH model of Glosten, Jaganathan, and Runkle [1993], the T-ARCH model of Zakoian [1993], the N-ARCH model of Higgins and Bera [1992], and the Log-ARCH model of Geweke [1986] and Pentula [1986]. There exist a collection of review articles by Bollerslev, Chou and Kroner [1992], Bera and Higgins [1993], Bollerslev, Engle and Nelson [1994], Engle [2001], Engle and Patton [2001], and Li, Ling and McAleer [2002] which give a good overview of the scope of the research. } \section{2 Time series simulation}{ Functions to simulate artificial GARCH and APARCH time series processes. \tabular{ll}{ \code{\link{garchSpec}} \tab specifies an univariate GARCH time series model\cr \code{\link{garchSim}} \tab simulates a GARCH/APARCH process } } \section{3 Parameter estimation}{ Functions to fit the parameters of GARCH and APARCH time series processes. \tabular{ll}{ \code{\link{garchFit}} \tab fits the parameters of a GARCH process } \subsection{Extractor Functions:}{ \tabular{ll}{ \code{\link{residuals}} \tab extracts residuals from a fitted \code{"fGARCH"} object\cr \code{\link{fitted}} \tab extracts fitted values from a fitted \code{"fGARCH"} object\cr \code{\link{volatility}} \tab extracts conditional volatility from a fitted \code{"fGARCH"} object\cr \code{\link{coef}} \tab extracts coefficients from a fitted \code{"fGARCH"} object\cr \code{\link{formula}} \tab extracts formula expression from a fitted \code{"fGARCH"} object } } } \section{4 Forecasting}{ Functions to forecast mean and variance of GARCH and APARCH processes. \tabular{ll}{ \code{\link{predict}} \tab forecasts from an object of class \code{"fGARCH"} } } \section{5 Standardized distributions}{ This section contains functions to model standardized distributions. \subsection{Skew normal distribution:}{ \tabular{ll}{ \code{\link[=dnorm]{[dpqr]norm}} \tab Normal distribution (base R)\cr \code{\link[=dsnorm]{[dpqr]snorm}} \tab Skew normal distribution\cr \code{\link[=snormFit]{snormFit}} \tab fits parameters of Skew normal distribution } } \subsection{Skew generalized error distribution:}{ \tabular{ll}{ \code{\link[=dged]{[dpqr]ged}} \tab Generalized error distribution\cr \code{\link[=psged]{[dpqr]sged}} \tab Skew Generalized error distribution\cr \code{\link[=gedFit]{gedFit}} \tab fits parameters of Generalized error distribution\cr \code{\link[=sgedFit]{sgedFit}} \tab fits parameters of Skew generalized error distribution } } \subsection{Skew standardized Student-t distribution:}{ \tabular{ll}{ \code{\link[=dstd]{[dpqr]std}} \tab Standardized Student-t distribution\cr \code{\link[=dsstd]{[dpqr]sstd}} \tab Skew standardized Student-t distribution\cr \code{\link[=stdFit]{stdFit}} \tab fits parameters of Standardized Student-t distribution\cr \code{\link[=sstdFit]{sstdFit}} \tab fits parameters of Skew standardized Student-t distribution } } \subsection{Absolute moments:}{ \tabular{ll}{ \code{\link{absMoments}} \tab computes absolute moments of these distribution } } } \section{About Rmetrics}{ The \code{fGarch} Rmetrics package is written for educational support in teaching \dQuote{Computational Finance and Financial Engineering} and licensed under the GPL. } \keyword{package} fGarch/man/dist-sstd.Rd0000644000176200001440000000607115104730075014432 0ustar liggesusers\name{sstd} \alias{sstd} \alias{dsstd} \alias{psstd} \alias{qsstd} \alias{rsstd} \concept{standardized skew Student-t distribution} \concept{skew Student-t distribution} \concept{skewed Student-t distribution} \concept{skew distribution} \concept{skewed distribution} \title{Skew Student-t distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the skew Student-t distribution. Note that there are different ways to define a skew-t distribution, check section Details to see if this is the distribution you want. } \usage{ dsstd(x, mean = 0, sd = 1, nu = 5, xi = 1.5, log = FALSE) psstd(q, mean = 0, sd = 1, nu = 5, xi = 1.5) qsstd(p, mean = 0, sd = 1, nu = 5, xi = 1.5) rsstd(n, mean = 0, sd = 1, nu = 5, xi = 1.5) } \arguments{ \item{x, q}{ a numeric vector of quantiles. } \item{p}{ a numeric vector of probabilities. } \item{n}{ number of observations to simulate. } \item{mean}{ location parameter. } \item{sd}{ scale parameter. } \item{nu}{ shape parameter (degrees of freedom). } \item{xi}{ skewness parameter, a positive number. \code{xi = 1} gives a symmetric distribution (here normal). } \item{log}{ logical; if \code{TRUE}, densities are given as log densities. } } \details{ Skewness is based on the scheme by Fernandez and Steel (2000) but with different parameterisation as discussed by Wuertz et al (????), in that the skewness (\code{xi}), degrees of freedom (\code{nu}), mean (\code{mean}) and standard deviation (\code{sd}) are independent parameters. \code{dsstd} computes the density, \code{psstd} the distribution function, \code{qsstd} the quantile function, and \code{rsstd} generates random deviates. } \value{ numeric vector } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. Wuertz D., Chalabi Y. and Luksan L. (????); \emph{Parameter estimation of ARMA models with GARCH/APARCH errors: An R and SPlus software implementation}, Preprint, 41 pages, \url{https://github.com/GeoBosh/fGarchDoc/blob/master/WurtzEtAlGarch.pdf} } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{sstdFit}} (fit), \code{\link{sstdSlider}} (visualize) \code{\link{snorm}} (skew normal), \code{\link{sged}} (skew GED) } \examples{ ## sstd - par(mfrow = c(2, 2)) set.seed(1953) r = rsstd(n = 1000) plot(r, type = "l", main = "sstd", col = "steelblue") # Plot empirical density and compare with true density: hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue") box() x = seq(min(r), max(r), length = 201) lines(x, dsstd(x), lwd = 2) # Plot df and compare with true df: plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue", ylab = "Probability") lines(x, psstd(x), lwd = 2) # Compute quantiles: round(qsstd(psstd(q = seq(-1, 5, by = 1))), digits = 6) } \keyword{distribution} fGarch/man/garchSim.Rd0000644000176200001440000001262615104730075014254 0ustar liggesusers\name{garchSim} \alias{garchSim} \concept{GARCH model} \concept{APARCH model} \concept{simulate GARCH} \concept{simulate APARCH} \title{Simulate univariate GARCH/APARCH time series} \description{ Simulates univariate GARCH/APARCH time series. } \usage{ garchSim(spec = garchSpec(), n = 100, n.start = 100, extended = FALSE) } \arguments{ \item{spec}{ a specification object of class \code{"\linkS4class{fGARCHSPEC}"} as returned by \code{\link{garchSpec}}. See also below for further details. } \item{n}{ length of the output series, an integer value, by default \code{n=100}. } \item{n.start}{ length of \sQuote{burn-in} period, by default 100. } \item{extended}{ logical parameter specifying what to return. If \code{FALSE}, return the univariate GARCH/APARCH time series. If \code{TRUE}, return a multivariate time series containing also the volatility and conditional innovations time series. } } \details{ \code{garchSim} simulates an univariate GARCH or APARCH time series process as specified by argument \code{spec}. The default model specifies Bollerslev's GARCH(1,1) model with normally distributed innovations. \code{spec} is an object of class \code{"fGARCHSPEC"} as returned by the function \code{\link{garchSpec}}. It comes with a slot \code{@model} which is a list of just the numeric parameter entries. These are recognized and extracted for use by the function \code{garchSim}. % (GB) commenting out since the return value is 'timeSeries'. % % By default the series will be returned as an object of class % \code{"ts"} or as a \code{"numeric"} vector. Having time/date % positions, e.g. from an empirical process the numeric vector can be % easily transformed into other time series objects like % \code{"timeSeries"} or \code{"zoo"}. So One can estimate the parameters of a GARCH process from empirical data using the function \code{garchFit} and then simulate statistically equivalent GARCH processes with the same set of model parameters using the function \code{garchSim}. % (GB) commenting out since there is no argument 'returnClass' % (apparently it is superseded by 'extend') % % The third entry in the argument \code{returnClass="mts"} allows to % return a trivariate time series, where the first column contains the % simulated \code{"garch"} process, the second column the conditional % standard deviations \code{"h"}, and the last column the innovations % named \code{"eps"}. } \value{ the simulated time series as an objects of class \code{"timeSeries"} with attribute \code{"spec"} containing the specification of the model. If \code{extended} is \code{TRUE}, then the time series is multivariate and contains also the volatility, \code{sigma}, and the conditional innovations, \code{eps}. } \note{ An undocumented feature (so, it should not be relied on) is that the returned time series is timed so that the last observation is the day before the date when the function is executed. This probably should be controlled by an additional argument in \code{garchSim}. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{garchSpec}}, \code{\link{garchFit}} } \examples{ ## default garch model spec <- garchSpec() spec x <- garchSim(spec, n = 50) class(x) print(x) ## More simulations ... ## Default GARCH(1,1) - uses default parameter settings spec <- garchSpec(model = list()) garchSim(spec, n = 10) ## ARCH(2) - use default omega and specify alpha, set beta=0! spec <- garchSpec(model = list(alpha = c(0.2, 0.4), beta = 0)) garchSim(spec, n = 10) ## AR(1)-ARCH(2) - use default mu, omega spec <- garchSpec(model = list(ar = 0.5, alpha = c(0.3, 0.4), beta = 0)) garchSim(spec, n = 10) ## AR([1,5])-GARCH(1,1) - use default garch values and subset ar[.] spec <- garchSpec(model = list(mu = 0.001, ar = c(0.5,0,0,0,0.1))) garchSim(spec, n = 10) ## ARMA(1,2)-GARCH(1,1) - use default garch values spec <- garchSpec(model = list(ar = 0.5, ma = c(0.3, -0.3))) garchSim(spec, n = 10) ## GARCH(1,1) - use default omega and specify alpha/beta spec <- garchSpec(model = list(alpha = 0.2, beta = 0.7)) garchSim(spec, n = 10) ## GARCH(1,1) - specify omega/alpha/beta spec <- garchSpec(model = list(omega = 1e-6, alpha = 0.1, beta = 0.8)) garchSim(spec, n = 10) ## GARCH(1,2) - use default omega and specify alpha[1]/beta[2] spec <- garchSpec(model = list(alpha = 0.1, beta = c(0.4, 0.4))) garchSim(spec, n = 10) ## GARCH(2,1) - use default omega and specify alpha[2]/beta[1] spec <- garchSpec(model = list(alpha = c(0.12, 0.04), beta = 0.08)) garchSim(spec, n = 10) ## snorm-ARCH(1) - use defaults with skew Normal spec <- garchSpec(model = list(beta = 0, skew = 0.8), cond.dist = "snorm") garchSim(spec, n = 10) ## sged-GARCH(1,1) - using defaults with skew GED model = garchSpec(model = list(skew = 0.93, shape = 3), cond.dist = "sged") garchSim(model, n = 10) ## Taylor Schwert GARCH(1,1) - this belongs to the family of APARCH Models spec <- garchSpec(model = list(delta = 1)) garchSim(spec, n = 10) ## AR(1)-t-APARCH(2, 1) - a little bit more complex specification ... spec <- garchSpec(model = list(mu = 1.0e-4, ar = 0.5, omega = 1.0e-6, alpha = c(0.10, 0.05), gamma = c(0, 0), beta = 0.8, delta = 1.8, shape = 4, skew = 0.85), cond.dist = "sstd") garchSim(spec, n = 10) garchSim(spec, n = 10, extended = TRUE) } \keyword{models} \keyword{ts} fGarch/man/dist-std.Rd0000644000176200001440000000606215104730075014247 0ustar liggesusers\name{std} \alias{std} \alias{dstd} \alias{pstd} \alias{qstd} \alias{rstd} \concept{t-distribution} \concept{Student-t distribution} \concept{standardized Student t distribution} \concept{standardized Student-t distribution} \title{Standardized Student-t distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the standardized Student-t distribution. } \usage{ dstd(x, mean = 0, sd = 1, nu = 5, log = FALSE) pstd(q, mean = 0, sd = 1, nu = 5) qstd(p, mean = 0, sd = 1, nu = 5) rstd(n, mean = 0, sd = 1, nu = 5) } \arguments{ \item{x, q}{ a numeric vector of quantiles. } \item{p}{ a numeric vector of probabilities. } \item{n}{ number of observations to simulate. } \item{mean}{ location parameter. } \item{sd}{ scale parameter. } \item{nu}{ shape parameter (degrees of freedom). } \item{log}{ logical; if \code{TRUE}, densities are given as log densities. } } \details{ The standardized Student-t distribution is defined so that for a given \code{sd} it has the same variance, \code{sd^2}, for all degrees of freedom. For comparison, the variance of the usual Student-t distribution is \code{nu/(nu-2)}, where \code{nu} is the degrees of freedom. The usual Student-t distribution is obtained by setting \code{sd = sqrt(nu/(nu - 2))}. Argument \code{nu} must be greater than 2. Although there is a default value for \code{nu}, it is rather arbitrary and relying on it is strongly discouraged. \code{dstd} computes the density, \code{pstd} the distribution function, \code{qstd} the quantile function, and \code{rstd} generates random deviates from the standardized-t distribution with the specified parameters. } \value{ numeric vector } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. Wuertz D., Chalabi Y. and Luksan L. (2006); \emph{Parameter estimation of ARMA models with GARCH/APARCH errors: An R and SPlus software implementation}, Preprint, 41 pages, \url{https://github.com/GeoBosh/fGarchDoc/blob/master/WurtzEtAlGarch.pdf} } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{stdFit}} (fit). \code{\link{stdSlider}} (visualize), \code{\link{absMoments}} } \examples{ ## std - pstd(1, sd = sqrt(5/(5-2)), nu = 5) == pt(1, df = 5) # TRUE par(mfrow = c(2, 2)) set.seed(1953) r = rstd(n = 1000) plot(r, type = "l", main = "sstd", col = "steelblue") # Plot empirical density and compare with true density: hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue") box() x = seq(min(r), max(r), length = 201) lines(x, dstd(x), lwd = 2) # Plot df and compare with true df: plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue", ylab = "Probability") lines(x, pstd(x), lwd = 2) # Compute quantiles: round(qstd(pstd(q = seq(-1, 5, by = 1))), digits = 6) } \keyword{distribution} fGarch/man/methods-volatility.Rd0000644000176200001440000000557415104730075016364 0ustar liggesusers\name{volatility-methods} \docType{methods} \alias{volatility}% S3 method now \alias{volatility.fGARCH}% S3 method now \title{Extract GARCH model volatility} \description{ Extracts volatility from a fitted GARCH object. } \usage{ \S3method{volatility}{fGARCH}(object, type = c("sigma", "h"), \dots) } \arguments{ \item{object}{ an object of class \code{"fGARCH"} as returned by \code{\link{garchFit}()}. } \item{type}{ a character string denoting if the conditional standard deviations \code{"sigma"} or the variances \code{"h"} should be returned. } \item{\dots}{currently not used.} } \details{ \code{volatility} is an S3 generic function for computation of volatility, see \code{\link[fBasics]{volatility}} for the default method. The method for \code{"fGARCH"} objects, described here, extracts the volatility from slot \code{@sigma.t} or \code{@h.t} of an \code{"fGARCH"} object usually obtained from the function \code{\link{garchFit}()}. The class of the returned value depends on the input to the function \code{garchFit} who created the object. The returned value is always of the same class as the input object to the argument \code{data} in the function \code{garchFit}, i.e. if you fit a \code{"timeSeries"} object, you will get back from the function \code{fitted} also a \code{"timeSeries"} object, if you fit an object of class \code{"zoo"}, you will get back again a \code{"zoo"} object. The same holds for a \code{"numeric"} vector, for a \code{"data.frame"}, and for objects of class \code{"ts", "mts"}. In contrast, the slot itself always contains a numeric vector, independently of the class of the input data input, i.e. the function call \code{slot(object, "fitted")} will return a numeric vector. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \note{ (GNB) Contrary to the description of the returned value of the \code{"fGARCH"} method, it is always \code{"numeric"}. TODO: either implement the documented behaviour or fix the documentation. } \section{Methods}{ Methods for \code{volatility} defined in package \pkg{fGarch}: \describe{ \item{object = "fGARCH"}{ Extractor function for volatility or standard deviation from an object of class \code{"fGARCH"}. } } } \seealso{ \code{\link{garchFit}}, class \code{\linkS4class{fGARCH}} } \examples{ ## Swiss Pension fund Index - stopifnot(require("timeSeries")) # need package 'timeSeries' x <- as.timeSeries(data(LPP2005REC, package = "timeSeries")) fit <- garchFit(LPP40 ~ garch(1, 1), data = 100*x, trace = FALSE) fit ## volatility ## Standard Deviation: vola <- volatility(fit, type = "sigma") head(vola) class(vola) ## Variance: vola <- volatility(fit, type = "h") head(vola) class(vola) ## slot vola <- slot(fit, "sigma.t") head(vola) class(vola) vola <- slot(fit, "h.t") head(vola) class(vola) } \keyword{models} fGarch/man/dist-stdFit.Rd0000644000176200001440000000243315104730075014710 0ustar liggesusers\name{stdFit} \alias{stdFit} \title{Student-t distribution parameter estimation} \description{ Fits the parameters of the standardized Student-t distribution. } \usage{ stdFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters parsed to the optimization function \code{nlm}. } } \value{ \code{stdFit} returns a list with the following components: \item{par}{ The best set of parameters found. } \item{objective}{ The value of objective corresponding to \code{par}. } \item{convergence}{ An integer code. 0 indicates successful convergence. } \item{message}{ A character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation. } \item{iterations}{ Number of iterations performed. } \item{evaluations}{ Number of objective function and gradient function evaluations. } } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{std}}, \code{\link{stdSlider}} } \examples{ set.seed(1953) r <- rstd(n = 1000) stdFit(r) } \keyword{distribution} fGarch/man/methods-formula.Rd0000644000176200001440000000643115104730075015622 0ustar liggesusers\name{formula-methods} \alias{formula-methods} \docType{methods} \alias{formula} \alias{formula,fGARCH-method} \title{Extract GARCH model formula} \description{ Extracts formula from a formula GARCH object. } \section{Methods}{ Methods for \code{formula} defined in package \pkg{fGarch}: \describe{ \item{object = "fGARCH"}{ Extractor function for formula expression. } } } \details{ \code{formula} is a generic function which extracts the formula expression from objects returned by modeling functions. The \code{"fGARCH"} method extracts the \code{@formula} expression slot from an object of class \code{"fGARCH"} as returned by the function \code{garchFit}. The returned formula has always a left hand side. If the argument \code{data} was an univariate time series and no name was specified to the series, then the left hand side is assigned the name of the data.set. In the multivariate case the rectangular \code{data} object must always have column names, otherwise the fitting will be stopped with an error message The class of the returned value depends on the input to the function \code{garchFit} who created the object. The returned value is always of the same class as the input object to the argument \code{data} in the function \code{garchFit}, i.e. if you fit a \code{"timeSeries"} object, you will get back from the function \code{fitted} also a \code{"timeSeries"} object, if you fit an object of class \code{"zoo"}, you will get back again a \code{"zoo"} object. The same holds for a \code{"numeric"} vector, for a \code{"data.frame"}, and for objects of class \code{"ts", "mts"}. In contrast, the slot itself returns independent of the class of the data input always a numeric vector, i.e. the function call r\code{slot(object, "fitted")} will return a numeric vector. } \note{ (GNB) Contrary to the description of the returned value of the \code{"fGARCH"} method, it is always \code{"numeric"}. TODO: either implement the documented behaviour or fix the documentation. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{garchFit}}, class \code{\linkS4class{fGARCH}} } \examples{ set.seed(2024) fit <- garchFit(~garch(1, 1), data = garchSim(), trace = FALSE) formula(fit) ## A Bivariate series and mis-specified formula: x <- garchSim(n = 500) y <- garchSim(n = 500) z <- cbind(x, y) colnames(z) class(z) \dontrun{ garchFit(z ~garch(1, 1), data = z, trace = FALSE) } # Returns: # Error in .garchArgsParser(formula = formula, data = data, trace = FALSE) : # Formula and data units do not match. ## Doubled column names in data set - formula can't fit: colnames(z) <- c("x", "x") z[1:6,] \dontrun{ garchFit(x ~garch(1, 1), data = z, trace = FALSE) } # Again the error will be noticed: # Error in garchFit(x ~ garch(1, 1), data = z) : # Column names of data are not unique. ## Missing column names in data set - formula can't fit: z.mat <- as.matrix(z) colnames(z.mat) <- NULL z.mat[1:6,] \dontrun{ garchFit(x ~ garch(1, 1), data = z.mat, trace = FALSE) } # Again the error will be noticed: # Error in .garchArgsParser(formula = formula, data = data, trace = FALSE) : # Formula and data units do not match } \keyword{models} fGarch/man/garchFitControl.Rd0000644000176200001440000001603115104730075015601 0ustar liggesusers\name{garchFitControl} \alias{garchFitControl} \title{Control GARCH fitting algorithms} \description{ Control parameters for the GARCH fitting algorithms. } \usage{ garchFitControl( llh = c("filter", "internal", "testing"), nlminb.eval.max = 2000, nlminb.iter.max = 1500, nlminb.abs.tol = 1.0e-20, nlminb.rel.tol = 1.0e-14, nlminb.x.tol = 1.0e-14, nlminb.step.min = 2.2e-14, nlminb.scale = 1, nlminb.fscale = FALSE, nlminb.xscale = FALSE, sqp.mit = 200, sqp.mfv = 500, sqp.met = 2, sqp.mec = 2, sqp.mer = 1, sqp.mes = 4, sqp.xmax = 1.0e3, sqp.tolx = 1.0e-16, sqp.tolc = 1.0e-6, sqp.tolg = 1.0e-6, sqp.told = 1.0e-6, sqp.tols = 1.0e-4, sqp.rpf = 1.0e-4, lbfgsb.REPORT = 10, lbfgsb.lmm = 20, lbfgsb.pgtol = 1e-14, lbfgsb.factr = 1, lbfgsb.fnscale = FALSE, lbfgsb.parscale = FALSE, nm.ndeps = 1e-14, nm.maxit = 10000, nm.abstol = 1e-14, nm.reltol = 1e-14, nm.alpha = 1.0, nm.beta = 0.5, nm.gamma = 2.0, nm.fnscale = FALSE, nm.parscale = FALSE) } \arguments{ % in general: \item{llh}{ \code{llh = c("filter", "internal", "testing")[1]}, defaults to \code{"filter"}. } % nlminb: \item{nlminb.eval.max}{ maximum number of evaluations of the objective function, defaults to 200. } \item{nlminb.iter.max}{ maximum number of iterations, defaults to 150. } %\item{nlminb.trace}{ % The value of the objective function and the parameters is % printed every trace'th iteration. Defaults to 0 which % indicates no trace information is to be printed. % } \item{nlminb.abs.tol}{ absolute tolerance, defaults to 1e-20. } \item{nlminb.rel.tol}{ relative tolerance, defaults to 1e-10. } \item{nlminb.x.tol}{ X tolerance, defaults to 1.5e-8. } \item{nlminb.fscale}{ defaults to FALSE. } \item{nlminb.xscale}{ defaulkts to FALSE. } \item{nlminb.step.min}{ minimum step size, defaults to 2.2e-14. } \item{nlminb.scale}{ defaults to 1. } % sqp: %\item{sqp.iprnt}{ % as.integer(trace). Default to 1. % } \item{sqp.mit}{ maximum number of iterations, defaults to 200. } \item{sqp.mfv}{ maximum number of function evaluations, defaults to 500. } \item{sqp.met}{ specifies scaling strategy:\cr sqp.met=1 - no scaling,\cr sqp.met=2 - preliminary scaling in 1st iteration (default),\cr sqp.met=3 - controlled scaling,\cr sqp.met=4 - interval scaling,\cr sqp.met=5 - permanent scaling in all iterations. } \item{sqp.mec}{ correction for negative curvature:\cr sqp.mec=1 - no correction,\cr sqp.mec=2 - Powell correction (default). } \item{sqp.mer}{ restarts after unsuccessful variable metric updates:\cr sqp.mer=0 - no restarts,\cr sqp.mer=1 - standard restart. } \item{sqp.mes}{ interpolation method selection in a line search:\cr sqp.mes=1 - bisection,\cr sqp.mes=2 - two point quadratic interpolation,\cr sqp.mes=3 - three point quadratic interpolation,\cr sqp.mes=4 - three point cubic interpolation (default). } \item{sqp.xmax}{ maximum stepsize, defaults to 1.0e+3. } \item{sqp.tolx}{ tolerance for the change of the coordinate vector, defaults to 1.0e-16. } \item{sqp.tolc}{ tolerance for the constraint violation, defaults to 1.0e-6. } \item{sqp.tolg}{ tolerance for the Lagrangian function gradient, defaults to 1.0e-6. } \item{sqp.told}{ defaults to 1.0e-6. } \item{sqp.tols}{ defaults to 1.0e-4. } \item{sqp.rpf}{ value of the penalty coefficient, default to1.0D-4. The default velue may be relatively small. Therefore, larger value, say one, can sometimes be more suitable. } % optim[lbfgsb]: \item{lbfgsb.REPORT}{ the frequency of reports for the \code{"BFGS"} and \code{"L-BFGS-B"} methods if \code{control$trace} is positive. Defaults to every 10 iterations. } \item{lbfgsb.lmm}{ an integer giving the number of BFGS updates retained in the \code{"L-BFGS-B"} method, It defaults to 5. } \item{lbfgsb.factr}{ controls the convergence of the \code{"L-BFGS-B"} method. Convergence occurs when the reduction in the objective is within this factor of the machine tolerance. Default is 1e7, that is a tolerance of about 1.0e-8. } \item{lbfgsb.pgtol}{ helps control the convergence of the \code{"L-BFGS-B"} method. It is a tolerance on the projected gradient in the current search direction. This defaults to zero, when the check is suppressed. } \item{lbfgsb.fnscale}{ defaults to FALSE. } \item{lbfgsb.parscale}{ defaults to FALSE. } % optim[nm]: %\item{nm.trace}{ % Non-negative integer. If positive, tracing information on the % progress of the optimization is produced. Higher values may % produce more tracing information: for method "L-BFGS-B" there % are six levels of tracing. (To understand exactly what these % do see the source code: higher levels give more detail.) % } \item{nm.ndeps}{ a vector of step sizes for the finite-difference approximation to the gradient, on par/parscale scale. Defaults to 1e-3. } \item{nm.maxit}{ the maximum number of iterations. Defaults to 100 for the derivative-based methods, and 500 for \code{"Nelder-Mead"}. For \code{"SANN"} maxit gives the total number of function evaluations. There is no other stopping criterion. Defaults to 10000. } \item{nm.abstol}{ the absolute convergence tolerance. Only useful for non-negative functions, as a tolerance for reaching zero. } \item{nm.reltol}{ relative convergence tolerance. The algorithm stops if it is unable to reduce the value by a factor of \code{reltol * (abs(val) + reltol)} at a step. Defaults to \code{sqrt(.Machine$double.eps)}, typically about 1e-8. } \item{nm.alpha, nm.beta, nm.gamma}{ scaling parameters for the "Nelder-Mead" method. alpha is the reflection factor (default 1.0), beta the contraction factor (0.5), and gamma the expansion factor (2.0). } \item{nm.fnscale}{ an overall scaling to be applied to the value of fn and gr during optimization. If negative, turns the problem into a maximization problem. Optimization is performed on \code{fn(par) / nm.fnscale}. } \item{nm.parscale}{ a vector of scaling values for the parameters. Optimization is performed on par/parscale and these should be comparable in the sense that a unit change in any element produces about a unit change in the scaled value. } } \value{ a list } \author{ Diethelm Wuertz for the Rmetrics \R-port,\cr R Core Team for the 'optim' \R-port,\cr Douglas Bates and Deepayan Sarkar for the 'nlminb' \R-port,\cr Bell-Labs for the underlying PORT Library,\cr Ladislav Luksan for the underlying Fortran SQP Routine, \cr Zhu, Byrd, Lu-Chen and Nocedal for the underlying L-BFGS-B Routine. } \seealso{ \code{\link{garchFit}} } \examples{ ## } \keyword{models} fGarch/man/dist-gedFit.Rd0000644000176200001440000000264515104730075014662 0ustar liggesusers\name{gedFit} \alias{gedFit} \title{Generalized error distribution parameter estimation} \description{ Function to fit the parameters of the generalized error distribution. } \usage{ gedFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters parsed to the optimization function \code{nlm}. } } \value{ \code{gedFit} returns a list with the following components: \item{par}{ The best set of parameters found. } \item{objective}{ The value of objective corresponding to \code{par}. } \item{convergence}{ An integer code, 0 indicates successful convergence. } \item{message}{ A character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation. } \item{iterations}{ Number of iterations performed. } \item{evaluations}{ Number of objective function and gradient function evaluations. } } \references{ Nelson D.B. (1991); \emph{Conditional Heteroscedasticity in Asset Returns: A New Approach}, Econometrica, 59, 347--370. Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{ged}}, \code{\link{sgedFit}} } \examples{ set.seed(1953) r <- rged(n = 1000) gedFit(r) } \keyword{distribution} fGarch/man/dist-absMoments.Rd0000644000176200001440000000344215104730075015564 0ustar liggesusers\name{absMoments} \alias{absMoments} \title{Absolute moments of GARCH distributions} \description{ Computes absolute moments of the standard normal, standardized GED, and standardized skew Student-t distributions. } \usage{ absMoments(n, density = c("dnorm", "dged", "dstd"), \dots) } \arguments{ \item{n}{ the order of the absolute moment, can be a vector to compute several absolute moments at once. } \item{density}{ a character string naming a symmetric density function. } \item{\dots}{ parameters passed to the density function. } } \details{ \code{absMoments} returns a numeric vector of length \code{n} with the values of the absolute moments, as specified by \code{n}, of the selected probability density function (pdf). If \code{density} names one of the densities in the signature of \code{absMoments}, the moments are calculated from known formulas. Otherwise, numerical integration is used and an attribute is attached to the results to report an estimate of the error. Note that the density is assumed symmetric wihtout a check. } \value{ a numeric vector } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{ged}}, \code{\link{std}} } \examples{ absMoments(1, "dstd", nu = 6) absMoments(1, "dstd", nu = 600) absMoments(1, "dstd", nu = 60000) absMoments(1, "dstd", nu = 600000) absMoments(1, "dnorm") ## excess kurtosis of t_nu is 6/(nu - 4) nu <- 6 absMoments(2*2, "dstd", nu = nu) / absMoments(2*1, "dstd", nu = nu)^2 - 3 6/(nu-4) ## 4th moment for t_4 is infinite absMoments(4, "dstd", nu = 4) absMoments(1, "dged", nu = 4) } \keyword{distribution} fGarch/man/class-fUGARCHSPEC.Rd0000644000176200001440000000227515104730075015413 0ustar liggesusers\name{fUGARCHSPEC-class} \alias{fUGARCHSPEC-class} \alias{.ugarchFit} \alias{.ugarchSpec} \docType{class} \title{Class 'fUGARCHSPEC'} \description{Class 'fUGARCHSPEC'.} \section{Objects from the Class}{ Objects can be created by calls of the form \code{new("fUGARCHSPEC", ...)}. } \section{Slots}{ \describe{ \item{\code{model}:}{Object of class \code{"list"} ~~ } \item{\code{distribution}:}{Object of class \code{"list"} ~~ } \item{\code{optimization}:}{Object of class \code{"list"} ~~ } \item{\code{documentation}:}{Object of class \code{"list"} ~~ } } } \section{Methods}{ No methods defined with class \code{"fUGARCHSPEC"} in the signature. } \note{ Was this class meant to replace \code{"fGARCHSPEC"}? (GNB) This class seems to be meant for internal use by the package. (GNB) Amendment: no, functions \code{.ugarchSpec} and \code{.ugarchFit} are exported. \code{.ugarchFit} fits the model from a spec, unlike \code{garchFit}. TODO: There is something unfinished here. Check and sort out. See also \code{\link{fUGARCHSPEC-class}} } \seealso{ class \code{"\linkS4class{fGARCH}"} } \examples{ showClass("fUGARCHSPEC") } \keyword{classes} fGarch/man/dist-sstdFit.Rd0000644000176200001440000000240115104730075015066 0ustar liggesusers\name{sstdFit} \alias{sstdFit} \title{Skew Student-t distribution parameter estimation} \description{ Fits the parameters of the skew Student-t distribution. } \usage{ sstdFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters passed to the optimization function \code{nlm}. } } \value{ a list with the following components: \item{par}{ the best set of parameters found; } \item{objective}{ the value of objective corresponding to \code{par}; } \item{convergence}{ an integer code. 0 indicates successful convergence; } \item{message}{ a character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation; } \item{iterations}{ number of iterations performed; } \item{evaluations}{ number of objective function and gradient function evaluations. } } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{sstd}}, \code{\link{stdFit}} } \examples{ set.seed(1953) r <- rsstd(n = 1000) sstdFit(r) } \keyword{distribution} fGarch/man/VaR.Rd0000644000176200001440000000445715104730075013212 0ustar liggesusers\name{VaR} \alias{VaR} \alias{VaR.fGARCH} \alias{ES} \alias{ES.fGARCH} \concept{VaR} \concept{value-at-risk} \concept{ES} \concept{expected shortfall} \title{Compute Value-at-Risk (VaR) and expected shortfall (ES)} \description{ Compute Value-at-Risk (VaR) and Expected Shortfall (ES) for a fitted GARCH-APARCH model. } \usage{ \method{VaR}{fGARCH}(dist, p_loss = 0.05, ..., tol) \method{ES}{fGARCH}(dist, p_loss = 0.05, ...) } \arguments{ \item{dist}{ an object from class \code{"fGARCH"}, obtained from \code{garchFit()}. } \item{p_loss}{level, default is 0.05.} \item{...}{not used.} \item{tol}{tollerance} } \details{ We provide methods for the generic functions \code{cvar::VaR} and \code{cvar::ES}. } \note{ We use the traditional definition of VaR as the negated lower quantile. For example, if \eqn{X} are returns on an asset, VAR\eqn{{}_\alpha}{_a} = \eqn{-q_\alpha}{-q_a}, where \eqn{q_\alpha}{-q_a} is the lower \eqn{\alpha}{a} quantile of \eqn{X}. Equivalently, VAR\eqn{{}_\alpha}{_a} is equal to the lower \eqn{1-\alpha}{1-a} quantile of \eqn{-X} (the loss series). For details see the vignette in package \pkg{cvar} availalble at \url{https://cran.r-project.org/package=cvar/vignettes/Guide_cvar.pdf} (or by calling \code{vignette("Guide_cvar", package = "cvar")}). If you wish to overlay the VaR or ES over returns, just negate the VaR/ES, see the examples. } \seealso{ \code{\link[cvar]{VaR}} and \code{\link[cvar]{ES}} in package \pkg{cvar} } \examples{ ## simulate a time series of returns x <- garchSim( garchSpec(), n = 500) class(x) ## fit a GARCH model fit <- garchFit(~ garch(1, 1), data = x, trace = FALSE) head(VaR(fit)) head(ES(fit)) ## use plot method for fitted GARCH models plot(fit, which = 14) # VaR plot(fit, which = 15) # ES plot(fit, which = 16) # VaR & ES ## plot(fit) # choose the plot interactively ## diy plots ## overlay VaR and ES over returns ## here x is from class 'timeSeries', so we convert VaR/ES to timeSeries ## don't forget to negate the result of VaR()/ES(), plot(x) lines(timeSeries(-VaR(fit)), col = "red") lines(timeSeries(-ES(fit)), col = "blue") ## alternatively, plot losses (rather than returns) and don't negate VaR()/ES() plot(-x) lines(timeSeries(VaR(fit)), col = "red") lines(timeSeries(ES(fit)), col = "blue") } fGarch/man/garchFit.Rd0000644000176200001440000003151715104730075014246 0ustar liggesusers\name{garchFit} \alias{garchFit} \alias{garchKappa} \alias{.gogarchFit} \concept{GARCH model} \concept{APARCH model} \concept{ARMA-GARCH model} \concept{ARMA-APARCH model} \concept{AR-GARCH model} \concept{AR-APARCH model} \concept{MA-GARCH model} \concept{MA-APARCH model} \concept{fit GARCH model} \concept{fit APARCH model} \concept{fit ARMA-GARCH model} \concept{fit ARMA-APARCH model} \concept{fit AR-GARCH model} \concept{fit AR-APARCH model} \concept{fit MA-GARCH model} \concept{fit MA-APARCH model} \title{Fit univariate and multivariate GARCH-type models} \description{ Estimates the parameters of a univariate ARMA-GARCH/APARCH process, or --- experimentally --- of a multivariate GO-GARCH process model. The latter uses an algorithm based on \code{fastICA()}, inspired from Bernhard Pfaff's package \CRANpkg{gogarch}. } \usage{ garchFit(formula = ~ garch(1, 1), data, init.rec = c("mci", "uev"), delta = 2, skew = 1, shape = 4, cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "snig", "QMLE"), include.mean = TRUE, include.delta = NULL, include.skew = NULL, include.shape = NULL, leverage = NULL, trace = TRUE, %recursion = c("internal", "filter", "testing"), algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), hessian = c("ropt", "rcd"), control = list(), title = NULL, description = NULL, \dots) garchKappa(cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd", "snig"), gamma = 0, delta = 2, skew = NA, shape = NA) .gogarchFit(formula = ~garch(1, 1), data, init.rec = c("mci", "uev"), delta = 2, skew = 1, shape = 4, cond.dist = c("norm", "snorm", "ged", "sged", "std", "sstd", "snig", "QMLE"), include.mean = TRUE, include.delta = NULL, include.skew = NULL, include.shape = NULL, leverage = NULL, trace = TRUE, algorithm = c("nlminb", "lbfgsb", "nlminb+nm", "lbfgsb+nm"), hessian = c("ropt", "rcd"), control = list(), title = NULL, description = NULL, \dots) } \arguments{ % \item{recursion}{ % a string parameter that determines the recursion used for calculating % the maximum log-likelihood function. % Allowed values are ... % } \item{formula}{ \code{\link{formula}} object describing the mean and variance equation of the ARMA-GARCH/APARCH model. A pure GARCH(1,1) model is selected e.g., for \code{formula = ~garch(1,1)}. To specify an ARMA(2,1)-APARCH(1,1) process, use \code{ ~ arma(2,1) + aparch(1,1)}. } \item{data}{ an optional \code{"timeSeries"} or \code{"data.frame"} object containing the variables in the model. If not found in \code{data}, the variables are taken from \code{environment(formula)}, typically the environment from which \code{armaFit} is called. If \code{data} is an univariate series, then the series is converted into a numeric vector and the name of the response in the formula will be neglected. } \item{init.rec}{ a character string indicating the method how to initialize the mean and varaince recursion relation. } \item{delta}{ a numeric value, the exponent \code{delta} of the variance recursion. By default, this value will be fixed, otherwise the exponent will be estimated together with the other model parameters if \code{include.delta=FALSE}. } \item{skew}{ a numeric value, the skewness parameter of the conditional distribution. } \item{shape}{ a numeric value, the shape parameter of the conditional distribution. } \item{cond.dist}{ a character string naming the desired conditional distribution. Valid values are \code{"dnorm"}, \code{"dged"}, \code{"dstd"}, \code{"dsnorm"}, \code{"dsged"}, \code{"dsstd"} and \code{"QMLE"}. The default value is the normal distribution. See Details for more information. } \item{include.mean}{ this flag determines if the parameter for the mean will be estimated or not. If \code{include.mean=TRUE} this will be the case, otherwise the parameter will be kept fixed durcing the process of parameter optimization. } \item{include.delta}{a \code{\link{logical}} determining if the parameter for the recursion equation \code{delta} will be estimated or not. If false, the shape parameter will be kept fixed during the process of parameter optimization. } \item{include.skew}{ a logical flag which determines if the parameter for the skewness of the conditional distribution will be estimated or not. If \code{include.skew=FALSE} then the skewness parameter will be kept fixed during the process of parameter optimization. } \item{include.shape}{ a logical flag which determines if the parameter for the shape of the conditional distribution will be estimated or not. If \code{include.shape=FALSE} then the shape parameter will be kept fixed during the process of parameter optimization. } \item{leverage}{ a logical flag for APARCH models. Should the model be leveraged? By default \code{leverage=TRUE}. } \item{trace}{ a logical flag. Should the optimization process of fitting the model parameters be printed? By default \code{trace=TRUE}. } \item{algorithm}{ a string parameter that determines the algorithm used for maximum likelihood estimation. % Allowed values are % \code{"nmfb"}, % \code{"sqp"}, % \code{"nlminb"}, and % \code{"bfgs"} where the third is the default % setting. \code{"mnfb"} is a fully Fortran implemented and extremely % fast version of the R-coded \code{"nlminb"} algorithm. } \item{hessian}{ a string denoting how the Hessian matrix should be evaluated, either \code{hessian ="rcd"}, or \code{"ropt"}. The default, \code{"rcd"} is a central difference approximation implemented in \R and \code{"ropt"} uses the internal R function \code{optimhess}. } \item{control}{ control parameters, the same as used for the functions from \code{nlminb}, and 'bfgs' and 'Nelder-Mead' from \code{optim}. } \item{gamma}{ APARCH leverage parameter entering into the formula for calculating the expectation value. } \item{title}{ a character string which allows for a project title. } \item{description}{optional character string with a brief description.} \item{\dots}{ additional arguments to be passed. } } \details{ \code{"QMLE"} stands for Quasi-Maximum Likelihood Estimation, which assumes normal distribution and uses robust standard errors for inference. Bollerslev and Wooldridge (1992) proved that if the mean and the volatility equations are correctly specified, the QML estimates are consistent and asymptotically normally distributed. However, the estimates are not efficient and \dQuote{the efficiency loss can be marked under asymmetric ... distributions} (Bollerslev and Wooldridge (1992), p. 166). The robust variance-covariance matrix of the estimates equals the (Eicker-White) sandwich estimator, i.e. \deqn{V = H^{-1} G^{\prime} G H^{-1},}{V = H^(-1) G' G H^(-1),} where \eqn{V}{V} denotes the variance-covariance matrix, \eqn{H}{H} stands for the Hessian and \eqn{G}{G} represents the matrix of contributions to the gradient, the elements of which are defined as \deqn{G_{t,i} = \frac{\partial l_{t}}{\partial \zeta_{i}},}{% G_{t,i} = derivative of l_{t} w.r.t. zeta_{i},} where \eqn{t_{t}}{l_{t}} is the log likelihood of the t-th observation and \eqn{\zeta_{i}}{zeta_{i}} is the i-th estimated parameter. See sections 10.3 and 10.4 in Davidson and MacKinnon (2004) for a more detailed description of the robust variance-covariance matrix. } \value{ for \code{garchFit}, an S4 object of class \code{"\linkS4class{fGARCH}"}. Slot \code{@fit} contains the results from the optimization. for \code{.gogarchFit()}: Similar definition for GO-GARCH modeling. Here, \code{data} must be \emph{multivariate}. Still \dQuote{preliminary}, mostly undocumented, and untested(!). At least mentioned here... } \references{ ATT (1984); \emph{PORT Library Documentation}, http://netlib.bell-labs.com/netlib/port/. Bera A.K., Higgins M.L. (1993); \emph{ARCH Models: Properties, Estimation and Testing}, J. Economic Surveys 7, 305--362. Bollerslev T. (1986); \emph{Generalized Autoregressive Conditional Heteroscedasticity}, Journal of Econometrics 31, 307--327. Bollerslev T., Wooldridge J.M. (1992); \emph{Quasi-Maximum Likelihood Estimation and Inference in Dynamic Models with Time-Varying Covariance}, Econometric Reviews 11, 143--172. Byrd R.H., Lu P., Nocedal J., Zhu C. (1995); \emph{A Limited Memory Algorithm for Bound Constrained Optimization}, SIAM Journal of Scientific Computing 16, 1190--1208. Davidson R., MacKinnon J.G. (2004); \emph{Econometric Theory and Methods}, Oxford University Press, New York. Engle R.F. (1982); \emph{Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation}, Econometrica 50, 987--1008. Nash J.C. (1990); \emph{Compact Numerical Methods for Computers}, Linear Algebra and Function Minimisation, Adam Hilger. Nelder J.A., Mead R. (1965); \emph{A Simplex Algorithm for Function Minimization}, Computer Journal 7, 308--313. Nocedal J., Wright S.J. (1999); \emph{Numerical Optimization}, Springer, New York. } \author{ Diethelm Wuertz for the Rmetrics \R-port,\cr R Core Team for the 'optim' \R-port,\cr Douglas Bates and Deepayan Sarkar for the 'nlminb' \R-port,\cr Bell-Labs for the underlying PORT Library,\cr Ladislav Luksan for the underlying Fortran SQP Routine, \cr Zhu, Byrd, Lu-Chen and Nocedal for the underlying L-BFGS-B Routine. Martin Maechler for cleaning up; \emph{mentioning} \code{.gogarchFit()}. } \seealso{ \code{\link{garchSpec}}, \code{\link{garchFitControl}}, class \code{"\linkS4class{fGARCH}"} } \examples{ ## UNIVARIATE TIME SERIES INPUT: # In the univariate case the lhs formula has not to be specified ... # A numeric Vector from default GARCH(1,1) - fix the seed: N <- 200 x.vec <- as.vector(garchSim(garchSpec(rseed = 1985), n = N)[,1]) garchFit(~ garch(1,1), data = x.vec, trace = FALSE) # An univariate timeSeries object with dummy dates: stopifnot(require("timeSeries")) x.timeSeries <- dummyDailySeries(matrix(x.vec), units = "GARCH11") garchFit(~ garch(1,1), data = x.timeSeries, trace = FALSE) \dontrun{ # An univariate zoo object: require("zoo") x.zoo <- zoo(as.vector(x.vec), order.by = as.Date(rownames(x.timeSeries))) garchFit(~ garch(1,1), data = x.zoo, trace = FALSE) } # An univariate "ts" object: x.ts <- as.ts(x.vec) garchFit(~ garch(1,1), data = x.ts, trace = FALSE) ## MULTIVARIATE TIME SERIES INPUT: ## # For multivariate data inputs the lhs formula must be specified ... # A numeric matrix binded with dummy random normal variates: X.mat <- cbind(GARCH11 = x.vec, R = rnorm(N)) garchFit(GARCH11 ~ garch(1,1), data = X.mat) # A multivariate timeSeries object with dummy dates: X.timeSeries <- dummyDailySeries(X.mat, units = c("GARCH11", "R")) garchFit(GARCH11 ~ garch(1,1), data = X.timeSeries) \dontrun{ # A multivariate zoo object: X.zoo <- zoo(X.mat, order.by = as.Date(rownames(x.timeSeries))) garchFit(GARCH11 ~ garch(1,1), data = X.zoo) } # A multivariate "mts" object: X.mts <- as.ts(X.mat) garchFit(GARCH11 ~ garch(1,1), data = X.mts) ## MODELING THE PERCENTUAL SPI/SBI SPREAD FROM LPP BENCHMARK: stopifnot(require("timeSeries")) X.timeSeries <- as.timeSeries(data(LPP2005REC)) X.mat <- as.matrix(X.timeSeries) \dontrun{X.zoo <- zoo(X.mat, order.by = as.Date(rownames(X.mat)))} X.mts <- ts(X.mat) garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.timeSeries) # The remaining are not yet supported ... # garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.mat) # garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.zoo) # garchFit(100*(SPI - SBI) ~ garch(1,1), data = X.mts) ## MODELING HIGH/LOW RETURN SPREADS FROM MSFT PRICE SERIES: X.timeSeries <- MSFT garchFit(Open ~ garch(1,1), data = returns(X.timeSeries)) garchFit(100*(High-Low) ~ garch(1,1), data = returns(X.timeSeries)) ## GO-GARCH Modelling (not yet!!) % FIXME ## data(DowJones30, package="fEcofin") # no longer exists ## X <- returns(as.timeSeries(DowJones30)); head(X) ## N <- 5; ans <- .gogarchFit(data = X[, 1:N], trace = FALSE); ans ## ans@h.t } \keyword{models} fGarch/man/dist-Slider.Rd0000755000176200001440000000423415104730075014701 0ustar liggesusers\name{dist-Slider} \alias{snormSlider} \alias{stdSlider} \alias{sstdSlider} \alias{gedSlider} \alias{sgedSlider} \concept{standardized GED distribution} \concept{GED distribution} \concept{standardized skew GED distribution} \concept{skew GED distribution} \concept{skewed GED distribution} \concept{skew distribution} \concept{skewed distribution} \concept{skewed normal distribution} \concept{skew distribution} \concept{skewed distribution} \concept{t-distribution} \concept{Student-t distribution} \concept{standardized Student t distribution} \concept{standardized Student-t distribution} \concept{standardized skew Student-t distribution} \concept{skew Student-t distribution} \concept{skewed Student-t distribution} \title{ Visualise skew normal, (skew) Student-t and (skew) GED distributions } \description{ Displays interactively the dependence of distributions on their parameters. Package 'fGarch' provides sliders for the Student-t, GED, skew normal, skew Student-t and skew GED distributions, } \usage{ stdSlider(type = c("dist", "rand")) gedSlider(type = c("dist", "rand")) snormSlider(type = c("dist", "rand")) sstdSlider(type = c("dist", "rand")) sgedSlider(type = c("dist", "rand")) } \arguments{ \item{type}{ a character string denoting which interactive plot should be displayed. Either a distribution plot \code{type = "dist"}, the default value, or a random variates plot, \code{type = "rand"}. } } \value{ a Tcl object } \references{ Nelson D.B. (1991); \emph{Conditional Heteroscedasticity in Asset Returns: A New Approach}, Econometrica, 59, 347--370. Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{snorm}}, \code{\link{std}}, \code{\link{sstd}}, \code{\link{ged}}, \code{\link{sged}} } \examples{ \dontrun{ require(tcltk) snormSlider("dist") snormSlider("rand") stdSlider("dist") stdSlider("rand") sstdSlider("dist") sstdSlider("rand") gedSlider("dist") gedSlider("rand") sgedSlider("dist") sgedSlider("rand") } } \keyword{distribution} fGarch/man/methods-fitted.Rd0000644000176200001440000000153215104730075015431 0ustar liggesusers\name{fitted-methods} \alias{fitted-methods} \docType{methods} \alias{fitted} \alias{fitted,fGARCH-method} \title{Extract GARCH model fitted values} \description{ Extracts fitted values from a fitted GARCH object. } \section{Methods}{ Methods for \code{fitted} defined in package \pkg{fGarch}: \describe{ \item{object = "fGARCH"}{ Extractor function for fitted values. } } } \details{ The method for \code{"fGARCH"} objects extracts the \code{@fitted} value slot from an object of class \code{"fGARCH"} as returned by the function \code{garchFit}. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{predict}}, \code{\link{residuals}}, \code{\link{garchFit}}, class \code{\linkS4class{fGARCH}}, \code{\link{plot}} } \examples{ ## see examples for 'residuals()' } \keyword{models} fGarch/man/methods-summary.Rd0000644000176200001440000000703515104730075015653 0ustar liggesusers\name{summary-methods} \alias{summary-methods} \docType{methods} \alias{summary} %\alias{summary,ANY-method} \alias{summary,fGARCH-method} \title{fGARCH method for the summary function} \description{ Prints a summary of an object from class \code{"fGARCH"}. The summary contains information about the parameters of the fitted model, its specifications, and diagnostic statistics for inference and goodness-of-fit. If you don't need the diagnostics, just print the object (instead of calling \code{summary}). } \section{Methods}{ Methods for \code{summary} defined in package \pkg{fGarch}: \describe{ \item{object = "fGARCH"}{ Summary function for objects of class \code{"fGARCH"}. } } } \value{ an object from class \code{"summary_fGARCH"} } \section{How to read a diagnostic summary report?}{ The first five sections give the title, the call, the mean and variance formula, the conditional distribution and the type of standard errors: \preformatted{ Title: GARCH Modelling Call: garchFit(~ garch(1, 1), data = garchSim(), trace = FALSE) Mean and Variance Equation: ~arch(0) Conditional Distribution: norm Std. Errors: based on Hessian } The next three sections return the estimated coefficients and an error analysis including standard errors, t values, and probabilities, as well as the log Likelihood values from optimization: \preformatted{ Coefficient(s): mu omega alpha1 beta1 -5.79788e-05 7.93017e-06 1.59456e-01 2.30772e-01 Error Analysis: Estimate Std. Error t value Pr(>|t|) mu -5.798e-05 2.582e-04 -0.225 0.822 omega 7.930e-06 5.309e-06 1.494 0.135 alpha1 1.595e-01 1.026e-01 1.554 0.120 beta1 2.308e-01 4.203e-01 0.549 0.583 Log Likelihood: -843.3991 normalized: -Inf } The next section provides results on standardized residuals tests, including statistic and p values, and on information criterion statistic including AIC, BIC, SIC, and HQIC: \preformatted{ Standardized Residuals Tests: Statistic p-Value Jarque-Bera Test R Chi^2 0.4172129 0.8117146 Shapiro-Wilk Test R W 0.9957817 0.8566985 Ljung-Box Test R Q(10) 13.05581 0.2205680 Ljung-Box Test R Q(15) 14.40879 0.4947788 Ljung-Box Test R Q(20) 38.15456 0.008478302 Ljung-Box Test R^2 Q(10) 7.619134 0.6659837 Ljung-Box Test R^2 Q(15) 13.89721 0.5333388 Ljung-Box Test R^2 Q(20) 15.61716 0.7400728 LM Arch Test R TR^2 7.049963 0.8542942 Information Criterion Statistics: AIC BIC SIC HQIC 8.473991 8.539957 8.473212 8.500687 } } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{tsdiag}} and \code{\link{plot}} for further diagnostics and plots, \code{\link{garchFit}} for fitting GARCH/APARCH models, class \code{"\linkS4class{fGARCH}"} for details and further methods } \examples{ \dontshow{ set.seed(1234) } x <- garchSim(n = 200) fit <- garchFit(formula = x ~ garch(1, 1), data = x, trace = FALSE) summary(fit) } fGarch/man/class-fGARCHSPEC.Rd0000644000176200001440000000330315104730075015257 0ustar liggesusers\name{fGARCHSPEC-class} \alias{fGARCHSPEC-class} \docType{class} \alias{show,fGARCHSPEC-method} \alias{update,fGARCHSPEC-method} \concept{GARCH model} \concept{APARCH model} \concept{ARMA-GARCH model} \concept{ARMA-APARCH model} \title{Class "fGARCHSPEC"} \description{ Specification structure for an univariate GARCH time series model. } \section{Objects from the Class}{ Objects can be created by calls of the function \code{garchSpec}. This object specifies the parameters of an empirical GARCH process. } \section{Slots}{ \describe{ \item{\code{call}:}{Object of class \code{"call"}: the call of the \code{garch} function. } \item{\code{formula}:}{Object of class \code{"formula"}: a list with two formula entries for the mean and variance equation. } \item{\code{model}:}{Object of class \code{"list"}: a list with the model parameters. } \item{\code{presample}:}{Object of class \code{"matrix"}: a numeric matrix with presample values. } \item{\code{distribution}:}{Object of class \code{"character"}: a character string with the name of the conditional distribution. } \item{\code{rseed}:}{Object of class \code{"numeric"}: an integer with the random number generator seed. } } } \section{Methods}{ \describe{ \item{show}{\code{signature(object = "fGARCHSPEC")}: prints an object of class 'fGARCHSPEC'. } } } \note{ With Rmetrics Version 2.6.1 the class has been renamed from \code{"garchSpec"} to \code{"fGARCHSPEC"}. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \examples{ spec = garchSpec() spec } \keyword{programming} fGarch/man/dist-ged.Rd0000644000176200001440000000534615104730075014220 0ustar liggesusers\name{ged} \alias{ged} \alias{dged} \alias{pged} \alias{qged} \alias{rged} \concept{standardized GED distribution} \concept{GED distribution} \title{Standardized generalized error distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the standardized generalized error distribution. } \usage{ dged(x, mean = 0, sd = 1, nu = 2, log = FALSE) pged(q, mean = 0, sd = 1, nu = 2) qged(p, mean = 0, sd = 1, nu = 2) rged(n, mean = 0, sd = 1, nu = 2) } \arguments{ \item{x, q}{ a numeric vector of quantiles. } \item{p}{ a numeric vector of probabilities. } \item{n}{ number of observations to simulate. } \item{mean}{ location parameter. } \item{sd}{ scale parameter. } \item{nu}{ shape parameter. } \item{log}{ logical; if \code{TRUE}, densities are given as log densities. } } \details{ The standardized GED is defined so that for a given \code{sd} it has the same variance, \code{sd^2}, for all values of the shape parameter, see the reference by Wuertz et al below. \code{dged} computes the density, \code{pged} the distribution function, \code{qged} the quantile function, and \code{rged} generates random deviates from the standardized-t distribution with the specified parameters. } \value{ numeric vector } \references{ Nelson D.B. (1991); \emph{Conditional Heteroscedasticity in Asset Returns: A New Approach}, Econometrica, 59, 347--370. Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. Wuertz D., Chalabi Y. and Luksan L. (????); \emph{Parameter estimation of ARMA models with GARCH/APARCH errors: An R and SPlus software implementation}, Preprint, 41 pages, \url{https://github.com/GeoBosh/fGarchDoc/blob/master/WurtzEtAlGarch.pdf} } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{gedFit}}, \code{\link{absMoments}}, \code{\link{sged}} (skew GED), \code{\link{gedSlider}} for visualization } \examples{ ## sged - par(mfrow = c(2, 2)) set.seed(1953) r = rsged(n = 1000) plot(r, type = "l", main = "sged", col = "steelblue") # Plot empirical density and compare with true density: hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue") box() x = seq(min(r), max(r), length = 201) lines(x, dsged(x), lwd = 2) # Plot df and compare with true df: plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue", ylab = "Probability") lines(x, psged(x), lwd = 2) # Compute quantiles: round(qsged(psged(q = seq(-1, 5, by = 1))), digits = 6) } \keyword{distribution} fGarch/man/dist-sged.Rd0000644000176200001440000000632315104730075014377 0ustar liggesusers\name{sged} \alias{sged} \alias{dsged} \alias{psged} \alias{qsged} \alias{rsged} \concept{standardized skew GED distribution} \concept{skew GED distribution} \concept{skewed GED distribution} \concept{skew distribution} \concept{skewed distribution} \title{Skew generalized error distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the skew generalized error distribution. Note that there are different ways to define a skew GED distribution, check section Details to see if this is the distribution you want. } \usage{ dsged(x, mean = 0, sd = 1, nu = 2, xi = 1.5, log = FALSE) psged(q, mean = 0, sd = 1, nu = 2, xi = 1.5) qsged(p, mean = 0, sd = 1, nu = 2, xi = 1.5) rsged(n, mean = 0, sd = 1, nu = 2, xi = 1.5) } \arguments{ \item{x, q}{ a numeric vector of quantiles. } \item{p}{ a numeric vector of probabilities. } \item{n}{ number of observations to simulate. } \item{mean}{ location parameter. } \item{sd}{ scale parameter. } \item{nu}{ shape parameter. } \item{xi}{ skewness parameter, a positive number. \code{xi = 1} gives a symmetric distribution (here normal). } \item{log}{ logical; if \code{TRUE}, densities are given as log densities. } } \details{ Skewness is based on the scheme by Fernandez and Steel (2000) but with different parameterisation as discussed by Wuertz et al (????), in that the skewness (\code{xi}), degrees of freedom (\code{nu}), mean (\code{mean}) and standard deviation (\code{sd}) are independent parameters. \code{dsged} computes the density, \code{psged} the distribution function, \code{qsged} the quantile function, and \code{rsged} generates random deviates. } \value{ numeric vector } \references{ Nelson D.B. (1991); \emph{Conditional Heteroscedasticity in Asset Returns: A New Approach}, Econometrica, 59, 347--370. Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. Wuertz D., Chalabi Y. and Luksan L. (????); \emph{Parameter estimation of ARMA models with GARCH/APARCH errors: An R and SPlus software implementation}, Preprint, 41 pages, \url{https://github.com/GeoBosh/fGarchDoc/blob/master/WurtzEtAlGarch.pdf} } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{sgedFit}} (fit), \code{\link{sgedSlider}} (visualize), \code{\link{snorm}} (skew normal), \code{\link{sstd}} (skew t) \code{\link{ged}} (symmetric GED) } \examples{ ## sged - par(mfrow = c(2, 2)) set.seed(1953) r = rsged(n = 1000) plot(r, type = "l", main = "sged", col = "steelblue") # Plot empirical density and compare with true density: hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue") box() x = seq(min(r), max(r), length = 201) lines(x, dsged(x), lwd = 2) # Plot df and compare with true df: plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue", ylab = "Probability") lines(x, psged(x), lwd = 2) # Compute quantiles: round(qsged(psged(q = seq(-1, 5, by = 1))), digits = 6) } \keyword{distribution} fGarch/man/dist-snormFit.Rd0000644000176200001440000000255315104730075015257 0ustar liggesusers\name{snormFit} \alias{snormFit} \concept{skew distribution} \concept{skewed distribution} \title{Skew normal distribution parameter estimation} \description{ Fits the parameters of the skew normal distribution. } \usage{ snormFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters passed to the optimization function \code{nlm}. } } \value{ a list with the following components: \item{par}{ the best set of parameters found; } \item{objective}{ the value of objective corresponding to \code{par}; } \item{convergence}{ an integer code. 0 indicates successful convergence; } \item{message}{ a character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation; } \item{iterations}{ number of iterations performed; } \item{evaluations}{ number of objective function and gradient function evaluations. } } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{snormSlider}} (visualize), \code{\link{snorm}}, \code{\link{absMoments}} } \examples{ set.seed(1953) r <- rsnorm(n = 1000) snormFit(r) } \keyword{distribution} fGarch/man/methods-residuals.Rd0000644000176200001440000000240715104730075016147 0ustar liggesusers\name{residuals-methods} \alias{residuals-methods} \docType{methods} \alias{residuals} \alias{residuals,fGARCH-method} \title{Extract GARCH model residuals} \description{ Extracts residuals from a fitted GARCH object. } \usage{ \S4method{residuals}{fGARCH}(object, standardize = FALSE) } \arguments{ \item{object}{ an object of class \code{"fGARCH"} as returned by \code{\link{garchFit}}. } \item{standardize}{ a logical, indicating if the residuals should be standardized. } } \details{ The \code{"fGARCH"} method extracts the \code{@residuals} slot from an object of class \code{"fGARCH"} as returned by the function \code{garchFit} and optionally standardizes them, using conditional standard deviations. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{fitted}}, \code{\link{predict}}, \code{\link{garchFit}}, class \code{\linkS4class{fGARCH}}, } \examples{ stopifnot(require("timeSeries")) ## Swiss Pension fund Index data(LPP2005REC, package = "timeSeries") x <- as.timeSeries(LPP2005REC) ## Fit LPP40 Bechmark: fit <- garchFit(LPP40 ~ garch(1, 1), data = 100*x, trace = FALSE) fit fitted <- fitted(fit) head(fitted) class(fitted) res <- residuals(fit) head(res) class(res) } \keyword{models} fGarch/man/methods-plot.Rd0000644000176200001440000000576315104730075015142 0ustar liggesusers\name{plot-methods} \alias{plot-methods} \docType{methods} \alias{plot} \alias{plot,fGARCH,missing-method} \concept{GARCH diagnostics} \concept{GARCH goodness=of-fit} \concept{VaR} \concept{value-at-risk} \concept{ES} \concept{expected shortfall} \title{GARCH plot methods} \description{ Plot methods for GARCH modelling. } \usage{ \S4method{plot}{fGARCH,missing}(x, which = "ask", \dots) } \arguments{ \item{x}{ an object of class \code{"fGARCH"}. } \item{which}{ a character string or a vector of positive integers specifying which plot(s) should be displayed, see section \sQuote{Details}. } \item{\dots}{ optional arguments to be passed. } } \details{ The \code{plot} method for \code{"fGARCH"} objects offers a selection of diagnostic, exploratory, and presentation plots from a menu. Argument \code{which} can be used to request specific plots. This is particularly useful in scripts. If \code{which} is of length larger than one, all requested plots are produced. For this to be useful, the graphics window should be split beforehand in subwindows, e.g., using \code{par(mfrow = ...)}, \code{par(mfcol = ...)}, or \code{layout()} (see section \sQuote{Examples}). If this is not done, then only the last plot will be visible. The following graphs are available: \tabular{rl}{ 1 \tab Time SeriesPlot\cr 2 \tab Conditional Standard Deviation Plot\cr 3 \tab Series Plot with 2 Conditional SD Superimposed\cr 4 \tab Autocorrelation function Plot of Observations\cr 5 \tab Autocorrelation function Plot of Squared Observations\cr 6 \tab Cross Correlation Plot\cr 7 \tab Residuals Plot\cr 8 \tab Conditional Standard Deviations Plot\cr 9 \tab Standardized Residuals Plot\cr 10 \tab ACF Plot of Standardized Residuals\cr 11 \tab ACF Plot of Squared Standardized Residuals\cr 12 \tab Cross Correlation Plot between $r^2$ and r\cr 13 \tab Quantile-Quantile Plot of Standardized Residuals\cr 14 \tab Series with -VaR Superimposed\cr 15 \tab Series with -ES Superimposed\cr 16 \tab Series with -VaR & -ES Superimposed } } \author{ Diethelm Wuertz for the Rmetrics \R-port; VaR and ES graphs were added by Georgi N. Boshnakov in v4033.92 } \seealso{ \code{\link[=tsdiag.fGARCH]{fGARCH}} method for \code{tsdiag}, \code{\link{garchFit}}, class \code{\linkS4class{fGARCH}}, \code{\link{predict}}, \code{\link{fitted}}, \code{\link{residuals}} \code{\link{VaR}} \code{\link{ES}} \code{\link{plot}} } \examples{ ## simulate a Garch(1,1) time series x <- garchSim(n = 200) head(x) ## fit GARCH(1,1) model fit <- garchFit(formula = ~ garch(1, 1), data = x, trace = FALSE) \dontrun{ ## choose plots interactively plot(fit) } ## Batch Plot: plot(fit, which = 3) ## a 2 by 2 matrix of plots op <- par(mfrow = c(2,2)) # prepare 2x2 window plot(fit, which = c(10, 11, 3, 16)) # plot par(op) # restore the previous layout } \keyword{models} fGarch/man/methods-predict.Rd0000644000176200001440000001111615104730075015603 0ustar liggesusers\name{predict-methods} \alias{predict-methods} \docType{methods} \alias{predict} \alias{predict,fGARCH-method} \concept{VaR} \concept{value-at-risk} \concept{ES} \concept{expected shortfall} \title{GARCH prediction function} \description{ Predicts a time series from a fitted GARCH object. } \usage{ \S4method{predict}{fGARCH}(object, n.ahead = 10, trace = FALSE, mse = c("cond","uncond"), plot=FALSE, nx=NULL, crit_val=NULL, conf=NULL, \dots, p_loss = NULL) } \arguments{ \item{n.ahead}{ an integer value, denoting the number of steps to be forecasted, by default 10.} \item{object}{ an object of class \code{"fGARCH"} as returned by the function \code{garchFit}.} \item{trace}{ a logical flag. Should the prediction process be traced? By default \code{trace=FALSE}.} \item{mse}{ If set to \code{"cond"}, \code{meanError} is defined as the conditional mean errors \eqn{\sqrt{E_t[x_{t+h}-E_t(x_{t+h})]^2}}. If set to \code{"uncond"}, it is defined as \eqn{\sqrt{E[x_{t+h}-E_t(x_{t+h})]^2}}.} \item{plot}{If set to \code{TRUE}, the confidence intervals are computed and plotted} \item{nx}{The number of observations to be plotted along with the predictions. The default is \code{round(n*0.25)}, where n is the sample size.} \item{crit_val}{The critical values for the confidence intervals when \code{plot} is set to \code{TRUE}. The intervals are defined as \eqn{\hat{x}_{t+h}} + \code{crit_val[2] * meanError} and \eqn{\hat{x}_{t+h}} + \code{crit_val[1] * meanError} if two critical values are provided and \eqn{\hat{x}_{t+h} \pm} \code{crit_val * meanError} if only one is given. If you do not provide critical values, they will be computed automatically. } \item{conf}{The confidence level for the confidence intervals if \code{crit_val} is not provided. By default it is set to 0.95. The critical values are then computed using the conditional distribution that was chosen to create the \code{object} with \code{garchFit} using the same \code{shape} and \code{skew} parameters. If the conditionnal distribution was set to \code{"QMLE"}, the critical values are computed using the empirical distribution of the standardized residuals. } \item{\dots}{ additional arguments to be passed. } \item{p_loss}{ if not null, compute predictions for VaR and ES for loss level \code{p_loss} (typically, 0.05 or 0.01). } } \details{ The predictions are returned as a data frame with columns \code{"meanForecast"}, \code{"meanError"}, and \code{"standardDeviation"}. Row \code{h} contains the predictions for horizon \code{h} (so, \code{n.ahead} rows in total). If \code{plot = TRUE}, the data frame contain also the prediction limits for each horizon in columns \code{lowerInterval} and \code{upperInterval}. If \code{p_loss} is not NULL, predictions of Value-at-Risk (VaR) and Expected Shortfall (ES) are returned in columns \code{VaR} and \code{ES}. The data frame has attribute \code{"p_loss"} containing \code{p_loss}. Typical values for \code{p_loss} are 0.01 and 0.05. These are somewhat experimental and the arguments and the returned values may change. } \value{ a data frame containing \code{n.ahead} rows and 3 to 7 columns, see section \sQuote{Details} } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link[stats]{predict}} in base R \code{\link{fitted}}, \code{\link{residuals}}, \code{\link{plot}}, \code{\link{garchFit}}, class \code{\linkS4class{fGARCH}}, } \examples{ ## Parameter Estimation of Default GARCH(1,1) Model set.seed(123) fit = garchFit(~ garch(1, 1), data = garchSim(), trace = FALSE) fit ## predict predict(fit, n.ahead = 10) predict(fit, n.ahead = 10, mse="uncond") ## predict with plotting: critical values = +/- 2 predict(fit, n.ahead = 10, plot=TRUE, crit_val = 2) ## include also VaR and ES at 5\% predict(fit, n.ahead = 10, plot=TRUE, crit_val = 2, p_loss = 0.05) ## predict with plotting: automatic critical values ## for different conditional distributions set.seed(321) fit2 = garchFit(~ garch(1, 1), data = garchSim(), trace=FALSE, cond.dist="sged") ## 95\% confidence level predict(fit2, n.ahead=20, plot=TRUE) set.seed(444) fit3 = garchFit(~ garch(1, 1), data = garchSim(), trace=FALSE, cond.dist="QMLE") ## 90\% confidence level and nx=100 predict(fit3, n.ahead=20, plot=TRUE, conf=.9, nx=100) } \keyword{models} \keyword{ts} fGarch/man/dist-snorm.Rd0000644000176200001440000000624215104730075014613 0ustar liggesusers\name{snorm} \alias{snorm} \alias{dsnorm} \alias{psnorm} \alias{qsnorm} \alias{rsnorm} \concept{skewed normal distribution} \concept{skew distribution} \concept{skewed distribution} \title{Skew normal distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the skew normal distribution. Note that there are different ways to define a skew normal distribution, check section Details to see if this is the distribution you want. } \usage{ dsnorm(x, mean = 0, sd = 1, xi = 1.5, log = FALSE) psnorm(q, mean = 0, sd = 1, xi = 1.5) qsnorm(p, mean = 0, sd = 1, xi = 1.5) rsnorm(n, mean = 0, sd = 1, xi = 1.5) } \arguments{ \item{x, q}{a numeric vector of quantiles.} \item{p}{a numeric vector of probabilities.} \item{n}{the number of observations.} \item{mean}{location parameter.} \item{sd}{scale parameter.} \item{xi}{ skewness parameter, a positive number. \code{xi = 1} gives a symmetric distribution (here normal). } \item{log}{a logical; if TRUE, densities are given as log densities.} } \details{ Skewness is based on the scheme by Fernandez and Steel (2000) but with different parameterisation as discussed by Wuertz et al (????), in that the skewness (\code{xi}), mean (\code{mean}) and standard deviation (\code{sd}) are independent parameters. Please note that there are different ways to define a 'skew normal distribution'. In particular, the distribution discussed here is different from what is usually referred to as 'skew normal distribution' (see, for example, Azzalini 1985). \code{dsnorm} computes the density, \code{psnorm} the distribution function, \code{qsnorm} the quantile function, and \code{rsnorm} generates random deviates. } \value{ numeric vector } \references{ Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. Wuertz D., Chalabi Y. and Luksan L. (????); \emph{Parameter estimation of ARMA models with GARCH/APARCH errors: An R and SPlus software implementation}, Preprint, 41 pages, \url{https://github.com/GeoBosh/fGarchDoc/blob/master/WurtzEtAlGarch.pdf} A. Azzalini (1985). A class of distributions which includes the normal ones. Scand. J. Statist. 12, 171-178 } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{snormFit}} (fit), \code{\link{snormSlider}} (visualize), \code{\link{sstd}} (skew Student-t), \code{\link{sged}} (skew GED) } \examples{ ## snorm - # Ranbdom Numbers: par(mfrow = c(2, 2)) set.seed(1953) r = rsnorm(n = 1000) plot(r, type = "l", main = "snorm", col = "steelblue") # Plot empirical density and compare with true density: hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue") box() x = seq(min(r), max(r), length = 201) lines(x, dsnorm(x), lwd = 2) # Plot df and compare with true df: plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue", ylab = "Probability") lines(x, psnorm(x), lwd = 2) # Compute quantiles: round(qsnorm(psnorm(q = seq(-1, 5, by = 1))), digits = 6) } \keyword{distribution} fGarch/man/fGarchData.Rd0000644000176200001440000000203115104730075014470 0ustar liggesusers\name{fGarchData} \alias{fGarchData} \alias{dem2gbp} \alias{sp500dge} \concept{exchange rates data} \concept{SP500 data} \title{Time series datasets} \description{ Datasets used in the examples, including DEM/GBP foreign exchange rates and data on SP500 index. } \format{ \code{dem2gbp} is a data frame with one column \code{"DEM2GBP"} and 1974 rows (observations). \code{sp500dge} is a data frame with one column \code{"SP500DGE"} and 17055 rows (observations). } \details{ The data represent retuns. No further details have been recorded. Further datasets are available in the packages that \pkg{fGarch} imports, see \code{\link[fBasics]{fBasicsData}} and \code{\link[timeSeries]{TimeSeriesData}}. } \seealso{ \code{data(package = "fBasics")} and \code{data(package = "timeSeries")} for related datasets } \examples{ data(dem2gbp) head(dem2gbp) tail(dem2gbp) str(dem2gbp) plot(dem2gbp[[1]]) data(sp500dge) head(sp500dge) tail(sp500dge) str(sp500dge) plot(sp500dge[[1]]) } \keyword{datasets} \keyword{ts} fGarch/man/dist-sgedFit.Rd0000644000176200001440000000265215104730075015043 0ustar liggesusers\name{sgedFit} \alias{sgedFit} \title{Skew generalized error distribution parameter estimation} \description{ Function to fit the parameters of the skew generalized error distribution. } \usage{ sgedFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters passed to the optimization function \code{nlm}. } } \value{ a list with the following components: \item{par}{ the best set of parameters found; } \item{objective}{ the value of objective corresponding to \code{par}; } \item{convergence}{ an integer code. 0 indicates successful convergence; } \item{message}{ a character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation; } \item{iterations}{ number of iterations performed; } \item{evaluations}{ number of objective function and gradient function evaluations. } } \references{ Nelson D.B. (1991); \emph{Conditional Heteroscedasticity in Asset Returns: A New Approach}, Econometrica, 59, 347--370. Fernandez C., Steel M.F.J. (2000); \emph{On Bayesian Modelling of Fat Tails and Skewness}, Preprint, 31 pages. } \author{ Diethelm Wuertz for the Rmetrics \R-port } \seealso{ \code{\link{sged}}, \code{\link{sgedSlider}} } \examples{ set.seed(1953) r <- rsged(n = 1000) sgedFit(r) } \keyword{distribution} fGarch/DESCRIPTION0000644000176200001440000000340615116757102013162 0ustar liggesusersPackage: fGarch Title: Rmetrics - Autoregressive Conditional Heteroskedastic Modelling Version: 4052.93 Authors@R: c(person("Diethelm", "Wuertz", role="aut", comment = "original code") , person("Yohan", "Chalabi", role = "aut") , person("Tobias", "Setz", role = c("aut"), email = "tobias.setz@live.com") , person("Martin","Maechler", role="aut", email="maechler@stat.math.ethz.ch", comment = c(ORCID = "0000-0002-8685-9910")) , person("Chris", "Boudt", role = "ctb") , person("Pierre", "Chausse", role = "ctb") , person("Michal", "Miklovac", role = "ctb") , person(given = c("Georgi", "N."), family = "Boshnakov", role = c("aut", "cre"), email = "georgi.boshnakov@manchester.ac.uk", comment = c(ORCID = "0000-0003-2839-346X")) ) Description: Analyze and model heteroskedastic behavior in financial time series. Imports: fBasics, timeDate, timeSeries, fastICA, Matrix (>= 1.5-0), cvar (>= 0.5), graphics, methods, stats, utils Suggests: RUnit, tcltk, goftest LazyData: yes License: GPL (>= 2) URL: https://geobosh.github.io/fGarchDoc/ (doc), https://CRAN.R-project.org/package=fGarch, https://www.rmetrics.org BugReports: https://r-forge.r-project.org/tracker/?func=browse&group_id=156&atid=633 NeedsCompilation: yes Packaged: 2025-12-12 08:32:03 UTC; georgi Author: Diethelm Wuertz [aut] (original code), Yohan Chalabi [aut], Tobias Setz [aut], Martin Maechler [aut] (ORCID: ), Chris Boudt [ctb], Pierre Chausse [ctb], Michal Miklovac [ctb], Georgi N. Boshnakov [aut, cre] (ORCID: ) Maintainer: Georgi N. Boshnakov Repository: CRAN Date/Publication: 2025-12-12 09:20:02 UTC