## 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 phase differences (with contour lines referring to cross-wavelet power)
# wc.phasediff.image(my.wc, which.contour="wp", timelab="time (days)",
# main="image of phase differences")
# ## End(Not run)
Run the code above in your browser using DataLab