Description Usage Arguments Details Value Note Author(s) References See Also Examples
Calculate linear transformation of the p-variate time series y_t such that the transformed series x_t=By_t is segmented into several lower-dimensional subseries, and those subseries are uncorrelated with each other both contemporaneously and serially.
1 |
Y |
a data matrix with n rows and p columns, where n is the sample size and p is the dimension of the time series. |
k0 |
a positive integer specified to calculate Wy. See (2.5) in Chang et al. (2014). |
thresh |
logical. If |
tuning.vec |
the value of thresholding parameter λ. The thresholding level is specified by u = λ {(log p/n)^(1/2)}. Default value is 2. If |
K |
the number of folders used in the cross validation, the default is 5. It is required when |
When p is small, thresholding is not required. However, when p is large, it is necessary to use the thresholding method, see more information in Chang et al. (2014).
An object of class "segmentTS" is a list containing the following components:
B |
the p by p transformation matrix such that x_t=By_t |
X |
the transformed series with n rows and p columns |
This is the first step to transform the time series. The second step is grouping the transformed time series, see permutationMax
, permutationFDR
.
Jinyuan Chang, Bin Guo and Qiwei Yao
Chang, J., Guo, B. and Yao, Q. (2014). Segmenting Multiple Time Series by Contemporaneous Linear Transformation: PCA for Time Series. Available at http://arxiv.org/abs/1410.2323.
Cai, T. and Liu, W. (2011). Adaptive thresholding for sparse covariance matrix estimation. Journal of the American Statistical Association 106: 672-684.
permutationMax
, permutationFDR
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | ## Example 1 (Example 5 of Chang et al.(2014)).
## p=6, x_t consists of 3 independent subseries with 3, 2 and 1 components.
p=6;n=1500
# Generate x_t
X=mat.or.vec(p,n)
x=arima.sim(model=list(ar=c(0.5, 0.3), ma=c(-0.9, 0.3, 1.2,1.3)),n=n+2,sd=1)
for(i in 1:3) X[i,]=x[i:(n+i-1)]
x=arima.sim(model=list(ar=c(0.8,-0.5),ma=c(1,0.8,1.8) ),n=n+1,sd=1)
for(i in 4:5) X[i,]=x[(i-3):(n+i-4)]
x=arima.sim(model=list(ar=c(-0.7, -0.5), ma=c(-1, -0.8)),n=n,sd=1)
X[6,]=x
# Generate y_t
A=matrix(runif(p*p, -3, 3), ncol=p)
Y=A%*%X
Y=t(Y)
Trans=segmentTS(Y, k0=5)
# The transformed series z_t
Z=Trans$X
# Plot the cross correlogram of z_t and y_t
Y=data.frame(Y);Z=data.frame(Z)
names(Y)=c("Y1","Y2","Y3","Y4","Y5","Y6")
names(Z)=c("Z1","Z2","Z3","Z4","Z5","Z6")
# The cross correlogram of y_t shows no block pattern
acfY=acf(Y)
# The cross correlogram of z_t shows 3-2-1 block pattern
acfZ=acf(Z)
## Example 2 (Example 6 of Chang et al.(2014)).
## p=20, x_t consists of 5 independent subseries with 6, 5, 4, 3 and 2 components.
p=20;n=3000
# Generate x_t
X=mat.or.vec(p,n)
x=arima.sim(model=list(ar=c(0.5, 0.3), ma=c(-0.9, 0.3, 1.2,1.3)),n.start=500,n=n+5,sd=1)
for(i in 1:6) X[i,]=x[i:(n+i-1)]
x=arima.sim(model=list(ar=c(-0.4,0.5),ma=c(1,0.8,1.5,1.8)),n.start=500,n=n+4,sd=1)
for(i in 7:11) X[i,]=x[(i-6):(n+i-7)]
x=arima.sim(model=list(ar=c(0.85,-0.3),ma=c(1,0.5,1.2)), n.start=500,n=n+3,sd=1)
for(i in 12:15) X[i,]=x[(i-11):(n+i-12)]
x=arima.sim(model=list(ar=c(0.8,-0.5),ma=c(1,0.8,1.8)),n.start=500,n=n+2,sd=1)
for(i in 16:18) X[i,]=x[(i-15):(n+i-16)]
x=arima.sim(model=list(ar=c(-0.7, -0.5), ma=c(-1, -0.8)),n.start=500,n=n+1,sd=1)
for(i in 19:20) X[i,]=x[(i-18):(n+i-19)]
# Generate y_t
A=matrix(runif(p*p, -3, 3), ncol=p)
Y=A%*%X
Y=t(Y)
Trans=segmentTS(Y, k0=5)
# The transformed series z_t
Z=Trans$X
# Plot the cross correlogram of x_t and y_t
Y=data.frame(Y);Z=data.frame(Z)
namesY=NULL;namesZ=NULL
for(i in 1:p)
{
namesY=c(namesY,paste0("Y",i))
namesZ=c(namesZ,paste0("Z",i))
}
names(Y)=namesY;names(Z)=namesZ
# The cross correlogram of y_t shows no block pattern
acfY=acf(Y, plot=FALSE)
plot(acfY, max.mfrow=6, xlab='', ylab='', mar=c(1.8,1.3,1.6,0.5),
oma=c(1,1.2,1.2,1), mgp=c(0.8,0.4,0),cex.main=1)
# The cross correlogram of z_t shows 6-5-4-3-2 block pattern
acfZ=acf(Z, plot=FALSE)
plot(acfZ, max.mfrow=6, xlab='', ylab='', mar=c(1.8,1.3,1.6,0.5),
oma=c(1,1.2,1.2,1), mgp=c(0.8,0.4,0),cex.main=1)
# Identify the permutation mechanism
permutation=permutationMax(Z)
permutation$Groups
|
No of groups with more than one members: 5
Nos of members in those groups: 6 5 4 3 2
No of connected pairs: 35
[,1] [,2] [,3] [,4] [,5]
[1,] 1 2 3 6 11
[2,] 5 4 8 12 16
[3,] 7 9 14 19 0
[4,] 10 13 18 0 0
[5,] 15 17 0 0 0
[6,] 20 0 0 0 0
[7,] 0 0 0 0 0
[8,] 0 0 0 0 0
[9,] 0 0 0 0 0
[10,] 0 0 0 0 0
[11,] 0 0 0 0 0
[12,] 0 0 0 0 0
[13,] 0 0 0 0 0
[14,] 0 0 0 0 0
[15,] 0 0 0 0 0
[16,] 0 0 0 0 0
[17,] 0 0 0 0 0
[18,] 0 0 0 0 0
[19,] 0 0 0 0 0
[20,] 0 0 0 0 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.