## 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.date = seq(as.POSIXct("2014-10-14 00:00:00","%F %T"), by="hour",
# length.out=series.length)
# my.data = data.frame(date=my.date, 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",
# legend.params=list(lab="cross-wavelet power levels (quantiles)"))
#
# ## The same plot, but with equidistant color breakpoints:
# wc.image(my.wc, color.key="i", timelab="time (days)", periodlab="period (days)",
# main="cross-wavelet power",
# legend.params=list(lab="cross-wavelet power levels (equidistant levels)"))
#
# ## The same plot, but adopting a palette of gray colors:
# wc.image(my.wc, color.key="i", timelab="time (days)", periodlab="period (days)",
# main="cross-wavelet power",
# legend.params=list(lab="cross-wavelet power levels (equidistant levels)"),
# color.palette="gray( (1:n.levels)/n.levels )", plot.arrow=F)
#
# ## The same plot, but with yellow arrows and calendar axis:
# wc.image(my.wc, color.key="i", timelab="", periodlab="period (days)",
# main="cross-wavelet power",
# legend.params=list(lab="cross-wavelet power levels (equidistant levels)"),
# color.palette="gray( (1:n.levels)/n.levels )",
# col.arrow="yellow",
# show.date=T)
#
# ## With additional ridge:
# wc.image(my.wc, color.key="i", timelab="", periodlab="period (days)",
# main="cross-wavelet power",
# legend.params=list(lab="cross-wavelet power levels (equidistant levels)"),
# color.palette="gray( (1:n.levels)/n.levels )",
# col.arrow="yellow",
# show.date=T,
# plot.ridge=T, col.ridge="red")
#
#
# ## The same plot, but with yellow arrows and individualized calendar axis:
# my.plot = wc.image(my.wc, color.key="i", timelab="", periodlab="period (days)",
# main="cross-wavelet power",
# legend.params=list(lab="cross-wavelet power levels (equidistant levels)"),
# color.palette="gray( (1:n.levels)/n.levels )",
# col.arrow="yellow",
# label.time.axis =F)
# ## recover plot region:
# par(new=T, plt=my.plot$image.plt)
# ## empty plot
# plot(my.date, rep(1,series.length), type="n",
# xaxs = "i", yaxs ="i", xaxt="n", yaxt="n",
# xlab="", ylab="")
# ## individualized calendar axis:
# axis.POSIXct(1, at=
# seq(as.POSIXct("2014-11-01 00:00:00", "%F %T"), my.date[length(my.date)], by="month"),
# format="%b %Y", las=2)
# ## return to default plot region:
# par(my.plot$op)
#
# ## 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(lab="wavelet coherence levels (quantiles)", lab.line=3.5,
# label.digits=3))
# ## plot of wavelet coherence, but with equidistant color breakpoints:
# wc.image(my.wc, which.image="wc", color.key="i",
# timelab="time (days)", periodlab="period (days)",
# main="wavelet coherence",
# legend.params=list(lab="wavelet coherence levels (equidistant levels)"))
#
# ## End(Not run)
Run the code above in your browser using DataLab