wc.sel.phases: Comparison plot of phases for selected periodic components of...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/wc.sel.phases.R

Description

This function plots the phases for periodic components of two time series, which are provided by an object of class "analyze.coherency".

Periodic components can be selected by specification of a single Fourier period or of a period band. In the latter case, and in the default case (no specification at all), phases are averaged across periods for each time series. Other options: restriction to the cone of influence, restriction to an area of significance (with respect to cross-wavelet power, wavelet coherence or individual wavelet power). Phase differences (i.e. angles, smoothed or not smoothed) can be added to the plot.

(The time axis can be altered to display dates, see e.g. wt.image. In particular, an option is given to individualize the phase and/or time axis by specifying tick marks and labels.)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
wc.sel.phases(WC, sel.period = NULL, sel.lower = NULL, sel.upper = NULL, 
      only.coi = FALSE, 
      only.sig = TRUE, which.sig = "wp", siglvl = 0.05, 
      phase.cols = c("red", "blue"), 
      show.Angle = TRUE, use.sAngle = FALSE, Angle.col = "black", 
      show.legend = TRUE, legend.coords = "topleft", legend.horiz = TRUE,
      label.time.axis = TRUE, 
      show.date = FALSE, date.format = NULL, date.tz = NULL, 
      timelab = NULL, timetck = 0.02, timetcl = 0.5,
      spec.time.axis = list(at = NULL, labels = TRUE, 
                            las = 1, hadj = NA, padj = NA),
      label.phase.axis = TRUE, 
      phaselab = NULL, phasetck = 0.02, phasetcl = 0.5,
      spec.phase.axis = list(at = NULL, labels = TRUE, 
                             las = 1, hadj = NA, padj = NA),
      phaselim = c(-pi,pi+show.legend*ifelse(legend.horiz,0.8,2)),      
      main = NULL, sub = NULL,
      lwd = 1, lwd.Angle = 2, lwd.axis = 1, 
      verbose = FALSE)

Arguments

WC

an object of class "analyze.coherency".

sel.period

a single number which determines the (closest available) Fourier period to be selected.

Default: NULL.

sel.lower

a number to define a lower Fourier period (or the closest available) for the selection of a band of periods (effective if sel.period is NULL).

Default: NULL.

sel.upper

a number to define an upper Fourier period (or the closest available) for the selection of a band of periods (effective if sel.period is NULL).

Default: NULL.

only.coi

Exclude borders influenced by edge effects, i.e. include the cone of influence only? Logical.

Default: FALSE.

only.sig

Use cross-wavelet power (or wavelet coherence, depending on which.sig) significance to decide about the inclusion of (parts of) the series of phases? Logical.

Default: TRUE.

which.sig

Which spectrum should significance refer to?

"wp" : cross-wavelet power
"wc" : wavelet coherence
"wt" : individual wavelet power

Default: "wp"

siglvl

level of cross-wavelet power (or wavelet coherence, depending on which.sig) significance.

Default: 0.05.

phase.cols

a vector of two colors for the plot of (average) phases referring to the two time series.

Default: c("red","blue").

show.Angle

Show the (average) phase difference (the Angle) between the two series? Logical.

Default: TRUE.

use.sAngle

Use smoothed version of phase difference? Logical.

Default: FALSE.

Angle.col

color of the line of Angles.

Default: "black".

show.legend

Include legend? Logical. Default: TRUE.

legend.coords

Coordinates to position the legend (with the same options as given in function legend).

Default: "topleft".

legend.horiz

Set the legend horizontally rather than vertically? Logical.

Default: TRUE.

label.time.axis

Label the time axis? Logical.

Default: TRUE.

show.date

Show calendar dates? (Effective only if dates are available as row names or by variable date in the data frame which is analyzed.) Logical.

Default: FALSE.

date.format

the format of calendar date given as a character string, e.g. "%Y-%m-%d", or equivalently "%F"; see strptime for a list of implemented date conversion specifications. Explicit information given here will overturn any specification stored in WC. If unspecified, date formatting is attempted according to as.Date.

Default: NULL.

date.tz

a character string specifying the time zone of calendar date; see strptime. Explicit information given here will overturn any specification stored in WC. If unspecified, "" (the local time zone) is used.

Default: NULL.

timelab

Time axis label.

Default: "index"; in case of a calendar axis: "calendar date".

timetck

length of tick marks on the time axis as a fraction of the smaller of the width or height of the plotting region; see par. If timetck >= 0.5, timetck is interpreted as a fraction of the length of the time axis, so if timetck = 1 (and timetcl = NULL), vertical grid lines will be drawn.
Setting timetck = NA is to use timetcl = -0.5 (which is the R default setting of tck and tcl).

Default here: 0.02.

timetcl

length of tick marks on the time axis as a fraction of the height of a line of text; see par. With timetcl = -0.5 (which is the R default setting of tcl), ticks will be drawn outward.

Default here: 0.5.

spec.time.axis

a list of tick mark and label specifications for individualized time axis labeling (only effective if label.time.axis = TRUE):

  • [at:] locations of tick marks (when NULL, default plotting will be applied). Valid tick marks can be provided as numerical values or as dates. Dates are used only in the case show.date = TRUE, however, and date formats should conform to as.Date or the format given in date.format.
    Default: NULL.

  • [labels:] either a logical value specifying whether annotations at the tick marks are the tick marks themselves, or any vector of labels. If labels is non-logical, at should be of same length.
    Default: TRUE.

  • [las:] the style of axis labels, see par.
    Default: 1 (always horizontal).

  • [hadj:] adjustment of labels horizontal to the reading direction, see axis.
    Default: NA (centering is used).

  • [padj:] adjustment of labels perpendicular to the reading direction (this can be a vector of adjustments for each label), see axis.
    Default: NA (centering is used).

Mismatches will result in a reset to default plotting.

label.phase.axis

Label the phase axis? Logical.

Default: TRUE.

phaselab

Phase axis label.

Default: "phase".

phasetck

length of tick marks on the phase axis as a fraction of the smaller of the width or height of the plotting region; see par. If phasetck >= 0.5, phasetck is interpreted as a fraction of the length of the phase axis, so if phasetck = 1 (and phasetcl = NULL), horizontal grid lines will be drawn.
Setting phasetck = NA is to use phasetcl = -0.5 (which is the R default setting of tck and tcl).

Default here: 0.02.

phasetcl

length of tick marks on the phase axis as a fraction of the height of a line of text; see par. With phasetcl = -0.5 (which is the R default setting of tcl), ticks will be drawn outward.

Default here: 0.5.

spec.phase.axis

a list of tick mark and label specifications for individualized phase axis labeling (only effective if label.phase.axis = TRUE):

  • [at:] locations of tick marks (when NULL, default plotting will be applied). Valid tick marks can be provided as numerical values between -pi and pi.
    Default: NULL.

  • [labels:] either a logical value specifying whether annotations at the tick marks are the tick marks themselves, or any vector of labels. If labels is non-logical, at should be of same length.
    Default: TRUE.

  • [las:] the style of axis labels, see par.
    Default: 1 (always horizontal).

  • [hadj:] adjustment of labels horizontal to the reading direction, see axis.
    Default: NA (centering is used).

  • [padj:] adjustment of labels perpendicular to the reading direction (this can be a vector of adjustments for each label), see axis.
    Default: NA (centering is used).

Mismatches will result in a reset to default plotting.

phaselim

numeric vector of length 2, giving the phase coordinate range.

Default: c(-pi,pi+0.8)
(+0.8 in order to accomodate the horizontal legend, +2 in case of a vertical legend).

main

an overall title for the plot.

Default: NULL.

sub

a subtitle for the plot.

Default: NULL. In this case, the selected period range will be given in the subtitle.

lwd

width of lines of phases.

Default: 1.

lwd.Angle

width of lines of (average) phase differences (the Angles) between the two series (this line will be plotted if show.Angle = TRUE).

Default: 2.

lwd.axis

line width of axes.

Default: 1.

verbose

Print verbose output on the screen? Logical.

Default: FALSE.

Value

A list of class "sel.phases" with the following elements:

Period

the selected period (or period band)

Phase.x

time series of (average) phases at the selected period (or period band), case of series x

Phase.y

time series of (average) phases at the selected period (or period band), case of series y

Angle

time series of (average) phase differences (non-smoothed version) at the selected period (or period band)

sAngle

time series of (average) smoothed phase differences at the selected periods

only.coi

Is the influence of edge effects excluded? I.e. is the cone of influence used only?

only.sig

Was significance used in selection of phases?

which.sig

Which spectrum was used to refer to significance?

"wp" : cross-wavelet power
"wc" : wavelet coherence
"wt" : individual wavelet power
siglvl

level of significance

date

time series of calendar date (if available)

date.format

the format of calendar date as provided

date.tz

the time zone of calendar date as provided

axis.1

tick levels corresponding to the time steps used for (cross-)wavelet transformation: 1, 1+dt, 1+2dt, ...

Author(s)

Angi Roesch and Harald Schmidbauer

References

Aguiar-Conraria L., and Soares M.J., 2011. Business cycle synchronization and the Euro: A wavelet analysis. Journal of Macroeconomics 33 (3), 477–489.

Aguiar-Conraria L., and Soares M.J., 2011. The Continuous Wavelet Transform: A Primer. NIPE Working Paper Series 16/2011.

Cazelles B., Chavez M., Berteaux, D., Menard F., Vik J.O., Jenouvrier S., and Stenseth N.C., 2008. Wavelet analysis of ecological time series. Oecologia 156, 287–304.

Liu P.C., 1994. Wavelet spectrum analysis and ocean wind waves. In: Foufoula-Georgiou E., and Kumar P., (eds.), Wavelets in Geophysics, Academic Press, San Diego, 151–166.

Torrence C., and Compo G.P., 1998. A practical guide to wavelet analysis. Bulletin of the American Meteorological Society 79 (1), 61–78.

Veleda D., Montagne R., and Araujo M., 2012. Cross-Wavelet Bias Corrected by Normalizing Scales. Journal of Atmospheric and Oceanic Technology 29, 1401–1408.

See Also

analyze.coherency, wc.image, wc.avg, wc.phasediff.image, wt.image, wt.avg,
wt.sel.phases, wt.phase.image, reconstruct

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
## Not run: 
## The following example is modified from Veleda et al., 2012:

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)
x3a <- periodic.series(start.period = 4*24, length = series.length)
x3b <- periodic.series(start.period = 4*24, length = series.length,
                       phase = 24)
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 + x3a + x4 + 3*x5 + x6 + x7 + x8 + rnorm(series.length)
y <- x1 + x2 + x3b + x4 - 3*x5 + x6 + 3*x7 + x8 + rnorm(series.length)

matplot(data.frame(x, y), type = "l", lty = 1, xaxs = "i", col = 1:2, 
 xlab = "index", ylab = "",
 main = "hourly series with periods of 1, 2, 4, 8, 16, 32, 64, 128 days", 
 sub = "(different phases at periods 4 and 16)")
legend("topright", legend = c("x","y"), col = 1:2, lty = 1)

my.date <- seq(as.POSIXct("2014-10-14 00:00:00", format = "%F %T"), 
               by = "hour", 
               length.out = series.length)     
my.data <- data.frame(date = my.date, x = x, y = y)

## Computation of cross-wavelet power and wavelet coherency of x over y:
## a natural choice of 'dt' in the case of hourly data is 'dt = 1/24', 
## resulting in one time unit equaling one day.
## This is also the time unit in which periods are measured.
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 = TRUE, n.sim = 10)

## Plot of cross-wavelet power spectrum, 
## with color breakpoints according to quantiles:
wc.image(my.wc, main = "cross-wavelet power spectrum, x over y",
   legend.params = list(lab = "cross-wavelet power levels (quantiles)"),
   periodlab = "period (days)")

## 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, sel.period = 64, show.Angle = TRUE)

## With time elapsed in days
## (starting from 0 and proceeding in steps of 50 days) 
## instead of the (default) time index:
index.ticks  <- seq(1, series.length, by = 50*24)
index.labels <- (index.ticks-1)/24
wc.sel.phases(my.wc, sel.period = 64, show.Angle = TRUE,  
   timelab = "time elapsed (days)",
   spec.time.axis = list(at = index.ticks, labels = index.labels))

## The same plot, but with (automatically produced) calendar axis:
wc.sel.phases(my.wc, sel.period = 64, show.Angle = TRUE,   
   show.date = TRUE, date.format = "%F %T")

## For further axis plotting options:
## Please see the examples in our guide booklet,
## URL http://www.hs-stat.com/projects/WaveletComp/WaveletComp_guided_tour.pdf.    

## Now, select period 16...
## and observe that corresponding components are out of phase:
wc.sel.phases(my.wc, sel.period = 16, show.Angle = TRUE,
   show.date = TRUE, date.format = "%F %T")
## ... compare to period 4...
wc.sel.phases(my.wc, sel.period = 4, show.Angle = TRUE,
   show.date = TRUE, date.format = "%F %T")   

## In the following, no periods are selected. 
## In this case, instead of individual phases, the plot shows 
## average phases for each series: 
wc.sel.phases(my.wc)


## End(Not run)

WaveletComp documentation built on May 2, 2019, 6:33 a.m.