# spin.covariance: Compute Wavelet Cross-Covariance Between Two Time Series In waveslim: Basic wavelet routines for one-, two- and three-dimensional signal processing

## Description

Computes wavelet cross-covariance or cross-correlation between two time series.

## Usage

 ```1 2``` ```spin.covariance(x, y, lag.max = NA) spin.correlation(x, y, lag.max = NA) ```

## Arguments

 `x` first time series `y` second time series, same length as `x` `lag.max` maximum lag to compute cross-covariance (correlation)

See references.

## Value

List structure holding the wavelet cross-covariances (correlations) according to scale.

B. Whitcher

## References

Gencay, R., F. Selcuk and B. Whitcher (2001) An Introduction to Wavelets and Other Filtering Methods in Finance and Economics, Academic Press.

Whitcher, B., P. Guttorp and D. B. Percival (2000) Wavelet analysis of covariance with application to atmospheric time series, Journal of Geophysical Research, 105, No. D11, 14,941-14,962.

`wave.covariance`, `wave.correlation`.

## Examples

 ``` 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``` ```## Figure 7.9 from Gencay, Selcuk and Whitcher (2001) data(exchange) returns <- diff(log(exchange)) returns <- ts(returns, start=1970, freq=12) wf <- "d4" demusd.modwt <- modwt(returns[,"DEM.USD"], wf, 8) demusd.modwt.bw <- brick.wall(demusd.modwt, wf) jpyusd.modwt <- modwt(returns[,"JPY.USD"], wf, 8) jpyusd.modwt.bw <- brick.wall(jpyusd.modwt, wf) n <- dim(returns)[1] J <- 6 lmax <- 36 returns.cross.cor <- NULL for(i in 1:J) { blah <- spin.correlation(demusd.modwt.bw[[i]], jpyusd.modwt.bw[[i]], lmax) returns.cross.cor <- cbind(returns.cross.cor, blah) } returns.cross.cor <- ts(as.matrix(returns.cross.cor), start=-36, freq=1) dimnames(returns.cross.cor) <- list(NULL, paste("Level", 1:J)) lags <- length(-lmax:lmax) lower.ci <- tanh(atanh(returns.cross.cor) - qnorm(0.975) / sqrt(matrix(trunc(n/2^(1:J)), nrow=lags, ncol=J, byrow=TRUE) - 3)) upper.ci <- tanh(atanh(returns.cross.cor) + qnorm(0.975) / sqrt(matrix(trunc(n/2^(1:J)), nrow=lags, ncol=J, byrow=TRUE) - 3)) par(mfrow=c(3,2), las=1, pty="m", mar=c(5,4,4,2)+.1) for(i in J:1) { plot(returns.cross.cor[,i], ylim=c(-1,1), xaxt="n", xlab="Lag (months)", ylab="", main=dimnames(returns.cross.cor)[[2]][i]) axis(side=1, at=seq(-36, 36, by=12)) lines(lower.ci[,i], lty=1, col=2) lines(upper.ci[,i], lty=1, col=2) abline(h=0,v=0) } ```

### Example output

```waveslim: Wavelet Method for 1/2/3D Signals (version = 1.7.5)
```

waveslim documentation built on May 29, 2017, 3:23 p.m.