kerseg1 {kerSeg} | R Documentation |
Kernel-based change-point detection for single change-point alternatives
Description
This function finds a break point in the sequence where the underlying distribution changes.
Usage
kerseg1(n, K, r1=1.2, r2=0.8, n0=0.05*n, n1=0.95*n,
pval.appr=TRUE, skew.corr=TRUE, pval.perm=FALSE, B=100)
Arguments
n |
The number of observations in the sequence. |
K |
The kernel matrix of observations in the sequence. |
r1 |
The constant in the test statistics |
r2 |
The constant in the test statistics |
n0 |
The starting index to be considered as a candidate for the change-point. |
n1 |
The ending index to be considered as a candidate for the change-point. |
pval.appr |
If it is TRUE, the function outputs the p-value approximation based on asymptotic properties. |
skew.corr |
This argument is useful only when pval.appr=TRUE. If skew.corr is TRUE, the p-value approximation would incorporate skewness correction. |
pval.perm |
If it is TRUE, the function outputs the p-value from doing B permutations, where B is another argument that you can specify. Doing permutation could be time consuming, so use this argument with caution as it may take a long time to finish the permutation. |
B |
This argument is useful only when pval.perm=TRUE. The default value for B is 100. |
Value
Returns a list stat
containing the each scan statistic, tauhat
containing the estimated location of change-point, appr
containing the approximated p-values of the fast tests when argument ‘pval.appr’ is TRUE, and perm
containing the permutation p-values of the fast tests and GKCP when argument ‘pval.perm’ is TRUE. See below for more details.
seq |
A vector of each scan statistic (standardized counts). |
Zmax |
The test statistics (maximum of the scan statistics). |
tauhat |
An estimate of the location of the change-point. |
fGKCP1_bon |
The p-value of |
fGKCP1_sim |
The p-value of |
fGKCP2_bon |
The p-value of |
fGKCP2_sim |
The p-value of |
GKCP |
The p-value of GKCP obtained by the random permutation. |
See Also
kerSeg-package
, kerseg1
, gaussiankernel
, kerseg2
Examples
## Sequence 1: change in the mean in the middle of the sequence.
d = 50
mu = 2
tau = 25
n = 50
set.seed(1)
y = rbind(matrix(rnorm(d*tau),tau), matrix(rnorm(d*(n-tau),mu/sqrt(d)), n-tau))
K = gaussiankernel(y) # Gaussian kernel matrix
a = kerseg1(n, K, pval.perm=TRUE, B=1000)
# output results based on the permutation and the asymptotic results.
# the scan statistics can be found in a$scanZ.
# the approximated p-values can be found in a$appr.
# the permutation p-values can be found in a$perm.
## Sequence 2: change in both the mean and variance away from the middle of the sequence.
d = 50
mu = 2
sigma = 0.7
tau = 35
n = 50
set.seed(1)
y = rbind(matrix(rnorm(d*tau),tau), matrix(rnorm(d*(n-tau),mu/sqrt(d),sigma), n-tau))
K = gaussiankernel(y)
a = kerseg1(n, K, pval.perm=TRUE, B=1000)