## Not run:
# ## The following example is adopted from Veleda et al, 2012:
#
# add.noise=TRUE
#
# series.length = 3*128*24
# x1 = periodic.series(start.period = 1*24, length = series.length)
# x2 = periodic.series(start.period = 2*24, length = series.length)
# x3 = periodic.series(start.period = 4*24, length = series.length)
# x4 = periodic.series(start.period = 8*24, length = series.length)
# x5 = periodic.series(start.period = 16*24, length = series.length)
# x6 = periodic.series(start.period = 32*24, length = series.length)
# x7 = periodic.series(start.period = 64*24, length = series.length)
# x8 = periodic.series(start.period = 128*24, length = series.length)
#
# x = x1 + x2 + x3 + x4 + 3*x5 + x6 + x7 + x8
# y = x1 + x2 + x3 + x4 + 3*x5 + x6 + 3*x7 + x8
#
# if (add.noise == TRUE){
# x = x + rnorm(length(x))
# y = y + rnorm(length(y))
# }
#
# my.data = data.frame(x=x, y=y)
#
# ts.plot(ts(my.data$x, start=0, frequency=24),
# ts(my.data$y, start=0, frequency=24),
# type="l", col=1:2,
# xlab="time (days)", ylab="hourly data",
# main="a series of hourly data with periods of 1, 2, 4, 8, 16, 32, 64, and 128 days",
# sub="(different amplitudes at periods 16 and 64)")
# legend("topright", legend=c("x","y"), col=1:2, lty=1)
#
# ## computation of cross-wavelet power and wavelet coherence:
# my.wc = analyze.coherency(my.data, c("x","y"), loess.span=0,
# dt=1/24, dj=1/20,
# window.size.t=1, window.size.s=1/2,
# lowerPeriod=1/4,
# make.pval=T, n.sim=10)
#
# ## plot of cross-wavelet power (with color breakpoints according to quantiles):
# wc.image(my.wc, timelab="time (days)", periodlab="period (days)",
# main="cross-wavelet power")
# ## plot of average cross-wavelet power:
# wc.avg(my.wc, siglvl=0.05, sigcol="red")
#
# ## plot of wavelet coherence (with color breakpoints according to quantiles):
# wc.image(my.wc, which.image="wc", timelab="time (days)", periodlab="period (days)",
# main="wavelet coherence",
# legend.params=list(label.digits=3))
# ## plot of average wavelet coherence:
# wc.avg(my.wc, which.avg="wc", siglvl=0.05, sigcol="red", legend.coords="topleft")
# ## End(Not run)
Run the code above in your browser using DataLab