# NOT RUN {
# set model parameters
T <- 500
d <- 0.2
set.seed(410)
# generate a fractionally integrated (long-memory) time series
tseries <- fracdiff::fracdiff.sim(n=T, d=d)$series
# generate a fractionally integrated (long-memory) time series
# with a change in mean in the middle of the series
changep <- c(rep(0,T/2), rep(1,T/2))
tseries2 <- tseries+changep
# estimate the long-memory parameter of both series via local
# Whittle approach. The bandwidth to estimate d is chosen
# as T^0.65, which is usual in literature
d_est <- LongMemoryTS::local.W(tseries, m=floor(1+T^0.65))$d
d_est2 <- LongMemoryTS::local.W(tseries2, m=floor(1+T^0.65))$d
# perform the different types of the test on both time series
CUSUMfixed(tseries, d=d_est, procedure="CUSUMfixedb_typeA", bandw=0.1)
CUSUMfixed(tseries, d=d_est, procedure="CUSUMfixedb_typeB", bandw=0.1)
CUSUMfixed(tseries, d=d_est, procedure="CUSUMfixedm_typeA", bandw=10)
CUSUMfixed(tseries, d=d_est, procedure="CUSUMfixedm_typeB", bandw=10)
CUSUMfixed(tseries2, d=d_est2, procedure="CUSUMfixedb_typeA", bandw=0.1)
CUSUMfixed(tseries2, d=d_est2, procedure="CUSUMfixedb_typeB", bandw=0.1)
CUSUMfixed(tseries2, d=d_est2, procedure="CUSUMfixedm_typeA", bandw=10)
CUSUMfixed(tseries2, d=d_est2, procedure="CUSUMfixedm_typeB", bandw=10)
# For the series with no change in mean all tests do not reject
# the null hypothesis of a constant mean across time at
# any reasonable significance level.
# For the series with a change in mean all tests reject the
# null hypothesis at a 1% significance level.
# }
Run the code above in your browser using DataLab