Simulates multiple realizations of the CUSUM statistic.
sim_Vn_stat(size, kn = function(n) { 1 }, tau = 0,
use_kernel_var = FALSE, kernel = "ba", bandwidth = "and",
n = 500, gen_func = rnorm, args = NULL, parallel = FALSE)
Number of realizations to simulate
A function returning a positive integer that is used in the definition of the trimmed CUSUSM statistic effectively setting the bounds over which the maximum is taken
The weighting parameter for the weighted CUSUM statistic (defaults to zero for no weighting)
Set to TRUE
to use kernel-based long-run
variance estimation (FALSE
means this is not
employed)
If character, the identifier of the kernel function as used in
the cointReg (see documentation for
cointReg::getLongRunVar
); if function, the kernel
function to be used for long-run variance estimation (default
is the Bartlett kernel in cointReg); this parameter
has no effect if use_kernel_var
is FALSE
If character, the identifier of how to compute the bandwidth
as defined in the cointReg package (see
documentation for cointReg::getLongRunVar
); if
function, a function to use for computing the bandwidth; if
numeric, the bandwidth to use (the default behavior is to
use the method described in andrews91bCPAT,
as used in cointReg); this parameter has no effect if
use_kernel_var
is FALSE
The sample size for each realization
The function generating the random sample from which the statistic is computed
A list of arguments to be passed to gen_func
Whether to use the foreach and doParallel packages to parallelize simulation (which needs to be initialized in the global namespace before use)
A vector of simulated realizations of the CUSUM statistic
This differs from sim_Vn()
in that the long-run variance is estimated
with this function, while sim_Vn()
assumes the long-run variance is
known. Estimation can be done in a variety of ways. If use_kernel_var
is set to TRUE
, long-run variance estimation using kernel-based
techniques will be employed; otherwise, a technique resembling standard
variance estimation will be employed. Any technique employed, though, will
account for the potential break points, as described in
horvathricemiller19;textualCPAT. See the documentation for
stat_Vn
for more details.
The parameters kernel
and bandwidth
control parameters for
long-run variance estimation using kernel methods. These parameters will be
passed directly to stat_Vn
.
Versions of the CUSUM statistic, such as the weighted or trimmed statistics,
can be simulated with the function by passing values to kn
and
tau
; again, see the documentation for stat_Vn
.
# NOT RUN {
CPAT:::sim_Vn_stat(100)
CPAT:::sim_Vn_stat(100, kn = function(n) {floor(0.1 * n)}, tau = 1/3,
use_kernel_var = TRUE, gen_func = CPAT:::rchangepoint,
args = list(changepoint = 250, mean2 = 1))
# }
Run the code above in your browser using DataLab