kcpRS_workflow {kcpRS} | R Documentation |
KCP on the Running Statistics Workflow
Description
Any of the four basic running statistics (i.e., running means, running variances, running autocorrelations and running correlations) or a combination thereof can be scanned for change points.
Usage
kcpRS_workflow(
data,
RS_funs = c("runMean", "runVar", "runAR", "runCorr"),
wsize = 25,
nperm = 1000,
Kmax = 10,
alpha = 0.05,
varTest = FALSE,
bcorr = TRUE,
ncpu = 1
)
## S3 method for class 'kcpRS_workflow'
plot(x, ...)
## S3 method for class 'kcpRS_workflow'
print(x, ...)
## S3 method for class 'kcpRS_workflow'
summary(object, ...)
Arguments
data |
data N x v dataframe where N is the number of time points and v the number of variables |
RS_funs |
a vector of names of the functions that correspond to the running statistics to be monitored. Options available: "runMean"=running mean, "runVar"=running variance, "runAR"=running autocorrelation and "runCorr"=running correlation. |
wsize |
Window size |
nperm |
Number of permutations used in the permutation test |
Kmax |
Maximum number of change points desired |
alpha |
Significance level for the full KCP-RS workflow analysis if |
varTest |
If set to TRUE, only the variance DROP test is implemented, and if set to FALSE, both the variance test and the variance DROP tests are implemented. |
bcorr |
Set to TRUE if Bonferonni correction is desired for the workflow analysis and set to FALSE otherwise. |
ncpu |
number of cpu cores to use |
x |
An object of the type produced by |
... |
Further plotting arguments |
object |
An object of the type produced by |
Details
The workflow proceeds in two steps: First, the mean change points are flagged using KCP on the running means. If there are significant change points,
the data is centered based on the yielded change points. Otherwise, the data remains untouched for the next analysis. Second, the remaining running
statistics are computed using the centered data in the first step. The user can specify which running statistics to scan change points for
(see RS_funs
and examples).
Bonferonni correction for tracking multiple running statistics can be implemented using the bcorr
option.
Value
kcpMean |
|
kcpVar |
|
kcpAR |
|
kcpCorr |
|
References
Cabrieto, J., Adolf, J., Tuerlinckx, F., Kuppens, P., & Ceulemans, E. (2019). An objective, comprehensive and flexible statistical framework for detecting early warning signs of mental health problems. Psychotherapy and Psychosomatics, 88, 184-186. doi:10.1159/000494356
Examples
phase1=cbind(rnorm(50,0,1),rnorm(50,0,1)) #phase1: Means=0
phase2=cbind(rnorm(50,1,1),rnorm(50,1,1)) #phase2: Means=1
X=rbind(phase1,phase2)
#scan all statistics
res=kcpRS_workflow(data=X,RS_funs=c("runMean","runVar","runAR","runCorr"),
wsize=25,nperm=1000,Kmax=10,alpha=.05, varTest=FALSE, bcorr=TRUE, ncpu=1)
summary(res)
plot(res)
#scan the mean and the correlation only
res=kcpRS_workflow(data=X,RS_funs=c("runMean","runCorr"),wsize=25,nperm=1000,Kmax=10,
alpha=.05, varTest=FALSE, bcorr=TRUE, ncpu=1)
summary(res)
plot(res)