kerseg2 {kerSeg} | R Documentation |
Kernel-based change-point detection for changed-interval alternatives
Description
This function finds an interval in the sequence where their underlying distribution differs from the rest of the sequence.
Usage
kerseg2(n, K, r1=1.2, r2=0.8, l0=0.05*n, l1=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 |
l0 |
The minimum length of the interval to be considered as a changed interval. |
l1 |
The maximum length of the interval to be considered as a changed interval. |
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 changed-interval, 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 matrix of each scan statistic (standardized counts). |
Zmax |
The test statistics (maximum of the scan statistics). |
tauhat |
An estimate of the two ends of the changed-interval. |
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
, kerseg2
, gaussiankernel
, kerseg1
Examples
## Sequence 3: change in both the mean and variance happens on an interval.
d = 50
mu = 2
sigma = 0.5
tau1 = 25
tau2 = 35
n = 50
set.seed(1)
y1 = matrix(rnorm(d*tau1),tau1)
y2 = matrix(rnorm(d*(tau2-tau1),mu/sqrt(d),sigma), tau2-tau1)
y3 = matrix(rnorm(d*(n-tau2)), n-tau2)
y = rbind(y1, y2, y3)
K = gaussiankernel(y)
a = kerseg2(n, K, pval.perm=TRUE, B=1000)