## 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 coherency
# 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
# wc.image(my.wc, timelab="time (days)", periodlab="period (days)",
# main="cross-wavelet power")
#
# ## Select period 64 and compare plots of corresponding phases, including the
# ## phase differences (angles) in their non-smoothed (default) version:
# wc.sel.phases(my.wc, timelab="time (days)", sel.period=64, show.Angle=T)
#
# ## In the following, no periods are selected. In this case, instead of individual phases
# ## the plot shows average phases:
# wc.sel.phases(my.wc, timelab="time (days)")
# ## End(Not run)
Run the code above in your browser using DataLab