fGarch/0000755000176000001440000000000012140125641011470 5ustar ripleyusersfGarch/MD50000644000176000001440000001415312140125641012004 0ustar ripleyusers8ddf42e368503fb9cb47500e2e44adab *ChangeLog b052643c399038f6e1573ac313d98c81 *DESCRIPTION 30c60066607724b18822e7132213ce1b *NAMESPACE 2eff91a11854273e4625d5b8672d94b6 *R/class-fGARCH.R 8b319ac72e222f5b714fd561511a1965 *R/class-fGARCHSPEC.R 04a5f0bf7ac0d162ab93f47530ccf9a9 *R/dist-absMoments.R 7b40285ba3f868b015ff905335f6d1df *R/dist-ged.R ccb808524bee2242b04a87cadbce8e29 *R/dist-gedFit.R d35be82ca2b203f6e3ecb0678d6f2fb1 *R/dist-gedSlider.R 2f4262b26b69462ad68826bbc6ad1926 *R/dist-sged.R 95584c9a0e38c2c1965139f202aecdc6 *R/dist-sgedFit.R f4b5d342a48c57b36f4a98a08f637e56 *R/dist-sgedSlider.R 86a3ec0c1a8be8e7c8835d380697056a *R/dist-snorm.R 10382aeb852b464f0c6518e461de773f *R/dist-snormFit.R 0c71233088546c742adfa6de041994d1 *R/dist-snormSlider.R f3119ef47af21a0a1ebb625e97fd55c1 *R/dist-sstd.R 81f06f626774aa9a7e09bd6038dfebb5 *R/dist-sstdFit.R 07abb511440e5cb6d44ffcc1e450443f *R/dist-sstdSlider.R 97fbe5d8149c1a0ff7cca075826c4c5f *R/dist-std.R add658ea5bb8e70363b1afd776ecae49 *R/dist-stdFit.R d06897dd68e8f25e9678913e4bd4fa90 *R/dist-stdSlider.R 126411d38ce8f2ed3996f724859d08e6 *R/fGarch-package.R 9741bff5bd063d83445d8457cbfb9f28 *R/fGarchEnv.R 049762f686f27bcb47b7838830e277d1 *R/garch-Distribution.R 84dd692b6fceb4c81564d582961b5420 *R/garch-FitFromFormula.R b95de1c14a197e1ca0154300fe2ced7a *R/garch-FitFromSpec.R 7229c9a6a796cef089e5bf489ac43570 *R/garch-FitInternal.R fff4d1f43e02a27c8dbb7f3a878158a7 *R/garch-GlobalVars.R 09d5ccc434690f061e870b4f22d8d3ad *R/garch-Gradient.R b52a3c76e5954d29e5516e196c0c0d85 *R/garch-Hessian.R e1b1fa3c676e0da11af6333cdaba9361 *R/garch-Initialization.R e4cf2b0d3866184a53444e5a2dfd613d *R/garch-Sim.R e3e825a5d6575d25fe1cd253ea79a530 *R/garch-Solver.R cf13fdd0a7f3afdea658cfff54087257 *R/garch-SolverControl.R 7d4060c159a161bce6d7e7e026873a22 *R/garch-Spec.R 7fb1ec19226587e1f1904f7b9455d496 *R/garch-Stats.R a0af43ada8cf98ae21ff931574f48317 *R/loglik-aparch.R 85dbb41d543618dd30d9b0514794a3b0 *R/loglik-egarch.R b70ab1c76855204cac6a878bc7c561f2 *R/loglik.R 635a7e01a9f65b2785512ad3ff9ccd30 *R/methods-coef.R fa405e2d76878d6e01e434d0cea425c3 *R/methods-fitted.R 16689bae0dbc0202d7b50dcefcdfbece *R/methods-formula.R 217995820b9c6780add922fb58b2af6a *R/methods-plot.R 3051bb12027a0f26eeda1fc3f707acfd *R/methods-predict.R a21b7e3829e99b2d0e3f5828c4a67254 *R/methods-residuals.R f46e2370d14171a1840333063b7a5abb *R/methods-show.R 4c436f7f23d453ac09fb88c42ba8b007 *R/methods-summary.R ad86287a53598ed54b90cd88a0d9ecc5 *R/methods-update.R d5635a8199157a93e80de65af8d745d9 *R/methods-volatility.R f9838bc1de85f6196779ebf05dc898bc *R/mgarch-FitFromFormula.R fa3322933d76cfb3b2255a425a111b9d *R/zzz.R fe75772d65e05a3b189023e372d3d1a2 *data/dem2gbp.csv.gz 58bbdc46c698bc7b97657229e8de1277 *data/sp500dge.csv.gz 6042b9c5e5bec3ecc1b6959cd2858b64 *inst/COPYRIGHT.html 70a0d93bc75a19be75bdab2f50fc48a0 *inst/THANKS 665e719c6c9360340268b2e6ac891515 *inst/unitTests/Makefile 6daf0e9de9a62ce7c24edd2e9cd2f7e1 *inst/unitTests/runTests.R 77ca4128e3983914e025103aa5036d80 *inst/unitTests/runit.formula-methods.R 34ce038d4e5a9b92efb5c01751078296 *inst/unitTests/runit.garch-methods.R 399380b12580d5aa2ca902919a4b9537 *inst/unitTests/runit.garchFit.R 1bbc596063ca7584964b89c23608cb83 *inst/unitTests/runit.garchFit.algorithm.R 6fd3d951a8fdebf579836babd064f714 *inst/unitTests/runit.garchFit.aparch.R e2e025242284f7379f314d39fe81e7ef *inst/unitTests/runit.garchFit.dist.R 285aaeac4df0f40f1e4a600af1924afa *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 027c502c4b2fd05f0d7a34a5f28a350a *inst/unitTests/runit.sged.R d03a2e8ca1f24c8d04dcb441d46c2694 *inst/unitTests/runit.snorm.R a5e6fc9d1dd9aff86220e2f674eda459 *inst/unitTests/runit.sstd.R 085cb26fb72eddee0a61e75226eb4234 *man/00fGarch-package.Rd f1df87fa10c973d2654cd6f8a1728dc1 *man/class-fGARCH.Rd 125ed9a7cad0ba5c5fb6b0b3aa143c5d *man/class-fGARCHSPEC.Rd 8319b3d1b871d1b876eddc5ca2ec7615 *man/data.Rd 76064039fae0c174a1962058d8a4ad78 *man/dist-absMoments.Rd 6b3c330084118c675f7277d6581379d0 *man/dist-ged.Rd 11745da022f78f994ea2c98b5efc979a *man/dist-gedFit.Rd 9911d25ccfa47537f45a74aed5190666 *man/dist-gedSlider.Rd 921778e7aad98dac8a953ba8593f54fd *man/dist-sged.Rd eeb045af4fee08cb77d8f0551c43988c *man/dist-sgedFit.Rd a4bf00ceef8cedb28b9011ed38f7d80b *man/dist-sgedSlider.Rd 34812552c00ce51d33306f19d18a1533 *man/dist-snorm.Rd f5c0350a45800aa2e1e5867dabcd6277 *man/dist-snormFit.Rd 4f46b025d2b8da80b04cad646afac529 *man/dist-snormSlider.Rd d99215fa2ffc6821d630462a3cccbca0 *man/dist-sstd.Rd d1ed90d33be97640a9afc984256bb0bf *man/dist-sstdFit.Rd 61984e15bd5340fb3b519064ef0ad0d6 *man/dist-sstdSlider.Rd 185f16a210c121a46c3f8ab31e5274e0 *man/dist-std.Rd 6388f5b29675e60cf7f2071d88ddd142 *man/dist-stdFit.Rd 0127c8854cbe9dbea33978c02f06d689 *man/dist-stdSlider.Rd f8d73cea1d5b19b4ff998658c89ac755 *man/garchFit.Rd 8b341b0c56c5903531b3492115ce2647 *man/garchFitControl.Rd 9a8625ab45743b198f0cadfb51f54f38 *man/garchSim.Rd 0565d8a39f2cc19856ab7a7d158fb18b *man/garchSpec.Rd 4a3d3fdf0f2b9828639bbf8fda86240b *man/methods-coef.Rd 437a5143241abaceff1a9bc446e54e5e *man/methods-fitted.Rd 7184cdd72049c0bd39bfd7ed621a1276 *man/methods-formula.Rd 1bff636eac58d145cb4a73109198df68 *man/methods-plot.Rd 68f94a039c236dd70a24349cf4127d1f *man/methods-predict.Rd e585f179940bc17c4b15e0c46024cc65 *man/methods-residuals.Rd 5b2f04e08dc58078f6a167d9d79525fb *man/methods-show.Rd 66cadde8ef0a5bc7d64a7da424685692 *man/methods-summary.Rd 8d55ce40351bd0de5474d8ddc710cf47 *man/methods-volatility.Rd b608c18c7828e45ac286afefb3e8713c *src/Makevars dd6d06f2cbf677b8adad564612b25dc9 *src/dist.f 4b98f5d08a5afa0dac518fadc2eea3e6 *src/llhGarch.f d17c103c6fb1e4f6e84bfaf32add5211 *src/math.f ca566e590ec30abd0718c5375e1a446f *tests/doRUnit.R fGarch/tests/0000755000176000001440000000000011720123747012642 5ustar ripleyusersfGarch/tests/doRUnit.R0000644000176000001440000000151611370220736014351 0ustar ripleyusers#### 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/src/0000755000176000001440000000000012140022162012251 5ustar ripleyusersfGarch/src/math.f0000644000176000001440000000320512140022162013351 0ustar ripleyusers C GAMMA FUNCTION: DOUBLE PRECISION FUNCTION DGAM(X) IMPLICIT DOUBLE PRECISION (A-H, O-Z) DIMENSION G(26) PI = 3.141592653589793D0 IF (X.EQ.INT(X)) THEN IF (X.GT.0.0D0) THEN DGAM = 1.0D0 M1 = X-1 DO K = 2, M1 DGAM = DGAM*K END DO ELSE DGAM = 1.0D+300 END IF ELSE IF (DABS(X).GT.1.0D0) THEN Z = DABS(X) M = INT(Z) R = 1.0D0 DO K = 1, M R = R*(Z-K) END DO Z = Z-M ELSE Z = X END IF DATA G/1.0D0,0.5772156649015329D0, + -0.6558780715202538D0, -0.420026350340952D-1, + 0.1665386113822915D0,-.421977345555443D-1, + -.96219715278770D-2, .72189432466630D-2, + -.11651675918591D-2, -.2152416741149D-3, + .1280502823882D-3, -.201348547807D-4, + -.12504934821D-5, .11330272320D-5, + -.2056338417D-6, .61160950D-8, + .50020075D-8, -.11812746D-8, + .1043427D-9, .77823D-11, + -.36968D-11, .51D-12, + -.206D-13, -.54D-14, .14D-14, .1D-15/ GR = G(26) DO K = 25, 1, -1 GR = GR*Z+G(K) END DO DGAM = 1.0D0/(GR*Z) IF (DABS(X).GT.1.0D0) THEN DGAM = DGAM*R IF (X.LT.0.0D0) DGAM = -PI/(X*GA*DSIN(PI*X)) END IF END IF RETURN END C ------------------------------------------------------------------------------ fGarch/src/llhGarch.f0000644000176000001440000001041112140022162014141 0ustar ripleyusers 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 VARIABLE 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 EXTRENAL 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: 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/src/dist.f0000644000176000001440000001216412140022162013367 0ustar ripleyusers C ------------------------------------------------------------------------------ C CONDITIONAL DISTRIBUTON: DOUBLE PRECISION FUNCTION DIST(Z, HH, SKEW, SHAPE, NDIST) IMPLICIT NONE INTEGER NDIST DOUBLE PRECISION Z, HH, SKEW, SHAPE DOUBLE PRECISION DNORM, DSNORM, DSTD, DSSTD, DGED, DSGED IF (NDIST.EQ.10) THEN C NORMAL: DIST = DNORM(Z/HH)/HH RETURN END IF IF (NDIST.EQ.11) THEN C SKEW NORMAL: DIST = DSNORM(Z/HH, SKEW)/HH RETURN END IF IF (NDIST.EQ.20) THEN C STUDENT-T: DIST = DSTD(Z/HH, SHAPE)/HH RETURN END IF IF (NDIST.EQ.21) THEN C SKEW STUDENT-T: DIST = DSSTD(Z/HH, SHAPE, SKEW)/HH RETURN END IF IF (NDIST.EQ.30) THEN C GED: DIST = DGED(Z/HH, SHAPE)/HH RETURN END IF IF (NDIST.EQ.31) THEN C SKEW GED: DIST = DSGED(Z/HH, SHAPE, SKEW)/HH RETURN END IF RETURN END C ------------------------------------------------------------------------------ C NORMAL: DOUBLE PRECISION FUNCTION DNORM(X) IMPLICIT NONE DOUBLE PRECISION X DOUBLE PRECISION PI, TWO PI = 3.141592653589793D0 TWO = 2.0D0 DNORM = DEXP(-X**2/TWO) / DSQRT(TWO*PI) RETURN END C ------------------------------------------------------------------------------ C SKEW NORMAL: DOUBLE PRECISION FUNCTION DSNORM(X, XI) IMPLICIT NONE DOUBLE PRECISION X, XI DOUBLE PRECISION ONE, TWO, PI, M1, MU, SIGMA DOUBLE PRECISION Z, XXI, G DOUBLE PRECISION DNORM ONE = 1.0D0 TWO = 2.0D0 PI = 3.141592653589793D0 M1 = TWO/DSQRT(TWO*PI) MU = M1*(XI-ONE/XI) SIGMA = DSQRT((ONE-M1**2)*(XI**2+ONE/XI**2)+TWO*M1**2-ONE) Z = X*SIGMA+MU XXI = XI**SIGN(ONE, Z) IF (Z.EQ.0.0D0) THEN XXI = XI**0.0D0 END IF G = TWO/(XI+ONE/XI) DSNORM = G*DNORM(Z/XXI)*SIGMA RETURN END C ------------------------------------------------------------------------------ C GED: DOUBLE PRECISION FUNCTION DGED(X, NU) IMPLICIT NONE DOUBLE PRECISION X, NU DOUBLE PRECISION HALF, ONE, TWO, THREE, LAMBDA, G DOUBLE PRECISION DGAM HALF = 0.50D0 ONE = 1.0D0 TWO = 2.0D0 THREE = 3.0D0 LAMBDA = DSQRT(TWO**(-TWO/NU)*DGAM(ONE/NU)/DGAM(THREE/NU)) G = NU/(LAMBDA*(TWO**(ONE+ONE/NU))*DGAM(ONE/NU)) DGED = G*DEXP(-HALF*(DABS(X/LAMBDA))**NU) RETURN END C ------------------------------------------------------------------------------ C SKEW GED: DOUBLE PRECISION FUNCTION DSGED(X, NU, XI) IMPLICIT NONE DOUBLE PRECISION X, NU, XI DOUBLE PRECISION HALF, ONE, TWO, THREE, LAMBDA, G, M1, MU DOUBLE PRECISION SIGMA, Z, XXI DOUBLE PRECISION DGAM, DGED HALF = 0.50D0 ONE = 1.0D0 TWO = 2.0D0 THREE = 3.0D0 LAMBDA = DSQRT(TWO**(-TWO/NU)*DGAM(ONE/NU)/DGAM(THREE/NU)) G = NU/(LAMBDA*(TWO**(ONE+ONE/NU))*DGAM(ONE/NU)) M1 = (TWO**(ONE/NU))*LAMBDA*DGAM(TWO/NU)/DGAM(ONE/NU) MU = M1*(XI-ONE/XI) SIGMA = (ONE-M1**2)*(XI**2+ONE/(XI**2))+TWO*(M1**2)-ONE SIGMA = DSQRT(SIGMA) Z = X*SIGMA+MU XXI = XI**SIGN(ONE, Z) IF (Z.EQ.0.0D0) THEN XXI = XI**0.0D0 END IF DSGED = (TWO/(XI+ONE/XI))*DGED(Z/XXI, NU)*SIGMA RETURN END C ------------------------------------------------------------------------------ C STUDENT T: DOUBLE PRECISION FUNCTION DT(X, NU) IMPLICIT NONE DOUBLE PRECISION X, NU DOUBLE PRECISION ONE, TWO, PI, A, B DOUBLE PRECISION DGAM ONE = 1.0D0 TWO = 2.0D0 PI = 3.141592653589793D0 A = DGAM((NU+ONE)/TWO)/DSQRT(PI*NU) B = DGAM(NU/TWO)*(ONE+(X*X)/NU)**((NU+ONE)/TWO) DT = A/B RETURN END C ------------------------------------------------------------------------------ C STANDARDIZED STUDENT T: DOUBLE PRECISION FUNCTION DSTD(X, NU) IMPLICIT NONE DOUBLE PRECISION X, NU DOUBLE PRECISION TWO, S DOUBLE PRECISION DT TWO = 2.0D0 S = DSQRT(NU/(NU-TWO)) DSTD = S*DT(X*S,NU) RETURN END C ------------------------------------------------------------------------------ C STANDARDIZED SKEW STUDENT T: DOUBLE PRECISION FUNCTION DSSTD(X, NU, XI) IMPLICIT NONE DOUBLE PRECISION X, NU, XI DOUBLE PRECISION ONE, TWO, A, B, BETA, M1, MU DOUBLE PRECISION SIGMA, Z, G, XXI DOUBLE PRECISION DSTD, DGAM ONE = 1.0D0 TWO = 2.0D0 A = ONE/TWO B = NU/TWO BETA = (DGAM(A)/DGAM(A+B))*DGAM(B) M1 = TWO*DSQRT(NU-TWO)/(NU-ONE)/BETA MU = M1*(XI-ONE/XI) SIGMA = DSQRT((ONE-M1**2)*(XI**2+ONE/XI**2)+TWO*M1**2-ONE) Z = X*SIGMA+MU XXI = XI**SIGN(ONE, Z) IF (Z.EQ.0.0D0) THEN XXI = XI**0.0D0 END IF G = TWO/(XI+ONE/XI) DSSTD = G*DSTD(Z/XXI,NU)*SIGMA RETURN END fGarch/src/Makevars0000644000176000001440000000016011370220736013755 0ustar ripleyusersPKG_LIBS=$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) PKG_CPPFLAGS=-DHAVE_CONFIG_H -I$(RHOME)/src/include PKG_FFLAGS=-w fGarch/man/0000755000176000001440000000000011720123747012253 5ustar ripleyusersfGarch/man/methods-volatility.Rd0000644000176000001440000000561211370220736016404 0ustar ripleyusers\name{volatility-methods} \docType{methods} % \alias{volatility-methods} % \alias{volatility,ANY-method} % \alias{volatility,fGARCH-method} \alias{volatility.fGARCH} \title{Extract GARCH Model Volatility} \description{ Extracts volatility from a fitted GARCH object. } \usage{ % \S4method{volatility}{fGARCH}(object, type = c("sigma", "h"), \dots) \method{volatility}{fGARCH}(object, type = c("sigma", "h"), \dots) } \arguments{ \item{object}{ an object of class \code{fGARCH} as returned from the function \code{garchFit()}. } \item{type}{ a character string denoting if the conditional standard deviations \code{"sigma"} or the variances \code{"h"} should be returned. } \item{\dots}{ additional arguments to be passed. } } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function. } \item{object = "fGARCH"}{ Extractor function for volatility or standard deviation from an object of class \code{"fGARCH"}. } } } \details{ The function extracts the \code{@volatility} from the slots \code{@sigma.t} or \code{@h.t} of an object of class \code{"fGARCH"} as returned by the function \code{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 returns independent of the class of the data input always a numceric vector, i.e. the function call r\code{slot(object, "fitted")} will return a numeric vector. } \note{ \code{volatility} is a generic function which extracts volatility values from objects returned by modeling functions. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## Swiss Pension func Index - x = as.timeSeries(data(LPP2005REC)) ## garchFit fit = garchFit(LPP40 ~ garch(1, 1), data = 100*x, trace = FALSE) fit ## volatility - # Standard Deviation: volatility = volatility(fit, type = "sigma") head(volatility) class(volatility) # Variance: volatility = volatility(fit, type = "h") head(volatility) class(volatility) ## slot - volatility = slot(fit, "sigma.t") head(volatility) class(volatility) volatility = slot(fit, "h.t") head(volatility) class(volatility) } \keyword{models} fGarch/man/methods-summary.Rd0000644000176000001440000000602311370220736015676 0ustar ripleyusers\name{summary-methods} \docType{methods} \alias{summary-methods} \alias{summary,ANY-method} \alias{summary,fGARCH-method} \title{GARCH Summary Methods} \description{ Summary methods for GARCH Modelling. } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function } \item{object = "fGARCH"}{ Summary function for objects of class \code{"fGARCH"}. } } } \section{How to read a diagnostic summary report?}{ The first five sections return 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. } \examples{ ## garchSim - x = garchSim(n = 200) ## garchFit - fit = garchFit(formula = x ~ garch(1, 1), data = x, trace = FALSE) summary(fit) } \keyword{models} fGarch/man/methods-show.Rd0000644000176000001440000000151311370220736015160 0ustar ripleyusers\name{show-methods} \docType{methods} \alias{show-methods} \alias{show,ANY-method} \alias{show,fGARCH-method} \alias{show,fGARCHSPEC-method} \title{GARCH Modelling Show Methods} \description{ Show methods for GARCH Modelling. } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function. } \item{object = "fGARCH"}{ Print function for objects of class \code{"fGARCH"}. } \item{object = "fGARCHSPEC"}{ Print function for objects of class \code{"fGARCH"}. } } } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchSpec - spec = garchSpec() print(spec) ## garchSim - x = garchSim(spec, n = 500) ## garchFit - fit = garchFit(~ garch(1, 1), data = x) print(fit) } \keyword{models} fGarch/man/methods-residuals.Rd0000644000176000001440000000443511370220736016201 0ustar ripleyusers\name{residuals-methods} \docType{methods} \alias{residuals-methods} \alias{residuals,ANY-method} \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 from the function \code{garchFit}. } \item{standardize}{ a logical flag, should the residuals be standardized? } } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function } \item{object = "fGARCH"}{ Extractor function for residual from an object of class \code{"fGARCH"}. } } } \details{ The function extracts the \code{@residuals} slot from an object of class \code{"fGARCH"} as returned by the function \code{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 returns independent of the class of the data input always a numceric vector, i.e. the function call r\code{slot(object, "fitted")} will return a numeric vector. } \note{ \code{residuals} is a generic function which extracts residual values from objects returned by modeling functions. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## Swiss Pension func Index - x = as.timeSeries(data(LPP2005REC)) ## garchFit fit = garchFit(LPP40 ~ garch(1, 1), data = 100*x, trace = FALSE) fit ## residuals - res = residuals(fit) head(res) class(res) ## slot - res = slot(fit, "residuals") head(res) } \keyword{models} fGarch/man/methods-predict.Rd0000644000176000001440000000704611370220736015641 0ustar ripleyusers\name{predict-methods} \docType{methods} \alias{predict-methods} \alias{predict,ANY-method} \alias{predict,fGARCH-method} \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) } \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. } } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function. } \item{object = "fGARCH"}{ Predict function for objects of class \code{"fGARCH"}. } } } \value{ returns a data frame with the foloowing columns: \code{"meanForecast"}, \code{meanError}, and \code{"standardDeviation"}. The number of records equals the number of forecasting steps \code{n.ahead}. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchFit - # 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) ## 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} fGarch/man/methods-plot.Rd0000644000176000001440000000360511370220736015162 0ustar ripleyusers\name{plot-methods} \docType{methods} \alias{plot-methods} \alias{plot,ANY,ANY-method} \alias{plot,fGARCH,missing-method} \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{"fREG"} } \item{which}{ a character string denoting which plot should be displayed. } \item{\dots}{ optional arguments to be passed. } } \section{Methods}{ \describe{ \item{x = "ANY", y = "ANY"}{ Generic function. } \item{x = "fGARCH", y = "missing"}{ Plot function for objects of class \code{"fGARCH"}. } } } \details{ The generic function \code{plot} allows to display 13 graphs. These are the \cr Time SeriesPlot\cr Conditional Standard Deviation Plot\cr Series Plot with 2 Conditional SD Superimposed\cr Autocorrelation function Plot of Observations\cr Autocorrelation function Plot of Squared Observations\cr Cross Correlation Plot\cr Residuals Plot\cr Conditional Standard Deviations Plot\cr Standardized Residuals Plot\cr ACF Plot of Standardized Residuals\cr ACF Plot of Squared Standardized Residuals\cr Cross Correlation Plot between $r^2$ and r\cr Quantile-Quantile Plot of Standardized Residuals\cr } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchSim - # Default Garch(1,1) Model: x = garchSim(n = 200) head(x) ## garchFit - fit = garchFit(formula = ~ garch(1, 1), data = x, trace = FALSE) ## Batch Plot: plot(fit, which = 3) \dontrun{ ## Plot: # Interactive Plot: plot(fit) } } \keyword{models} fGarch/man/methods-formula.Rd0000644000176000001440000000626311370220736015654 0ustar ripleyusers\name{formula-methods} \docType{methods} \alias{formula-methods} \alias{formula,ANY-method} \alias{formula,fGARCH-method} \title{Extract GARCH Model formula} \description{ Extracts formula from a formula GARCH object. } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function. } \item{object = "fGARCH"}{ Extractor function for formula expression. } } } \details{ The function extracts the \code{@formula} expression slot from an object of class \code{"fGARCH"} as returned by the function \code{garchFit}. Note, 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 has 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 and you get the 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 numceric vector, i.e. the function call r\code{slot(object, "fitted")} will return a numeric vector. } \note{ \code{formula} is a generic function which extracts the formula expression from objects returned by modeling functions. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchFit - fit = garchFit(~garch(1, 1), data = garchSim()) ## formula - 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/methods-fitted.Rd0000644000176000001440000000411011370220736015453 0ustar ripleyusers\name{fitted-methods} \docType{methods} \alias{fitted-methods} \alias{fitted,ANY-method} \alias{fitted,fGARCH-method} \title{Extract GARCH Model Fitted Values} \description{ Extracts fitted values from a fitted GARCH object. } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function. } \item{object = "fGARCH"}{ Extractor function for fitted values. } } } \details{ The function extracts the \code{@fitted} value slot from an object of class \code{"fGARCH"} as returned by the function \code{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 returns independent of the class of the data input always a numceric vector, i.e. the function call r\code{slot(object, "fitted")} will return a numeric vector. } \note{ \code{fitted} is a generic function which extracts fitted values from objects returned by modeling functions. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## Swiss Pension fund Index - x = as.timeSeries(data(LPP2005REC)) ## garchFit - # Fit LPP40 Bechmark: fit = garchFit(LPP40 ~ garch(1, 1), data = 100*x, trace = FALSE) fit ## fitted - # Fitted values are now a "timeSeries" oject: fitted = fitted(fit) head(fitted) class(fitted) ## slot - # The slot contains a numeric Vector: fitted = slot(fit, "fitted") head(fitted) class(fitted) } \keyword{models} fGarch/man/methods-coef.Rd0000644000176000001440000000223611370220736015117 0ustar ripleyusers\name{coef-methods} \docType{methods} \alias{coef-methods} \alias{coef,ANY-method} \alias{coef,fGARCH-method} \alias{coef,fGARCHSPEC-method} \title{GARCH Coefficients Methods} \description{ Coefficients methods for GARCH Modelling. } \section{Methods}{ \describe{ \item{object = "ANY"}{ Generic function. } \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{coef} is a generic function which extracts coefficients from objects returned by modeling functions. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchSpec - # Use default parameters beside alpha: spec = garchSpec(model = list(alpha = c(0.05, 0.05))) spec coef(spec) ## garchSim - # Simulate an univariate "timeSeries" series x = garchSim(spec, n = 200) x = x[,1] ## garchFit - fit = garchFit( ~ garch(1, 1), data = x) ## coef - coef(fit) } \keyword{models} fGarch/man/garchSpec.Rd0000644000176000001440000001504111370220736014437 0ustar ripleyusers\name{garchSpec} \alias{garchSpec} \title{Univariate GARCH Time Series Specification} \description{ Specifies an univariate GARCH time series model. } \usage{ garchSpec(model = list(), presample = NULL, cond.dist = c("norm", "ged", "std", "snorm", "sged", "sstd"), rseed = NULL) } \arguments{ \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 the normal distribution. } \item{model}{ a list of GARCH model parameters: \cr \code{omega} - the constant coefficient of the variance equation, by default 1e-6; \cr \code{alpha} - the value or vector of autoregressive coefficients, by default 0.1, specifying a model of order 1; \cr \code{beta} - the value or vector of variance coefficients, by default 0.8, specifying a model of order 1; \cr The values for the linear part are: \cr \code{mu} - the mean value, by default NULL; \cr \code{ar} - the autoregressive ARMA coefficients, by default NULL; \cr \code{ma} - the moving average ARMA coefficients, by default NULL. \cr The parameters for the conditional distributions are:\cr \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; \cr \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.\cr \cr Note, 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 cutted. Note, all presamples are initialized by a normal-GARCH(p,q) process. } \item{rseed}{ single integer argument, the seed for the intitialization of the random number generator for the innovations. Using the default value \code{rseed=NULL} then the random number generation will be started with \code{set.seed(0)}. } } \details{ The function \code{garchSpec} specifies a GARCH or APARCH time series process which we can use for simulating artificial GARCH and/or APARCH models. This is very useful for testing the GARCH parameter estimation results, since your model parameters are known and well specified. For example specifying a subet 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 } The "Formula" describes the formula expression specifying the generating process, "Model" lists the associated model parameters, "Distribution" the type of the conditional distribution function in use, "Distributional Parmeters" lists the distributional parameter (if any), and the "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{ The returned value is an object of class \code{"fGARCHSPEC"}. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchSpec - # 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} fGarch/man/garchSim.Rd0000644000176000001440000001465011370220736014302 0ustar ripleyusers\name{garchSim} \alias{garchSim} \title{Univariate GARCH/APARCH Time Series Simulation} \description{ Simulates a univariate GARCH/APARCH time series model. } \usage{ garchSim(spec = garchSpec(), n = 100, n.start = 100, extended = FALSE) } \arguments{ \item{extended}{ logical parameter if the output series should be a 3 columns \code{timeSeries} object with \code{garch}, \code{sigma} and \code{eps} data (\code{extended = TRUE}) or a univariate GARCH\\APARCH time series (\code{extended = FALSE} } \item{spec}{ a specification object of class \code{"fGARCHSPEC"} as returned by the function \code{garchSpec}. The model parameters are taken from the \code{@model} slot, a list with the following entries:\cr \code{omega} - the constant coefficient of the variance equation, by default 1e-6; \cr \code{alpha} - the value or vector of autoregressive coefficients, by default 0.1, specifying a model of order 1; \cr \code{beta} - the value or vector of variance coefficients, by default 0.8, specifying a model of order 1; \cr The optional values for the linear part are: \cr \code{mu} - the intercept value, by default 0 (it implies that the mean = mu/(1-sum(ar))); \cr \code{ar} - the autoregressive ARMA coefficients, by default 0; \cr \code{ma} - the moving average ARMA coefficients, by default 0. \cr The optional parameters for the conditional distributions are:\cr \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; \cr \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.\cr See also below for further details. } \item{n}{ length of output series, an integer value. An integer value, by default \code{n=100}. } \item{n.start}{ length of "burn-in" period, by default 100. } } \details{ The function \code{garchSim} simulates an univariate GARCH or APARCH time series process as specified by the argument \code{model}. The \code{model} is an object of class \code{"fGARCHSPEC"} as returned by the function \code{garchSpec}. The returned model specification comes 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}. 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 simulate than statistically equivalent GARCH processes with the same set of model parameters using the function \code{garchSim}. 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"}. Note, the default model specifies Bollerslev's GARCH(1,1) model with normal distributed innovations. } \value{ The function \code{garchSim} returns an objects of class \code{"timeSeries"} attributed by a list with entry \code{$garchSpec} giving the GARCH specification structure as returned by the function \code{garchSpec} and with information on conditional standard deviations and innovations. See details above. } \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ ## garchSpec - spec = garchSpec() spec ## garchSim - # Simulate a "timeSeries" object: 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) } \keyword{models} fGarch/man/garchFitControl.Rd0000644000176000001440000001762411370220736015641 0ustar ripleyusers\name{garchFitControl} \alias{garchFitControl} \title{GARCH Fitting Algorithms and Control} \description{ Estimates the parameters of an univariate GARCH process. } \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}{ llh = c("filter", "internal", "testing")[1], defaults to "filter". } % nlminb: \item{nlminb.eval.max}{ Maximum number of evaluations of the objective function allowed, defaults to 200. } \item{nlminb.iter.max}{ Maximum number of iterations allowed, 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 "BFGS" and "L-BFGS-B" methods if control\$trace is positive. Defaults to every 10 iterations. } \item{lbfgsb.lmm}{ is an integer giving the number of BFGS updates retained in the "L-BFGS-B" method, It defaults to 5. } \item{lbfgsb.factr}{ controls the convergence of the "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 "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 "Nelder-Mead". For "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 reltol * (abs(val) + reltol) at a step. Defaults to 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 fn(par)/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{ returns 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. } \examples{ ## } \keyword{models} fGarch/man/garchFit.Rd0000644000176000001440000003142311370220736014271 0ustar ripleyusers\name{garchFit} \alias{garchFit} \alias{garchKappa} \title{Univariate GARCH Time Series Fitting} \description{ Estimates the parameters of an univariate ARMA-GARCH/APARCH process. } \usage{ garchFit(formula = ~ garch(1, 1), data = dem2gbp, 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) } \arguments{ %\item{recursion}{ % a string parameter that determines the recursion used for calculating % the maximum log-likelihood function. % Allowed values are ... %} \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{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{control}{ control parameters, the same as used for the functions from \code{nlminb}, and 'bfgs' and 'Nelder-Mead' from \code{optim}. } \item{data}{ an optional timeSeries or 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{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{description}{ a character string which allows for a brief description. } \item{formula}{ formula object describing the mean and variance equation of the ARMA-GARCH/APARCH model. A pure GARCH(1,1) model is selected when e.g. \code{formula=~garch(1,1)}. To specify for example an ARMA(2,1)-APARCH(1,1) use \code{formula = ~arma(2,1)+apaarch(1,1)}. } \item{gamma}{ APARCH leverage parameter entering into the formula for calculating the expectation value. } % \item{hessian}{ % a string denoting how the Hessian matrix should be evaluated, % either \code{hessian ="cda"}, the default, or \code{"fda"}. % The forward difference approximation, \code{"fda"} consumes less % computer time, but is usually not as precise as approximations % that use central difference approximation, \code{"cda"}, formula. % } \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"} use the internal R function \code{optimhess}. } \item{include.delta}{ a logical flag which determines if the parameter for the recursion equation \code{delta} will be estimated or not. If \code{include.delta=FALSE} then the shape parameter will be kept fixed during the process of parameter optimization. } \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.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{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{init.rec}{ a character string indicating the method how to initialize the mean and varaince recursion relation. } \item{leverage}{ a logical flag for APARCH models. Should the model be leveraged? By default \code{leverage=TRUE}. } \item{shape}{ a numeric value, the shape parameter of the conditional distribution. } \item{skew}{ a numeric value, the skewness parameter of the conditional distribution. } \item{title}{ a character string which allows for a project title. } \item{trace}{ a logical flag. Should the optimization process of fitting the model parameters be printed? By default \code{trace=TRUE}. } \item{\dots}{ additional arguments to be passed. } } \value{ \code{garchFit} \cr \cr returns a S4 object of class \code{"fGARCH"} with the following slots: \item{@call}{ the call of the \code{garch} function. } \item{@formula}{ a list with two formula entries, one for the mean and the other one for the variance equation. } \item{@method}{ a string denoting the optimization method, by default the returneds string is "Max Log-Likelihood Estimation". } \item{@data}{ a list with one entry named \code{x}, containing the data of the time series to be estimated, the same as given by the input argument \code{series}. } \item{@fit}{ a list with the results from the parameter estimation. The entries of the list depend on the selected algorithm, see below. } \item{@residuals}{ a numeric vector with the (raw, unstandardized) residual values. } \item{@fitted}{ a numeric vector with the fitted values. } \item{@h.t}{ a numeric vector with the conditional variances (\eqn{h_t = \sigma_t^\delta}{h.t = sigma.t^delta}). } \item{@sigma.t}{ a numeric vector with the conditional standard deviation. } \item{@title}{ a title string. } \item{@description}{ a string with a brief description. } The entries of the @fit slot show the results from the optimization. } \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. } \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. } \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: x.timeSeries = dummyDailySeries(matrix(x.vec), units = "GARCH11") garchFit(~ garch(1,1), data = x.timeSeries, trace = FALSE) \dontrun{ # An univariate zoo object: 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: 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)) } \keyword{models} fGarch/man/dist-stdSlider.Rd0000644000176000001440000000137511370220736015443 0ustar ripleyusers\name{stdSlider} \alias{stdSlider} \title{Student-t Distribution Slider} \description{ Displays interactively the dependence of the Student-t distribution on its parameters. } \usage{ stdSlider(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{ %} \author{ Diethelm Wuertz for the Rmetrics \R-port. } \examples{ \dontrun{ ## stdSlider - require(tcltk) stdSlider("dist") stdSlider("rand") } } \keyword{distribution} fGarch/man/dist-stdFit.Rd0000644000176000001440000000265611370220736014746 0ustar ripleyusers\name{stdFit} \alias{stdFit} \title{Student-t Distribution Parameter Estimation} \description{ Function to fit the parameters of the 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: \cr \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. } \examples{ ## std - set.seed(1953) r = rstd(n = 1000) ## stdFit - stdFit(r) } \keyword{distribution} fGarch/man/dist-std.Rd0000644000176000001440000000370411370220736014276 0ustar ripleyusers\name{std} \alias{std} \alias{dstd} \alias{pstd} \alias{qstd} \alias{rstd} \title{Student-t Distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the 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{mean, sd, nu}{ location parameter \code{mean}, scale parameter \code{sd}, shape parameter \code{nu}. } \item{n}{ the number of observations. } \item{p}{ a numeric vector of probabilities. } \item{x, q}{ a numeric vector of quantiles. } \item{log}{ a logical; if TRUE, densities are given as log densities. } } \value{ \code{d*} returns the density, \code{p*} returns the distribution function, \code{q*} returns the quantile function, and \code{r*} generates random deviates, \cr all values are numeric vectors. } \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. } \examples{ ## std - 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/dist-sstdSlider.Rd0000644000176000001440000000161211370220736015620 0ustar ripleyusers\name{sstdSlider} \alias{sstdSlider} \title{Skew Student-t Distribution Slider} \description{ Displays interactively the dependence of the skew Student-t distribution on its parameters. } \usage{ sstdSlider(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{ 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. } \examples{ \dontrun{ ## sstdSlider - require(tcltk) sstdSlider("dist") sstdSlider("rand") } } \keyword{distribution} fGarch/man/dist-sstdFit.Rd0000644000176000001440000000267311370220736015130 0ustar ripleyusers\name{sstdFit} \alias{sstdFit} \title{Skew Student-t Distribution Parameter Estimation} \description{ Function to fit the parameters of the Student-t distribution. } \usage{ sstdFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters parsed to the optimization function \code{nlm}. } } \value{ \code{sstdFit} returns a list with the following components: \cr \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. } \examples{ ## sstd - set.seed(1953) r = rsstd(n = 1000) ## sstdFit - sstdFit(r) } \keyword{distribution} fGarch/man/dist-sstd.Rd0000644000176000001440000000412311370220736014455 0ustar ripleyusers\name{sstd} \alias{sstd} \alias{dsstd} \alias{psstd} \alias{qsstd} \alias{rsstd} \title{Skew Student-t Distribution and Parameter Estimation} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the skew Student-t distribution. } \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{mean, sd, nu, xi}{ location parameter \code{mean}, scale parameter \code{sd}, shape parameter \code{nu}, skewness parameter \code{xi}. } \item{n}{ the number of observations. } \item{p}{ a numeric vector of probabilities. } \item{x, q}{ a numeric vector of quantiles. } \item{log}{ a logical; if TRUE, densities are given as log densities. } } \value{ \code{d*} returns the density, \code{p*} returns the distribution function, \code{q*} returns the quantile function, and \code{r*} generates random deviates, \cr all values are numeric vectors. } \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. } \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/dist-snormSlider.Rd0000644000176000001440000000161211370220736016001 0ustar ripleyusers\name{snormSlider} \alias{snormSlider} \title{Skew Normal Distribution Slider} \description{ Displays interactively the dependence of the skew Normal distribution on its parameters. } \usage{ snormSlider(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{ 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. } \examples{ \dontrun{ ## snormSlider - require(tcltk) snormSlider("dist") snormSlider("rand") } } \keyword{distribution} fGarch/man/dist-snormFit.Rd0000644000176000001440000000270311370220736015303 0ustar ripleyusers\name{snormFit} \alias{snormFit} \title{Skew Normal Distribution Parameter Estimation} \description{ Function to fit the parameters of the skew normal distribution. } \usage{ snormFit(x, \dots) } \arguments{ \item{x}{ a numeric vector of quantiles. } \item{\dots}{ parameters parsed to the optimization function \code{nlm}. } } \value{ \code{snormFit} returns a list with the following components: \cr \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. } \examples{ ## rsnorm - set.seed(1953) r = rsnorm(n = 1000) ## snormFit - snormFit(r) } \keyword{distribution} fGarch/man/dist-snorm.Rd0000644000176000001440000000415311370220736014641 0ustar ripleyusers\name{snorm} \alias{snorm} \alias{dsnorm} \alias{psnorm} \alias{qsnorm} \alias{rsnorm} \title{Skew Normal Distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the skew normal distribution. } \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{mean, sd, xi}{ location parameter \code{mean}, scale parameter \code{sd}, skewness parameter \code{xi}. } \item{n}{ the number of observations. } \item{p}{ a numeric vector of probabilities. } \item{x, q}{ a numeric vector of quantiles. } \item{\dots}{ parameters parsed to the optimization function \code{nlm}. } \item{log}{ a logical; if TRUE, densities are given as log densities. } } \value{ \code{d*} returns the density, \code{p*} returns the distribution function, \code{q*} returns the quantile function, and \code{r*} generates random deviates, \cr all values are numeric vectors. } \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. } \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/dist-sgedSlider.Rd0000644000176000001440000000177711370220736015601 0ustar ripleyusers\name{sgedSlider} \alias{sgedSlider} \title{Skew GED Distribution Slider} \description{ Displays interactively the dependence of the skew GED distribution on its parameters. } \usage{ 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. } \examples{ \dontrun{ ## sgedSlider - require(tcltk) sgedSlider("dist") sgedSlider("rand") } } \keyword{distribution} fGarch/man/dist-sgedFit.Rd0000644000176000001440000000312411370220736015065 0ustar ripleyusers\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 parsed to the optimization function \code{nlm}. } } \value{ \code{sgedFit} returns a list with the following components: \cr \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. } \examples{ ## rsged - set.seed(1953) r = rsged(n = 1000) ## sgedFit - sgedFit(r) } \keyword{distribution} fGarch/man/dist-sged.Rd0000644000176000001440000000431611370220736014426 0ustar ripleyusers\name{sged} \alias{sged} \alias{dsged} \alias{psged} \alias{qsged} \alias{rsged} \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. } \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{mean, sd, nu, xi}{ location parameter \code{mean}, scale parameter \code{sd}, shape parameter \code{nu}, skewness parameter \code{xi}. } \item{n}{ the number of observations. } \item{p}{ a numeric vector of probabilities. } \item{x, q}{ a numeric vector of quantiles. } \item{log}{ a logical; if TRUE, densities are given as log densities. } } \value{ \code{d*} returns the density, \code{p*} returns the distribution function, \code{q*} returns the quantile function, and \code{r*} generates random deviates, \cr all values are numeric vectors. } \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. } \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-gedSlider.Rd0000644000176000001440000000177611370220736015415 0ustar ripleyusers\name{gedSlider} \alias{gedSlider} \title{Geeneralized Error Distribution Slider} \description{ Displays interactively the dependence of the GED distribution on its parameters. } \usage{ gedSlider(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. } \examples{ \dontrun{ ## gedSlider - require(tcltk) gedSlider("dist") gedSlider("rand") } } \keyword{distribution} fGarch/man/dist-gedFit.Rd0000644000176000001440000000310211370220736014676 0ustar ripleyusers\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: \cr \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. } \examples{ ## rged - set.seed(1953) r = rged(n = 1000) ## gedFit - gedFit(r) } \keyword{distribution} fGarch/man/dist-ged.Rd0000644000176000001440000000415511370220736014244 0ustar ripleyusers\name{ged} \alias{ged} \alias{dged} \alias{pged} \alias{qged} \alias{rged} \title{Generalized Error Distribution} \description{ Functions to compute density, distribution function, quantile function and to generate random variates for the 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{mean, sd, nu}{ location parameter \code{mean}, scale parameter \code{sd}, shape parameter \code{nu}. } \item{n}{ the number of observations. } \item{p}{ a numeric vector of probabilities. } \item{x, q}{ a numeric vector of quantiles. } \item{log}{ a logical; if TRUE, densities are given as log densities. } } \value{ \code{d*} returns the density, \code{p*} returns the distribution function, \code{q*} returns the quantile function, and \code{r*} generates random deviates, \cr all values are numeric vectors. } \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. } \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-absMoments.Rd0000644000176000001440000000201211370220736015603 0ustar ripleyusers\name{absMoments} \alias{absMoments} \title{Absolute Moments of GARCH Distributions} \description{ Computes absolute Moments of the skew Normal, skew GED, and standardized skew Student-t distributions } \usage{ absMoments(n, density = c("dnorm", "dged", "dstd"), \dots) } \arguments{ \item{density}{ a character string naming the symmetric density function. } \item{n}{ the number of absolute Moments. } \item{\dots}{ parameters passed to the density function. } } \value{ \code{absMoments} returns a numeric vector of length \code{n} with the values of the absolute moments of the selected density function. } \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. } \examples{ ## absMoment - absMoments(4, "dstd", nu = 4) } \keyword{distribution} fGarch/man/data.Rd0000644000176000001440000000030211370220736013443 0ustar ripleyusers\name{TimeSeriesData} \alias{TimeSeriesData} \alias{dem2gbp} \alias{sp500dge} \title{Time Series Data Sets} \description{ Data sets used in the examples of the timeSeries packages. } fGarch/man/class-fGARCHSPEC.Rd0000644000176000001440000000315111370220736015307 0ustar ripleyusers\name{fGARCHSPEC-class} \docType{class} \alias{fGARCHSPEC-class} \alias{update,fGARCHSPEC-method} \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 is 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. } \keyword{programming} fGarch/man/class-fGARCH.Rd0000644000176000001440000000653411370220736014644 0ustar ripleyusers\name{fGARCH-class} \docType{class} \alias{fGARCH-class} \alias{fUGARCHSPEC-class} \alias{update,fGARCH-method} \title{Class "fGARCH"} \description{ The class fGARCH represents a model of an heteroskedastic time series process. } \section{Objects from the Class}{ Objects can be created by calls of the function \code{garchFit}. This object is a parameter estimate 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 formula object specifying mean and variance equation. } \item{\code{method}:}{Object of class \code{"character"}: a string denoting the optimization method, by default the returneds string is "Max Log-Likelihood Estimation". } \item{\code{data}:}{Object of class \code{"list"}: a list with one entry named \code{x}, containing the data of the time series to be estimated, the same as given by the input argument \code{series}. } \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"}: a numeric vector with the residual values. } \item{\code{fitted}:}{Object of class \code{"numeric"}: a numeric vector with the fitted values. } \item{\code{h.t}:}{Object of class \code{"numeric"}: a numeric vector with the conditional variances. } \item{\code{sigma.t}:}{Object of class \code{"numeric"}: a numeric vector with 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. } } } \section{Methods}{ \describe{ \item{plot}{\code{signature(x = "fGARCH", y = "missing")}: plots an object of class 'fGARCH'. } \item{show}{\code{signature(object = "fGARCH")}: prints an object of class 'fGARCH'. } \item{summary}{\code{signature(object = "fGARCH")}: summarizes an object of class 'fGARCH'. } \item{predict}{\code{signature(object = "fGARCH")}: forecasts mean and volatility from an object of class 'fGARCH'. } \item{fitted}{\code{signature(object = "fGARCH")}: extracts fitted values from an object of class 'fGARCH'. } \item{residuals}{\code{signature(object = "fGARCH")}: extracts fresiduals from an object of class 'fGARCH'. } \item{volatility}{\code{signature(object = "fGARCH")}: extracts conditional volatility from an object of class 'fGARCH'. } \item{coef}{\code{signature(object = "fGARCH")}: extracts fitted coefficients from an object of class 'fGARCH'. } \item{formula}{\code{signature(x = "fGARCH")}: extracts formula expression from an object of class 'fGARCH'. } } } \author{ Diethelm Wuertz and Rmetrics Core Team. } \keyword{programming} fGarch/man/00fGarch-package.Rd0000644000176000001440000001231711370220736015466 0ustar ripleyusers\name{fGarch-package} \alias{fGarch-package} \alias{fGarch} \docType{package} \title{GARCH Modelling Package} \description{ Package of econometric functions for modelling GARCH processes. } \details{ \tabular{ll}{ Package: \tab fGarch \cr Type: \tab Package \cr Version: \tab 270.73 \cr Date: \tab 2008 \cr License: \tab GPL (>= 2) \cr Copyright: \tab (c) 1999-2008 Diethelm Wuertz and Rmetrics Foundation \cr URL: \tab \url{http://www.rmetrics.org} } 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{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.\cr } \section{Time Series Simulation}{ contains functions to simulate artificial GARCH and APARCH time series processes. Functions: \tabular{ll}{ \code{garchSpec} \tab Specifies an univariate GARCH time series model, \cr \code{garchSim} \tab Simulates a GARCH/APARCH process. } } \section{Parameter Estimation}{ contains functions to fit the parameters of GARCH and APARCH time series processes. Functions: \tabular{ll}{ \code{garchFit} \tab Fits the parameters of a GARCH process, \cr \code{residuals} \tab Extracts residuals from a fitted 'fGARCH' object, \cr \code{fitted} \tab Extracts fitted values from a fitted 'fGARCH' object, \cr \code{volatility} \tab Extracts conditional volatility from a fitted 'fGARCH' object, \cr \code{coef} \tab Extracts coefficients from a fitted 'fGARCH' object, \cr \code{formula} \tab Extracts formula expression from a fitted 'fGARCH' object. } } \section{Forecasting}{ contains functions to forcecast mean and variance of GARCH and APARCH processes. Functions: \tabular{ll}{ \code{predict} \tab Forecasts from an object of class 'fGARCH'. } } \section{Standardized Distribution Functions}{ contains functions to model standardized distribution functions. Functions: \tabular{ll}{ \code{[dpqr]norm} \tab Normal distribution function, \cr \code{[dpqr]snorm} \tab Skew Normal distribution function, \cr \code{[s]normFit} \tab Fits parameters of [skew] Normal distribution, \cr \code{[dpqr]ged} \tab Generalized Error distribution function, \cr \code{[dpqr]sged} \tab Skew Generalized Error distribution function, \cr \code{[s]gedFit} \tab Fits parameters of [skew] Generalized Error distribution, \cr \code{[dpqr]std} \tab standardized Student-t distribution function, \cr \code{[dpqr]sstd} \tab Skew standardized Student-t distribution function, \cr \code{[s]stdFit} \tab Fits parameters of [skew] Student-t distribution, \cr \code{absMoments} \tab Computes absolute Moments of these distribution. } } \section{OX Interface}{ NOTE: garchOxFit is no longer part of fGarch package. If you are interested to use, please contact us. contains a Windows interface to OX. The function \code{garchOxFit} interfaces a subset of the functionality of the G@ARCH 4.0 Package written in Ox. G@RCH 4.0 is one of the most sophisticated packages for modelling univariate GARCH processes including GARCH, EGARCH, GJR, APARCH, IGARCH, FIGARCH, FIEGARCH, FIAPARCH and HYGARCH models. Parameters can be estimated by approximate (Quasi-) maximum likelihood methods under four assumptions: normal, Student-t, GED or skewed Student-t errors. } \author{ Diethelm Wuertz and Rmetrics Core Team. } \keyword{package} fGarch/inst/0000755000176000001440000000000011720123747012455 5ustar ripleyusersfGarch/inst/unitTests/0000755000176000001440000000000012026023045014445 5ustar ripleyusersfGarch/inst/unitTests/runit.sstd.R0000644000176000001440000001067511370220737016726 0ustar ripleyusers # 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 = .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 = .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.snorm.R0000644000176000001440000000705211370220737017102 0ustar ripleyusers # 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 = .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 = .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.sged.R0000644000176000001440000001040511370220737016662 0ustar ripleyusers # 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 = .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 = .distCheck("sged", mean = 0, sd = 1, nu = 2, xi = 0.8, robust = FALSE) print(test) # 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.predict-methods.R0000644000176000001440000000435211370220737021037 0ustar ripleyusers # 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.plot-methods.R0000644000176000001440000001423211370220737020361 0ustar ripleyusers # 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.garchSpec.R0000644000176000001440000000777211370220737017654 0ustar ripleyusers # 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.garchSolver.R0000644000176000001440000002402012026023045020205 0ustar ripleyusers # 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.garchSim.R0000644000176000001440000001224611370220737017502 0ustar ripleyusers # 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.garchHessian.R0000644000176000001440000000302211370220737020334 0ustar ripleyusers # 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.garchFit.init.R0000644000176000001440000000427411370220737020440 0ustar ripleyusers # 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/runit.garchFit.garch.R0000644000176000001440000000735211370220737020561 0ustar ripleyusers # 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/runit.garchFit.faked.R0000644000176000001440000001371411370220737020546 0ustar ripleyusers # 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 = 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 = 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 = 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 = 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 = 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.garchFit.dist.R0000644000176000001440000001356311370220737020441 0ustar ripleyusers # 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/unitTests/runit.garchFit.aparch.R0000644000176000001440000001022411370220737020723 0ustar ripleyusers # 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 = 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.algorithm.R0000644000176000001440000001050111370220737021451 0ustar ripleyusers # 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.garchFit.R0000644000176000001440000000622511370220737017474 0ustar ripleyusers # 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 = 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 = 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.garch-methods.R0000644000176000001440000000524511370220737020473 0ustar ripleyusers # 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.formula-methods.R0000644000176000001440000001400411370220737021045 0ustar ripleyusers # 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 = 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 = 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 = 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: 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)) # head does not work for ts objects! # 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/runTests.R0000644000176000001440000000452611370220737016436 0ustar ripleyuserspkg <- "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/Makefile0000644000176000001440000000041711370220737016117 0ustar ripleyusersPKG=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/THANKS0000644000176000001440000000035511370220737013371 0ustar ripleyusersThe 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/COPYRIGHT.html0000644000176000001440000002041111370220737014707 0ustar ripleyusers Rmetrics::COPYRIGHT

Rmetrics Copyrights


2005-12-18 Built 221.10065

  
________________________________________________________________________________
Copyrights (C) for 

    R:  
      see R's copyright and license file
      
    Version R 2.0.0 claims:
    - The stub packages from 1.9.x have been removed.
    - All the datasets formerly in packages 'base' and 'stats' have
      been moved to a new package 'datasets'. 
    - Package 'graphics' has been split into 'grDevices' (the graphics
      devices shared between base and grid graphics) and 'graphics'
      (base graphics). 
    - Packages must have been re-installed for this version, and
      library() will enforce this.
    - Package names must now be given exactly in library() and
      require(), regardless of whether the underlying file system is
      case-sensitive or not.    

________________________________________________________________________________
for 
    
    Rmetrics:
      (C) 1999-2005, Diethelm Wuertz, GPL
      Diethelm Wuertz 
      www.rmetrics.org
      info@rmetrics.org
 
________________________________________________________________________________
for non default loaded basic packages part of R's basic distribution

    MASS:    
      Main Package of Venables and Ripley's MASS.
      We assume that MASS is available. 
      Package 'lqs' has been returned to 'MASS'.  
      S original by Venables & Ripley.
      R port by Brian Ripley .
      Earlier work by Kurt Hornik and Albrecht Gebhardt.
    methods: 
      Formally defined methods and classes for R objects, plus other 
      programming tools, as described in the reference "Programming 
      with Data" (1998), John M. Chambers, Springer NY. 
      R Development Core Team.
    mgcv:   
      Routines for GAMs and other generalized ridge regression
      with multiple smoothing parameter selection by GCV or UBRE.
      Also GAMMs by REML or PQL. Includes a gam() function.
      Simon Wood 
    nnet: 
      Feed-forward Neural Networks and Multinomial Log-Linear Models
      Original by Venables & Ripley. 
      R port by Brian Ripley .
      Earlier work by Kurt Hornik and Albrecht Gebhardt.
      
________________________________________________________________________________
for the code partly included as builtin functions from other R ports:

    fBasics:CDHSC.F
      GRASS program for distributional testing.
      By James Darrell McCauley 
      Original Fortran Source by Paul Johnson EZ006244@ALCOR.UCDAVIS.EDU>
    fBasics:nortest
      Five omnibus tests for the composite hypothesis of normality
      R-port by Juergen Gross 
    fBasics:SYMSTB.F
      Fast numerical approximation to the Symmetric Stable distribution 
      and density functions.  
      By Hu McCulloch 
    fBasics:tseries
      Functions for time series analysis and computational finance.
      Compiled by Adrian Trapletti 
         
    fCalendar:date     
      The tiny C program from Terry Therneau  is used
      R port by Th. Lumley ,
      K. Halvorsen , and 
      Kurt Hornik 
    fCalendar:holidays
      The holiday information was collected from the internet and 
      governmental sources obtained from a few dozens of websites
    fCalendar:libical
      Libical is an Open Source implementation of the IETF's 
      iCalendar Calendaring and Scheduling protocols. (RFC 2445, 2446, 
      and 2447). It parses iCal components and provides a C API for 
      manipulating the component properties, parameters, and subcomponents.
    fCalendar:vtimezone
      Olsen's VTIMEZONE database consists of data files are released under 
      the GNU General Public License, in keeping with the license options of 
      libical. 
     
    fSeries:bdstest.c
      C Program to compute the BDS Test.
      Blake LeBaron
    fSeries:fracdiff  
      R functions, help pages and the Fortran Code for the 'fracdiff' 
      function are included. 
      S original by Chris Fraley 
      R-port by Fritz Leisch 
      since 2003-12: Martin Maechler
    fSeries:lmtest
      R functions and help pages for the linear modelling tests are included .
      Compiled by Torsten Hothorn ,
      Achim Zeileis , and
      David Mitchell
    fSeries:mda    
      R functions, help pages and the Fortran Code for the 'mars' function
      are implemeted.
      S original by Trevor Hastie & Robert Tibshirani,
      R port by Friedrich Leisch, Kurt Hornik and Brian D. Ripley 
    fSeries:modreg
      Brian Ripley and the R Core Team
    fSeries:polspline   
      R functions, help pages and the C/Fortran Code for the 'polymars' 
      function are implemented
      Charles Kooperberg 
    fSeries:systemfit
      Simultaneous Equation Estimation Package.
      R port by Jeff D. Hamann  and 
      Arne Henningsen 
    fSeries:tseries
      Functions for time series analysis and computational finance.
      Compiled by Adrian Trapletti 
    fSeries:UnitrootDistribution:
      The program uses the Fortran routine and the tables 
      from J.G. McKinnon. 
    fSeries:urca
      Unit root and cointegration tests for time series data.
      R port by Bernhard Pfaff .
     
    fExtremes:evd
      Functions for extreme value distributions.
      R port by Alec Stephenson 
      Function 'fbvpot' by Chris Ferro.
    fExtremes:evir
      Extreme Values in R
      Original S functions (EVIS) by Alexander McNeil 
      R port by Alec Stephenson   
    fExtremes:ismev
      An Introduction to Statistical Modeling of Extreme Values
      Original S functions by Stuart Coles 
      R port/documentation by Alec Stephenson 
      
    fOptions
      Option Pricing formulas are implemented along the book and 
      the Excel spreadsheets of E.G. Haug, "The Complete Guide to Option 
      Pricing"; documentation is partly taken from www.derivicom.com which 
      implements a C Library based on Haug. For non-academic and commercial 
      use we recommend the professional software from "www.derivicom.com".  
    fOptions:SOBOL.F
      ACM Algorithm 659 by P. Bratley and B.L. Fox
      Extension on Algorithm 659 by S. Joe and F.Y. Kuo
    fOptions:CGAMA.F
      Complex gamma and related functions.
      Fortran routines by Jianming Jin.
    fOptions:CONHYP.F
      Confluenet Hypergeometric and related functions.
      ACM Algorithm 707 by mark Nardin, W.F. Perger, A. Bhalla
             
    fPortfolio:mvtnorm
      Multivariate Normal and T Distribution.
      Alan Genz , 
      Frank Bretz 
      R port by Torsten Hothorn 
    fPortfolio:quadprog
      Functions to solve Quadratic Programming Problems.
      S original by Berwin A. Turlach  
      R port by Andreas Weingessel 
    fPortfolio:sn
      The skew-normal and skew-t distributions.
      R port by Adelchi Azzalini 
    fPortfolio:tseries
      Functions for time series analysis and computational finance.
      Compiled by Adrian Trapletti 
 
fGarch/data/0000755000176000001440000000000012140022162012373 5ustar ripleyusersfGarch/data/sp500dge.csv.gz0000644000176000001440000016043412140022162015066 0ustar ripleyusers‹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=‘š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/R/0000755000176000001440000000000012135305634011677 5ustar ripleyusersfGarch/R/zzz.R0000644000176000001440000000253012135305634012657 0ustar ripleyusers # 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 ################################################################################ ## .First.lib <- function(lib, pkg) library.dynam("fGarch", pkg, lib) ################################################################################ fGarch/R/mgarch-FitFromFormula.R0000644000176000001440000001124411370220736016156 0ustar ripleyusers # 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(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-volatility.R0000644000176000001440000000510111370220736015657 0ustar ripleyusers # 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 ################################################################################ # 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/methods-update.R0000644000176000001440000000503011370220736014742 0ustar ripleyusers # 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 ################################################################################ # 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/methods-summary.R0000644000176000001440000001027411370220736015163 0ustar ripleyusers # 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: DESCRIPTION: # summary Summary method for an object of class 'fGARCH' ################################################################################ setMethod(f = "summary", signature(object = "fGARCH"), function(object) { # A function implemented by Diethelm Wuertz # 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() }) ################################################################################ fGarch/R/methods-show.R0000644000176000001440000001363211370220736014447 0ustar ripleyusers # 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: DESCRIPTION: # show.fGARCH S4 Show method for an object of class 'fGARCH' # show.fGARCHSPEC S4 Show method for an object of class 'fGARCHSPEC' ################################################################################ setMethod(f = "show", signature(object = "fGARCH"), definition = function(object) { # A function implemented by Diethelm Wuertz # Description: # Print method for an object of class "fGARCH" # Arguments: # object - an object of class 'fGARCH' # FUNCTION: # Title: cat("\nTitle:\n ") cat(object@title, "\n") # Call: cat("\nCall:\n ") cat(paste(deparse(object@call), sep = "\n", collapse = "\n"), "\n") # Mean and Variance Equation: cat("\nMean and Variance Equation:\n ") Name = unclass(attr(object@formula, "data")) Formula = object@formula attr(Formula, "data") <- NULL print(Formula) cat(" [", Name, "]\n", sep = "") # Univariate or Multivariate Modeling ? if (as.character(object@call[1]) == ".gogarchFit") { # 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") } else { # For univariate Garch Models ... # Conditional Distribution: cat("\nConditional Distribution:\n ") cat(object@fit$params$cond.dist, "\n") # Coefficients: cat("\nCoefficient(s):\n") digits = max(5, getOption("digits") - 4) print.default(format(object@fit$par, digits = digits), print.gap = 2, quote = FALSE) # Std. Errors: cat("\nStd. Errors:\n ") if (object@fit$params$cond.dist == "QMLE") { cat("robust", "\n") } else { cat("based on Hessian", "\n") } # Error Analysis: digits = max(4, getOption("digits") - 5) fit = object@fit signif.stars = getOption("show.signif.stars") cat("\nError Analysis:\n") printCoefmat(fit$matcoef, digits = digits, signif.stars = signif.stars) # Log Likelihood: cat("\nLog Likelihood:\n ") LLH = - object@fit$value N = NROW(object@data) cat(LLH, " normalized: ", LLH/N, "\n") } # Description: cat("\nDescription:\n ") cat(object@description, "\n") # Return Value: cat("\n") invisible() }) # ------------------------------------------------------------------------------ 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/methods-residuals.R0000644000176000001440000000430511370220736015457 0ustar ripleyusers # 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 ################################################################################ # 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-predict.R0000644000176000001440000002560111370220736015120 0ustar ripleyusers # 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 ################################################################################ # 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, ...) { # 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) { 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: 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)]) } # Return Value: forecast }) ################################################################################ fGarch/R/methods-plot.R0000644000176000001440000003673111370220736014452 0ustar ripleyusers # 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: 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: .interactiveGarchPlot( x, 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"), plotFUN = paste(".plot.garch", 1:13, 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 cecks: 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) } ################################################################################ fGarch/R/methods-formula.R0000644000176000001440000000361411370220736015133 0ustar ripleyusers # 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: 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-fitted.R0000644000176000001440000000406611370220736014747 0ustar ripleyusers # 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 ################################################################################ # 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: # Get numeric vector of fitted, optionally standardized fitted = object@fitted # Get original time series class: ans = slot(object, "data") Name = as.character(fit@formula[2]) attr(ans, "Name") <- Name # Return Value: ans }) ################################################################################ fGarch/R/methods-coef.R0000644000176000001440000000500511370220736014376 0ustar ripleyusers # 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 ################################################################################ # 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/loglik.R0000644000176000001440000001667011370220736013314 0ustar ripleyusers # 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!") } } # ------------------------------------------------------------------------------ .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/loglik-egarch.R0000644000176000001440000000170711370220736014536 0ustar ripleyusers # 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/loglik-aparch.R0000644000176000001440000004107112026020350014526 0ustar ripleyusers # 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/garch-Stats.R0000644000176000001440000001154311370220736014205 0ustar ripleyusers # 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: 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/garch-Spec.R0000644000176000001440000002011711370220736013776 0ustar ripleyusers # 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 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) warnings("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/garch-SolverControl.R0000644000176000001440000001031611370220736015717 0ustar ripleyusers # 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: 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-Solver.R0000644000176000001440000001317011370220736014357 0ustar ripleyusers # 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 ################################################################################ .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/garch-Sim.R0000644000176000001440000001225511370220736013640 0ustar ripleyusers # 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 ################################################################################ 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(class(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/garch-Initialization.R0000644000176000001440000002575511370220736016110 0ustar ripleyusers # 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/garch-Hessian.R0000644000176000001440000001316011777016742014511 0ustar ripleyusers # 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 ################################################################################ .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(diag(h), sparse = TRUE) # Compute forward and backward steps: gp = vector(mode = "numeric", length = n) for(i in 1:n) gp[i] <- f(x + ee[, i], ...) gm = vector(mode = "numeric", length = n) for(i in 1:n) gm[i] <- f(x - ee[, i], ...) H = h %*% t(h) Hm = H Hp = H # Compute "double" forward and backward steps: for(i in 1:n){ for(j in i:n){ Hp[i, j] <- f(x + ee[, i] + ee[, j], ...) Hp[j, i] <- Hp[i, j] Hm[i, j] <- f(x - ee[, i] - ee[, j], ...) Hm[j, i] <- Hm[i, j] } } # Compute the hessian: for(i in 1:n){ for(j in i:n){ H[i, j] = ((Hp[i, j] - gp[i] - gp[j] + fx + fx - gm[i] - gm[j] + Hm[i, j]) / H[i, j]) / 2 H[j, i] = H[i, j] } } # Return Value: return(H) } ################################################################################ fGarch/R/garch-Gradient.R0000644000176000001440000000665611370220736014655 0ustar ripleyusers # 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: # .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/garch-GlobalVars.R0000644000176000001440000000274111370220736015143 0ustar ripleyusers # 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/garch-FitInternal.R0000644000176000001440000003352011370220736015325 0ustar ripleyusers # 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 ################################################################################ .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 if (.params$includes["delta"]) deltainv = 1/fit$par["delta"] else deltainv = 1/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() # 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 = as.formula(paste("~", formula.mean, "+", formula.var)), 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 (class(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-FitFromSpec.R0000644000176000001440000002010611370220736015263 0ustar ripleyusers # 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 ################################################################################ .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/garch-FitFromFormula.R0000644000176000001440000001421111370220736015776 0ustar ripleyusers # 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 = dem2gbp, 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/garch-Distribution.R0000644000176000001440000001327211370220736015567 0ustar ripleyusers # 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/fGarchEnv.R0000644000176000001440000000357511370220736013676 0ustar ripleyusers # 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/fGarch-package.R0000644000176000001440000000230211370220736014601 0ustar ripleyusers # 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 ################################################################################ fGarch/R/dist-stdSlider.R0000644000176000001440000000646611370220736014733 0ustar ripleyusers # 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/dist-stdFit.R0000644000176000001440000001002411370220736014214 0ustar ripleyusers # 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 = try(-sum(log(dist(y, x[1], x[2], x[3]))), silent = TRUE) if (is.na(f) | class(f) == "try-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/dist-std.R0000644000176000001440000000604711370220736013563 0ustar ripleyusers # 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/dist-sstdSlider.R0000644000176000001440000001001611370220736015100 0ustar ripleyusers # 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: 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/dist-sstdFit.R0000644000176000001440000001043111370220736014401 0ustar ripleyusers # 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 = try(-sum(log(dist(y, x[1], x[2], x[3], x[4]))), silent = TRUE) if (is.na(f) | class(f) == "try-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/dist-sstd.R0000644000176000001440000001507411370220736013746 0ustar ripleyusers # 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: 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 # 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: Xi = xi^sign(z) g = 2 / (xi + 1/xi) Probability = Heaviside(z) - sign(z) * g * Xi * pstd(q = -abs(z)/Xi, nu = nu) # Return Value: Probability } # ------------------------------------------------------------------------------ .qsstd <- function(p, 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) # Compute: g = 2 / (xi + 1/xi) sig = sign(p-1/2) Xi = xi^sig p = (Heaviside(p-1/2)-sig*p) / (g*Xi) 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/dist-snormSlider.R0000644000176000001440000000705111370220736015266 0ustar ripleyusers # 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-snormFit.R0000644000176000001440000001022411370220736014562 0ustar ripleyusers # 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 = try(-sum(log(dist(y, x[1], x[2], x[3]))), silent = TRUE) if (is.na(f) | class(f) == "try-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/dist-snorm.R0000644000176000001440000001453711370220736014132 0ustar ripleyusers # 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 # 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: Xi = xi^sign(z) g = 2 / (xi + 1/xi) Probability = Heaviside(z) - sign(z) * g * Xi * pnorm(q = -abs(z)/Xi) # Return Value: Probability } # ------------------------------------------------------------------------------ .qsnorm <- function(p, xi) { # A function implemented by Diethelm Wuertz # 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) sig = sign(p-1/2) Xi = xi^sig p = (Heaviside(p-1/2)-sig*p) / (g*Xi) 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-sgedSlider.R0000644000176000001440000000727411370220736015061 0ustar ripleyusers # 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-sgedFit.R0000644000176000001440000001022511370220736014347 0ustar ripleyusers # 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 = try(-sum(log(dist(y, x[1], x[2], x[3], x[4]))), silent = TRUE) if (is.na(f) | class(f) == "try-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/dist-sged.R0000644000176000001440000001452611370220736013714 0ustar ripleyusers # 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 # 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: Xi = xi^sign(z) g = 2 / (xi + 1/xi) Probability = Heaviside(z) - sign(z) * g * Xi * pged(q = -abs(z)/Xi, nu=nu) # Return Value: Probability } # ------------------------------------------------------------------------------ .qsged <- function(p, 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) # Compute: g = 2 / (xi + 1/xi) sig = sign(p-1/2) Xi = xi^sig p = (Heaviside(p-1/2)-sig*p) / (g*Xi) 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-gedSlider.R0000644000176000001440000000661511370220736014674 0ustar ripleyusers # 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/dist-gedFit.R0000644000176000001440000001021111370220736014157 0ustar ripleyusers # 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 = try(-sum(log(dist(y, x[1], x[2], x[3]))), silent = TRUE) if (is.na(f) | class(f) == "try-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-ged.R0000644000176000001440000000727111370220736013530 0ustar ripleyusers # 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/dist-absMoments.R0000644000176000001440000000643611370220736015103 0ustar ripleyusers # 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: MOMENTS: # absMoments Compute absolute moments of a symmetric distribution ################################################################################ absMoments <- function(n, density = c("dnorm", "dged", "dstd"), ...) { # A function implemented by Diethelm Wuertz # 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 comuted 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 - Student-t Distribution: # Note: nu > 2*n if (density == "dstd" | density == "std") { parm = function(n, nu) { return (beta(1/2+2*n, nu/2-2*n)/beta(1/2, nu/2) * sqrt(nu-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/class-fGARCHSPEC.R0000644000176000001440000000326111370220736014573 0ustar ripleyusers # 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: # fGARCHSPEC S4 fGARCHSPEC Class representation ################################################################################ setClass("fGARCHSPEC", representation( call = "call", formula = "formula", model = "list", presample = "matrix", distribution = "character", rseed = "numeric") ) ################################################################################ fGarch/R/class-fGARCH.R0000644000176000001440000000347411370220736014126 0ustar ripleyusers # 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: 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/NAMESPACE0000644000176000001440000000565112026020142012707 0ustar ripleyusers ################################################ ## import name space ################################################ import("stats") import("graphics") import("methods") import("timeDate") import("timeSeries") import("fBasics") ################################################ ## useDynLib ################################################ useDynLib("fGarch") ################################################ ## S4 classes ################################################ exportClasses("fGARCH", "fGARCHSPEC", "fUGARCHSPEC" ) exportMethods("coef", "fitted", "formula", "plot", "predict", "residuals", "show", "summary", "update" ) ################################################ ## S3 classes ################################################ S3method("volatility", "fGARCH") ################################################ ## functions ################################################ export( ".QMLECondDist", ".aparchLLH.filter", ".aparchLLH.internal", ".aparchLLH.testing", ".dsged", ".dsnorm", ".dsstd", ".garchArgsParser", ".garchFit", ".garchInitParameters", ".garchInitSeries", ".garchKappaFun", ".garchLLH", ".garchModelSeries", ".garchNames", ".garchOptimizeLLH", ".garchOptimizerControl", ".garchRCDAGradient", ".garchRCDAHessian", ".garchRlbfgsb", ".garchRnlminb", ".garchRnm", ".garchRoptimhess", ".garchSetCondDist", ".garchTSHessian", ".gedCondDist", ".gedFit", ".getfGarchEnv", ".gogarchFit", ".hessian2sided", ".interactiveGarchPlot", ".multGarchPlot", ".normCondDist", ".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", ".psged", ".psnorm", ".psstd", ".qqDist", ".qqLine", ".qsged", ".qsnorm", ".qsstd", ".rsged", ".rsnorm", ".rsstd", ".setfGarchEnv", ".sgedCondDist", ".sgedFit", ".snigCondDist", ".snormCondDist", ".snormFit", ".sstdCondDist", ".sstdFit", ".stdCondDist", ".stdFit", ".truePersistence", ".ugarchFit", ".ugarchSpec", "absMoments", "dged", "dsged", "dsnorm", "dsstd", "dstd", "garchFit", "garchFitControl", "garchKappa", "garchSim", "garchSpec", "gedFit", "gedSlider", "pged", "psged", "psnorm", "psstd", "pstd", "qged", "qsged", "qsnorm", "qsstd", "qstd", "rged", "rsged", "rsnorm", "rsstd", "rstd", "sgedFit", "sgedSlider", "snormFit", "snormSlider", "sstdFit", "sstdSlider", "stdFit", "stdSlider" ) fGarch/DESCRIPTION0000644000176000001440000000165112140125641013201 0ustar ripleyusersPackage: fGarch Version: 3010.82 Revision: 5504 Date: 2013-04-30 Title: Rmetrics - Autoregressive Conditional Heteroskedastic Modelling Author: Diethelm Wuertz and Yohan Chalabi with contribution from Michal Miklovic, Chris Boudt, Pierre Chausse and others Depends: R (>= 2.15.0), stats, graphics, methods, timeDate, timeSeries, fBasics (>= 2100.78) Suggests: RUnit, Matrix, fastICA, tcltk Maintainer: Yohan Chalabi Description: Environment for teaching "Financial Engineering and Computational Finance" NOTE: SEVERAL PARTS ARE STILL PRELIMINARY AND MAY BE CHANGED IN THE FUTURE. THIS TYPICALLY INCLUDES FUNCTION AND ARGUMENT NAMES, AS WELL AS DEFAULTS FOR ARGUMENTS AND RETURN VALUES. LazyData: yes License: GPL (>= 2) URL: http://www.rmetrics.org Packaged: 2013-04-30 20:07:14 UTC; yankee NeedsCompilation: yes Repository: CRAN Date/Publication: 2013-05-01 07:44:01 fGarch/ChangeLog0000644000176000001440000001433012140022162013235 0ustar ripleyusers2013-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.