R Under development (unstable) (2024-01-31 r85845 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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 an HTML browser interface to help. Type 'q()' to quit R. > library(fracdiff) > if(FALSE) # manual testing + library(fracdiff, lib="/u/maechler/R/Pkgs/fracdiff.Rcheck") > > .ptime <- proc.time() > ## Test if the default 'n.start' is ok, i.e., if the > ## "burn in" period is long enough : > > n <- 512 > > set.seed(101) ; ok <- TRUE > for(i in 1:2000) { + r <- fracdiff.sim(n, ar = -0.9, ma = NULL, d = 0.3)$series + if(max(abs(r)) > 10) { + cat("OOps : indices ",str(ibig <- which(big <- abs(r) > 10)), + "\n are > 10\n") + if(any(ibig < 200) && (length(ibig) > 5 || abs(r)[big] > 20)) { + cat("Some have index < 200 --> BREAK\n") + ok <- FALSE + break + } + } + if(i %% 100 == 0) { + cat(i,": ACF = \n") + print(acf(r, plot=FALSE)) + } + } 100 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.810 0.793 -0.668 0.635 -0.542 0.516 -0.446 0.445 -0.395 0.401 11 12 13 14 15 16 17 18 19 20 21 -0.361 0.374 -0.332 0.329 -0.304 0.319 -0.312 0.319 -0.289 0.314 -0.300 22 23 24 25 26 27 0.302 -0.288 0.282 -0.256 0.235 -0.218 int 443 OOps : indices are > 10 200 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.792 0.775 -0.613 0.560 -0.421 0.366 -0.267 0.228 -0.148 0.124 11 12 13 14 15 16 17 18 19 20 21 -0.068 0.047 0.004 0.000 0.040 -0.027 0.041 -0.013 0.036 0.001 -0.014 22 23 24 25 26 27 0.058 -0.056 0.079 -0.068 0.085 -0.080 300 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.842 0.817 -0.700 0.666 -0.572 0.546 -0.456 0.445 -0.385 0.386 11 12 13 14 15 16 17 18 19 20 21 -0.336 0.342 -0.289 0.303 -0.261 0.266 -0.226 0.227 -0.185 0.199 -0.165 22 23 24 25 26 27 0.172 -0.136 0.135 -0.103 0.121 -0.104 400 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.864 0.832 -0.739 0.698 -0.624 0.567 -0.498 0.443 -0.372 0.341 11 12 13 14 15 16 17 18 19 20 21 -0.286 0.254 -0.212 0.157 -0.115 0.066 -0.039 0.013 0.011 -0.013 0.020 22 23 24 25 26 27 -0.035 0.029 -0.032 0.026 -0.053 0.051 500 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.766 0.729 -0.578 0.549 -0.427 0.396 -0.289 0.277 -0.196 0.189 11 12 13 14 15 16 17 18 19 20 21 -0.123 0.131 -0.090 0.116 -0.084 0.103 -0.042 0.060 -0.036 0.055 -0.043 22 23 24 25 26 27 0.041 -0.032 0.033 -0.056 0.063 -0.092 600 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.822 0.765 -0.634 0.607 -0.513 0.478 -0.384 0.357 -0.295 0.283 11 12 13 14 15 16 17 18 19 20 21 -0.220 0.194 -0.153 0.136 -0.089 0.072 -0.044 0.028 0.000 -0.006 0.039 22 23 24 25 26 27 -0.053 0.082 -0.098 0.110 -0.097 0.086 700 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.855 0.824 -0.724 0.698 -0.627 0.610 -0.554 0.516 -0.466 0.441 11 12 13 14 15 16 17 18 19 20 21 -0.391 0.359 -0.302 0.275 -0.234 0.233 -0.204 0.205 -0.197 0.198 -0.187 22 23 24 25 26 27 0.186 -0.181 0.169 -0.165 0.172 -0.180 800 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.809 0.748 -0.649 0.598 -0.546 0.510 -0.450 0.414 -0.373 0.337 11 12 13 14 15 16 17 18 19 20 21 -0.298 0.274 -0.249 0.238 -0.201 0.172 -0.144 0.138 -0.113 0.090 -0.061 22 23 24 25 26 27 0.043 -0.045 0.040 -0.051 0.052 -0.035 900 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.834 0.824 -0.696 0.679 -0.572 0.562 -0.473 0.460 -0.375 0.371 11 12 13 14 15 16 17 18 19 20 21 -0.307 0.318 -0.261 0.262 -0.202 0.200 -0.136 0.139 -0.086 0.097 -0.034 22 23 24 25 26 27 0.036 0.012 0.002 0.037 -0.011 0.037 1000 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.844 0.813 -0.699 0.668 -0.594 0.565 -0.502 0.477 -0.426 0.386 11 12 13 14 15 16 17 18 19 20 21 -0.343 0.319 -0.299 0.270 -0.233 0.193 -0.153 0.127 -0.104 0.093 -0.083 22 23 24 25 26 27 0.086 -0.083 0.059 -0.048 0.036 -0.035 1100 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.713 0.713 -0.547 0.555 -0.422 0.443 -0.358 0.368 -0.297 0.289 11 12 13 14 15 16 17 18 19 20 21 -0.241 0.238 -0.152 0.145 -0.092 0.124 -0.075 0.099 -0.056 0.078 -0.027 22 23 24 25 26 27 0.022 -0.013 0.045 -0.024 0.042 -0.059 1200 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.785 0.726 -0.594 0.522 -0.445 0.402 -0.366 0.349 -0.313 0.297 11 12 13 14 15 16 17 18 19 20 21 -0.231 0.204 -0.124 0.107 -0.052 0.002 0.064 -0.088 0.120 -0.106 0.128 22 23 24 25 26 27 -0.150 0.166 -0.183 0.217 -0.231 0.256 1300 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.830 0.830 -0.705 0.700 -0.593 0.575 -0.487 0.468 -0.383 0.361 11 12 13 14 15 16 17 18 19 20 21 -0.287 0.289 -0.229 0.235 -0.173 0.176 -0.147 0.141 -0.094 0.077 -0.034 22 23 24 25 26 27 0.025 0.021 -0.013 0.045 -0.030 0.057 1400 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.841 0.800 -0.702 0.662 -0.587 0.546 -0.467 0.428 -0.372 0.360 11 12 13 14 15 16 17 18 19 20 21 -0.315 0.293 -0.251 0.254 -0.234 0.233 -0.220 0.222 -0.220 0.219 -0.204 22 23 24 25 26 27 0.194 -0.167 0.181 -0.157 0.162 -0.151 1500 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.807 0.811 -0.670 0.677 -0.562 0.551 -0.442 0.421 -0.338 0.321 11 12 13 14 15 16 17 18 19 20 21 -0.258 0.259 -0.224 0.225 -0.197 0.189 -0.178 0.174 -0.179 0.180 -0.191 22 23 24 25 26 27 0.179 -0.188 0.169 -0.166 0.142 -0.121 1600 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.825 0.800 -0.662 0.629 -0.527 0.487 -0.409 0.378 -0.303 0.275 11 12 13 14 15 16 17 18 19 20 21 -0.195 0.181 -0.140 0.154 -0.129 0.141 -0.110 0.108 -0.078 0.070 -0.047 22 23 24 25 26 27 0.046 -0.001 0.003 0.061 -0.042 0.084 1700 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.830 0.798 -0.675 0.624 -0.527 0.487 -0.416 0.391 -0.325 0.297 11 12 13 14 15 16 17 18 19 20 21 -0.252 0.210 -0.161 0.130 -0.108 0.093 -0.076 0.081 -0.068 0.087 -0.054 22 23 24 25 26 27 0.041 -0.025 0.017 0.007 -0.001 0.028 1800 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.704 0.679 -0.530 0.486 -0.400 0.381 -0.307 0.314 -0.271 0.273 11 12 13 14 15 16 17 18 19 20 21 -0.257 0.241 -0.230 0.223 -0.166 0.185 -0.146 0.151 -0.121 0.136 -0.120 22 23 24 25 26 27 0.154 -0.118 0.142 -0.107 0.095 -0.074 1900 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.856 0.816 -0.685 0.630 -0.535 0.493 -0.444 0.427 -0.400 0.384 11 12 13 14 15 16 17 18 19 20 21 -0.361 0.348 -0.326 0.304 -0.280 0.252 -0.203 0.172 -0.123 0.103 -0.061 22 23 24 25 26 27 0.073 -0.040 0.042 -0.005 -0.016 0.051 2000 : ACF = Autocorrelations of series 'r', by lag 0 1 2 3 4 5 6 7 8 9 10 1.000 -0.824 0.804 -0.640 0.620 -0.508 0.495 -0.390 0.380 -0.280 0.281 11 12 13 14 15 16 17 18 19 20 21 -0.208 0.223 -0.160 0.173 -0.133 0.160 -0.140 0.172 -0.137 0.162 -0.112 22 23 24 25 26 27 0.140 -0.111 0.170 -0.159 0.217 -0.196 > if(!ok) { + cat("i=",i," gave series \n") + print(head(r)) ; cat(".......\n") + plot(as.ts(r)) ## clearly did show problem {when we had bug} + } > > ## Try to find an example more quickly with setting `one seed': > .AR <- c(-.75, -.9) > .MA <- c(0.2, 0.1) > ok <- TRUE > set.seed(1) > r0 <- fracdiff.sim(100, d = 0.3) > r1 <- fracdiff.sim(100, ar = .AR, d = 0.25) > r2 <- fracdiff.sim(100, ar = .AR, ma = .MA, d = 0.2) > for(i in 1:1000) { + set.seed(1)# yes; identical ones + r0i <- fracdiff.sim(100, d = 0.3) + r1i <- fracdiff.sim(100, ar = .AR, d = 0.25) + r2i <- fracdiff.sim(100, ar = .AR, ma = .MA, d = 0.2) + stopifnot(identical(r0, r0i), + identical(r1, r1i), + identical(r2, r2i)) + } > > ## Last Line: > cat('Time elapsed: ', proc.time() - .ptime,'\n') Time elapsed: 1.99 0.05 2.03 NA NA > > proc.time() user system elapsed 2.17 0.14 2.29