R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("fracdiff-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('fracdiff') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "fracdiff" > > ### * fracdiff > > flush(stderr()); flush(stdout()) > > ### Name: fracdiff > ### Title: ML Estimates for Fractionally-Differenced ARIMA (p,d,q) models > ### Aliases: fracdiff > ### Keywords: ts > > ### ** Examples > > ts.test <- fracdiff.sim( 5000, ar = .2, ma = -.4, d = .3) > fracdiff( ts.test$series, nar = length(ts.test$ar), nma = length(ts.test$ma)) $log.likelihood [1] -7228.933 $d [1] 0.2901102 $ar [1] 0.2095184 $ma [1] -0.4063822 $covariance.dpq d ar1 ma1 d 0.0002766653 -0.0003901960 -0.0001066595 ar1 -0.0003901960 0.0011602590 0.0006301288 ma1 -0.0001066595 0.0006301288 0.0005909529 $stderror.dpq [1] 0.01663326 0.03406257 0.02430952 $correlation.dpq [,1] [,2] [,3] [1,] 1.0000000 -0.6886966 -0.2637824 [2,] -0.6886966 1.0000000 0.7609838 [3,] -0.2637824 0.7609838 1.0000000 $h [1] 7.617972e-05 $d.tol [1] 0.0001220703 $M [1] 100 $hessian.dpq d ar1 ma1 d -9910.447 -5610.440 4193.661 ar1 -5610.440 -5223.828 4557.517 ma1 4193.661 4557.517 -5794.926 $length.w [1] 25014 > > > > cleanEx(); ..nameEx <- "fracdiff.sim" > > ### * fracdiff.sim > > flush(stderr()); flush(stdout()) > > ### Name: fracdiff.sim > ### Title: Simulate fractional ARIMA Time Series > ### Aliases: fracdiff.sim > ### Keywords: ts > > ### ** Examples > > ## Pretty (too) short to "see" the long memory > fracdiff.sim(100, ar = .2, ma = .4, d = .3) $series [1] 0.23881111 -0.77058664 1.56944453 0.46955593 -0.65866704 0.56022603 [7] 0.85633192 0.75999222 -0.07255621 1.70478585 0.72601126 -0.26854347 [13] -1.95074069 1.14336954 0.07771185 0.09074226 1.05358810 1.02797912 [19] 0.87902437 1.25612190 1.19750080 0.54560747 -1.54212813 0.83600496 [25] 0.20241969 0.07599861 -1.26409645 -0.42760580 0.42172169 1.41041045 [31] 0.09498683 0.57956243 0.17870265 -1.16027485 -0.34690184 -0.37167933 [37] -0.07708237 1.08597823 0.87228625 0.02794560 -0.07612007 0.84521057 [43] 0.76814146 -0.43174739 -0.53052875 0.46220226 0.89671644 0.08873311 [49] 1.06826642 0.67098987 -0.31114482 0.56790988 -0.88135265 1.55332601 [55] 2.24205552 0.08227386 -0.64678862 0.84516271 0.17664792 2.68040789 [61] 0.46998021 1.17262546 0.56067850 -0.24056761 0.58644768 -1.41504901 [67] 1.65153451 0.47986235 2.50314512 1.02168014 -0.13577999 1.09144770 [73] -0.41997327 -0.86549643 0.53439485 -0.18334757 0.20916555 0.28550067 [79] -0.36913337 -0.40530841 -0.02448992 1.28144130 -1.29475686 0.67357076 [85] 0.48351171 1.24807387 -0.00811021 0.63228443 0.56244719 -0.23205392 [91] 1.45339503 1.51957061 1.16184551 2.10370810 1.21237933 -0.60158236 [97] -0.06402830 -0.80757723 -0.20958069 -0.41743316 $ar [1] 0.2 $ma [1] 0.4 $d [1] 0.3 $mu [1] 0 $n.start [1] 6 > > ## longer with "extreme" ar: > r <- fracdiff.sim(n=1500, ar=-0.9, d= 0.3) > plot(as.ts(r$series)) > > > > cleanEx(); ..nameEx <- "fracdiff.var" > > ### * fracdiff.var > > flush(stderr()); flush(stdout()) > > ### Name: fracdiff.var > ### Title: Recompute Covariance Estimate for fracdiff > ### Aliases: fracdiff.var > ### Keywords: ts > > ### ** Examples > > ## Generate a fractionally-differenced ARIMA(1,d,1) model : > ts.test <- fracdiff.sim(10000, ar = .2, ma = .4, d = .3) > ## estimate the parameters in an ARIMA(1,d,1) model for the simulated series > fd.out <- fracdiff(ts.test$ser, nar= 1, nma = 1) > > ## Modify the covariance estimate by changing the finite-difference interval > fracdiff.var(ts.test$series, fd.out, h = .0001) $log.likelihood [1] -14310.08 $d [1] 0.2575488 $ar [1] 0.1330638 $ma [1] 0.2784551 $covariance.dpq d ar1 ma1 d 0.0002518780 0.000668328 0.0009272233 ar1 0.0006683280 0.005961131 0.0065198777 ma1 0.0009272233 0.006519878 0.0074432007 $stderror.dpq [1] 0.01587066 0.07720836 0.08627399 $correlation.dpq [,1] [,2] [,3] [1,] 1.0000000 0.545419 0.6771882 [2,] 0.5454190 1.000000 0.9788029 [3,] 0.6771882 0.978803 1.0000000 $h [1] 1e-04 $d.tol [1] 0.0001220703 $M [1] 100 $hessian.dpq d ar1 ma1 d -18662.02 -10738.25 11730.97 ar1 -10738.25 -10178.24 10253.33 ma1 11730.97 10253.33 -10577.13 $length.w [1] 50014 > > > > ### *