knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

The following simulations demonstrate that the implemented tests do what they are supposed. For this purpose, we simulate critical values based on our implemented tests and compare them to the critical values stated by the authors of the tests. To save computing time we consider a sample size of 100 observations and M=10,000 replications. As M is typically chosen to be larger (50,000 or even higher) when simulating critical values we expect some deviations between our simulated critical values and those by the authors. These should, however, be rather small.

Cusum test

Following @leybourne2007cusum we perform the following simulation for the cusum test

results_cusum<-vector(mode="list")
set.seed(410)
x=cumsum(rnorm(100))
trend = c("none", "linear")
for(a in 1:2){
  tr=trend[a]
  true=cusum_test(x,trend=tr)
  simu=cusum_test(x,trend=tr,simu=1)
  results_cusum[[a]]=true/simu
}

This takes approximately thirty minutes and yields the following list of results depicting the ratio between our simulated critical values and those simulated by the authors

> results_cusum
[[1]]
            90%       95%       99%
Lower 0.9615506 0.9477438 0.9389883
Upper 0.9988600 0.9899724 0.9300507

[[2]]
            90%      95%      99%
Lower 1.0050942 1.011183 1.010665
Upper 0.9995166 1.007026 1.018699

As can be seen, our simulated critical values and those by the authors coincide for the standard cusum test. Minor differences for very extreme quantile as the 99 percent quantile are due to the fact that our M is rather small. We should further note that we did not compare quantiles for the modified cusum test of @sibbertsen2009testing as these are based on T=10,000 so that we expect major differences when considering a small sample of T=100.

LBI test

Following @busetti2004tests we perform the following simulation for the LBI test

results_LBI<-vector(mode="list")
set.seed(410)
x=rnorm(100)
trend = c("none", "linear")
statistic = c("mean", "max", "exp")
q=1
for(a in 1:2){
  tr=trend[a]
  for(b in 1:3){
    st=statistic[b]
    true=LBI_test(x,trend=tr,statistic=st)
    simu=LBI_test(x,trend=tr,statistic=st,simu=1)
    results_LBI[[q]]=true/simu
    q=q+1
  }
}

This takes approximately five minutes and yields the following list of results depicting the ratio between our simulated critical values and those simulated by the authors

> results_LBI
[[1]]
                                          90%      95%      99%
Against change from I(0) to I(1)    0.9903047 0.996316 1.008091
Against change from I(1) to I(0)    1.0398047 1.040524 1.084773
Against change in unknown direction 0.9917469 1.022388 1.017279

[[2]]
                                          90%       95%       99%
Against change from I(0) to I(1)    0.9693076 0.9605230 0.9683209
Against change from I(1) to I(0)    1.0320189 1.0253584 1.0323698
Against change in unknown direction 0.9961075 0.9981334 0.9916528

[[3]]
                                          90%      95%       99%
Against change from I(0) to I(1)    0.9981339 0.996351 1.0198090
Against change from I(1) to I(0)    1.0217925 1.018093 1.0213628
Against change in unknown direction 0.9961721 1.034169 0.9981803

[[4]]
                                         90%       95%       99%
Against change from I(0) to I(1)    1.010792 0.9864122 0.9776112
Against change from I(1) to I(0)    1.045760 1.0396506 0.9881523
Against change in unknown direction 1.019737 0.9960209 0.9743066

[[5]]
                                          90%       95%      99%
Against change from I(0) to I(1)    1.0065405 0.9817173 1.017411
Against change from I(1) to I(0)    1.0351170 1.0069331 1.006393
Against change in unknown direction 0.9889146 1.0050087 1.007362

[[6]]
                                          90%       95%       99%
Against change from I(0) to I(1)    0.9767617 0.9678892 0.9703013
Against change from I(1) to I(0)    1.0214279 1.0157512 1.0219212
Against change in unknown direction 0.9860583 0.9782866 0.9875743

As can be seen, our simulated critical values and those by the authors coincide.

LKSN test

Following @leybourne2003tests we perform the following simulation for the LKSN test

results_lksn<-vector(mode="list")
set.seed(410)
x=rnorm(100)
trend = c("none", "linear")
for(a in 1:2){
  tr=trend[a]
  true=LKSN_test(x,trend=tr)
  simu=LKSN_test(x,trend=tr,simu=1)
  results_lksn[[a]]=true/simu
}

This takes approximately three hours and yields the following list of results depicting the ratio between our simulated critical values and those simulated by the authors

> results_lksn
[[1]]
                                          90%       95%
Against change from I(0) to I(1)    0.9906178 0.9973267
Against change from I(1) to I(0)    0.9935230 0.9968259
Against change in unknown direction 0.9929663 0.9925711

[[2]]
                                          90%       95%
Against change from I(0) to I(1)    0.9914396 0.9967095
Against change from I(1) to I(0)    0.9890775 0.9958796
Against change in unknown direction 0.9988733 1.0011454

As can be seen, our simulated critical values and those by the authors coincide.

Ratio test

Following @harvey2006modified we perform the following simulation for the ratio test

results_ratio<-vector(mode="list")
set.seed(410)
x=rnorm(100)
trend = c("none", "linear")
statistic = c("mean", "max", "exp")
type = c("BT", "LT", "HLT","HLTmin")
q=1
for(a in 1:2){
  tr=trend[a]
  for(b in 1:3){
    st=statistic[b]
    for(c in 1:4){
      ty=type[c]
      true=ratio_test(x,trend=tr,statistic=st,type=ty)
      simu=ratio_test(x,trend=tr,statistic=st,type=ty,simu=1)
      results_ratio[[q]]=true/simu
      q=q+1
    }
  }
}

This takes approximately three hours and yields the following list of results depicting the ratio between our simulated critical values and those simulated by the authors

> results_ratio
[[1]]
                                          90%       95%      99%
Against change from I(0) to I(1)    1.0104250 1.0106469 1.014149
Against change from I(1) to I(0)    0.9735059 0.9767644 1.035246
Against change in unknown direction 0.9931738 1.0049371 1.017751

[[2]]
                                         90%      95%      99%
Against change from I(0) to I(1)    1.016274 1.014215 1.033000
Against change from I(1) to I(0)    1.018238 1.007246 1.017004
Against change in unknown direction 1.012034 1.006302 1.044284

[[3]]
                                          90%       95%       99%
Against change from I(0) to I(1)    1.0111421 1.0064878 1.0347122
Against change from I(1) to I(0)    1.0056987 0.9826152 0.9939418
Against change in unknown direction 0.9954995 1.0192008 1.0414741

[[4]]
                                         90%       95%       99%
Against change from I(0) to I(1)    1.018239 1.0086119 0.9978576
Against change from I(1) to I(0)    0.995950 0.9960618 0.9913083
Against change in unknown direction 1.002817 1.0147989 1.0146256

[[5]]
                                          90%       95%      99%
Against change from I(0) to I(1)    0.9925191 1.0225850 1.072802
Against change from I(1) to I(0)    1.0129890 0.9743272 1.014282
Against change in unknown direction 0.9994110 1.0159194 1.029520

[[6]]
                                          90%       95%       99%
Against change from I(0) to I(1)    0.9978642 1.0084483 1.0370896
Against change from I(1) to I(0)    0.9901502 0.9767408 0.9480799
Against change in unknown direction 0.9978088 0.9940026 0.9781581

[[7]]
                                         90%      95%      99%
Against change from I(0) to I(1)    1.002980 1.019833 1.043573
Against change from I(1) to I(0)    1.004153 1.021031 1.048013
Against change in unknown direction 1.021044 1.017115 1.020734

[[8]]
                                          90%       95%       99%
Against change from I(0) to I(1)    0.9643583 0.9907442 0.9704638
Against change from I(1) to I(0)    1.0132629 1.0065195 1.0051733
Against change in unknown direction 0.9950285 1.0055013 0.9772474

[[9]]
                                         90%      95%       99%
Against change from I(0) to I(1)    1.010083 1.037978 1.0377896
Against change from I(1) to I(0)    1.009392 1.004364 1.0076891
Against change in unknown direction 1.021443 1.033268 0.9971142

[[10]]
                                         90%       95%       99%
Against change from I(0) to I(1)    1.040852 1.0249551 1.0178647
Against change from I(1) to I(0)    1.007570 1.0079394 1.0053984
Against change in unknown direction 1.018683 0.9988347 0.9757091

[[11]]
                                         90%      95%      99%
Against change from I(0) to I(1)    1.020242 1.032039 1.082446
Against change from I(1) to I(0)    1.003868 0.985227 1.003126
Against change in unknown direction 1.003696 0.994087 1.035095

[[12]]
                                         90%      95%      99%
Against change from I(0) to I(1)    1.010254 1.035360 1.036488
Against change from I(1) to I(0)    1.016027 1.013850 1.056750
Against change in unknown direction 1.027942 1.008848 1.042858

[[13]]
                                         90%      95%       99%
Against change from I(0) to I(1)    1.006230 1.003591 0.9981193
Against change from I(1) to I(0)    1.005268 1.006165 1.0229856
Against change in unknown direction 1.008271 1.006686 0.9943168

[[14]]
                                         90%       95%       99%
Against change from I(0) to I(1)    1.006885 1.0300327 1.0151076
Against change from I(1) to I(0)    1.005847 0.9865353 0.9610391
Against change in unknown direction 1.012352 1.0084214 0.9848723

[[15]]
                                          90%       95%       99%
Against change from I(0) to I(1)    1.0004917 0.9892640 1.0036570
Against change from I(1) to I(0)    0.9894258 0.9677367 0.9821644
Against change in unknown direction 0.9810083 0.9734070 1.0050720

[[16]]
                                          90%      95%      99%
Against change from I(0) to I(1)    1.0039238 1.023166 1.035995
Against change from I(1) to I(0)    0.9953004 1.000251 1.006698
Against change in unknown direction 1.0129828 1.016836 1.012524

[[17]]
                                          90%       95%       99%
Against change from I(0) to I(1)    0.9888824 0.9773667 0.9627482
Against change from I(1) to I(0)    0.9842887 0.9874578 1.0012626
Against change in unknown direction 0.9801884 0.9766469 0.9736113

[[18]]
                                          90%      95%      99%
Against change from I(0) to I(1)    1.0117644 1.024351 1.000546
Against change from I(1) to I(0)    0.9943186 1.000496 1.031211
Against change in unknown direction 1.0136303 1.009115 1.007792

[[19]]
                                          90%       95%       99%
Against change from I(0) to I(1)    1.0238111 1.0084094 0.9897555
Against change from I(1) to I(0)    0.9938434 0.9969527 1.0145038
Against change in unknown direction 1.0020532 0.9977881 1.0073695

[[20]]
                                         90%       95%      99%
Against change from I(0) to I(1)    1.008649 1.0141979 1.007053
Against change from I(1) to I(0)    1.005176 0.9983218 1.002269
Against change in unknown direction 1.004947 1.0113122 0.993839

[[21]]
                                          90%      95%       99%
Against change from I(0) to I(1)    1.0172671 1.026730 0.9575499
Against change from I(1) to I(0)    0.9966601 1.013493 1.0487057
Against change in unknown direction 1.0216434 1.024416 0.9851763

[[22]]
                                          90%      95%       99%
Against change from I(0) to I(1)    1.0203230 1.036651 1.0565788
Against change from I(1) to I(0)    0.9910996 1.000276 0.9587569
Against change in unknown direction 1.0152079 1.031090 0.9877004

[[23]]
                                          90%      95%       99%
Against change from I(0) to I(1)    1.0205737 1.012399 1.0163757
Against change from I(1) to I(0)    0.9856524 1.001397 1.0319036
Against change in unknown direction 1.0049035 1.045185 0.9829798

[[24]]
                                         90%       95%       99%
Against change from I(0) to I(1)    1.008942 0.9947827 1.0609302
Against change from I(1) to I(0)    1.000578 1.0146001 0.9731082
Against change in unknown direction 1.005835 1.0230188 1.0283740

As can be seen, our critical values and those by the authors coincide for all of the different modifications of the ratio test.

MR test

Finally, we compare the critical values of the MR_test function with those by @martins2014testing. Here, we considered a sample size of 750 to show the procedures also for larger sample sizes do what they are supposed to.

results_MR<-vector(mode="list")
set.seed(410)
x=rnorm(750)
trend = c("none", "linear")
q=1
for(a in 1:2){
  tr=trend[a]
  true=MR_test(x,trend=tr)
  simu=MR_test(x,trend=tr,simu=1)
  results_MR[[q]]=true/simu
  q=q+1
  print(a)
}

This takes approximately twelve hours and yields the following list of results depicting the ratio between our simulated critical values and those simulated by the authors

> results_MR
[[1]]
                                         90%      95%       99%
Against increase in memory          1.052064 1.024713 0.9852241
Against decrease in memory          1.030878 1.003282 1.0059825
Against change in unknown direction 1.009281 0.990159 0.9749962

[[2]]
                                         90%      95%       99%
Against increase in memory          1.045056 1.034517 1.0357703
Against decrease in memory          1.043284 1.032554 0.9794880
Against change in unknown direction 1.030771 1.005586 0.9714673

Again, the critical values coincide.

References



KaiWenger/memochange documentation built on Jan. 2, 2025, 7:46 p.m.