# cross.cor.MSAR: empirical cross-correlation for multivariate MSAR time series In NHMSAR: Non-Homogeneous Markov Switching Autoregressive Models

## Description

cross.cor.MSAR computes the cross-correlation between two components. The cross-corelation can be estimted for the whole time series or regime by regime.

## Usage

 ```1 2 3``` ```cross.cor.MSAR(data, X=NULL, nc1 = 1, nc2 = 2, lag = 10, regime = 0, CI = FALSE, Bsim = 0, N.samples = 1, add = FALSE, col = 1, names = NULL, alpha = 0.1,ylab="Cross-Correlation", dt = 1, ylim = c(-0.1, 1)) ```

## Arguments

 `data` observed (or reference) time series, array of dimension T*N.samples*d `X` time series of regimes associated to data `nc1` first component to be considered `nc2` second component to be considered `lag` maximum lag (default=10). The cross-correlation is estimated for lags -lag:lag. `regime` has to be an integer between 0 and M, with M the number of regimes. If regime=0, the cross correlaiton is computed for the whole time series. If regime=m>0, the corss corelation is computed considereing only the sub-sequences in regime m. `CI` If CI=TRUE fluctuation intervals are computed, default is FALSE `Bsim` useful for computation of confidence intervals. When observed and simulated data are compared, one expects that the number of simulated time series is Bsim*N.samples `N.samples` useful for computation of confidence intervals. N.sample describes the number of independant time series in the observed (or reference) data `dt` default time step is equal to 1 `add` if add=TRUE the empirical cross-correlation is added to the current plot. `col` color of the line `names` list with the names of components of data `alpha` level for the computation of the fluctuation intervals. default=0.1 `ylab` legend for y axis `ylim` limit for y axis

## Details

The cross-correlation functions are computed from one or several independent realizations of the same length.

## Value

returns a list including:

 `..\$ccf` empirical cross-correlation `..\$lag` abscissa for the cross-correlation `..\$CI` fluctuation intervals

## Author(s)

Valerie Monbet, valerie.monbet@univ-rennes1.fr

## References

Bessac, J., Ailliot, P., & Monbet, V. (2013). Gaussian linear state-space model for wind fields in the North-East Atlantic. arXiv preprint arXiv:1312.5530.

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```data(Wind) T = dim(U)[1] c = cross.cor.MSAR(U,nc1=1,nc2=18,names=1:18) ## Not run #Y = U[,,c(1,18)] #theta.init=init.theta.MSAR(Y,M=2,order=2,label="HH") #res.hh = fit.MSAR(Y,theta.init,verbose=TRUE,MaxIter=200) #Bsim = 20 #N.samples = dim(U)[2] #Ksim = Bsim*N.samples #Y0 = Y0 #Y.sim = simule.nh.MSAR(res.hh\$theta,Y0 = Y0,T,N.samples = Ksim) #c.sim = cross.cor.MSAR(Y.sim\$Y,nc1=1,nc2=2,names=c(1,18), # CI=TRUE,Bsim=Bsim,N.samples=N.samples,add=TRUE,col="red") ```