Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/permutationMax.R
The permutation is determined by grouping the components of a multivariate series X into q groups, where q and the cardinal numbers of those groups are also unknown.
1 | permutationMax(X, Vol = FALSE, m = NULL)
|
X |
a data matrix used to find the grouping mechanism with n rows and p columns, where n is the sample size and p is the dimension of the time series. |
Vol |
logical. If |
m |
a positive constant used to calculate the maximum cross correlation over the lags between -m and m. If m is not specified, the default constant 10*log10(n/p) will be used. |
See Chang et al. (2014) for the permutation step and more information.
An object of class "permutationMax" is a list containing the following components:
NoGroups |
number of groups with at least two components series |
Nos_of_Members |
number of members in each of groups with at least two members |
Groups |
indices of components in each of groups with at least two members |
maxcorr |
maximum correlation (over lags) of p(p-1)/2 pairs in descending order |
corrRatio |
ratios of successive values from maxcorr |
NoConnectedPairs |
number of connected pairs |
Xpre |
the prewhitened data with n-R rows and p columns |
This is the second step for segmentation by grouping the transformed time series. The first step is to seek for a contemporaneous linear transformation of the original series, see segmentTS.
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
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 | ## 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 x_t and y_t
Z=data.frame(Z)
names(Z)=c("Z1","Z2","Z3","Z4","Z5","Z6")
# The cross correlogram of z_t shows 3-2-1 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
## 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
# Identify the permutation mechanism
permutation=permutationMax(Z)
permutation$Groups
|
No of groups with more than one members: 2
Nos of members in those groups: 3 2
No of connected pairs: 4
[,1] [,2]
[1,] 1 2
[2,] 3 4
[3,] 6 0
[4,] 0 0
[5,] 0 0
[6,] 0 0
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.