| Title: | Wavelet Approaches to Studies of Synchrony in Ecology and Other Fields |
|---|---|
| Description: | Tools for a wavelet-based approach to analyzing spatial synchrony, principally in ecological data. Some tools will be useful for studying community synchrony. See, for instance, Sheppard et al (2016) <doi: 10.1038/NCLIMATE2991>, Sheppard et al (2017) <doi: 10.1051/epjnbp/2017000>, Sheppard et al (2019) <doi: 10.1371/journal.pcbi.1006744>. |
| Authors: | Daniel C. Reuman [aut, cre], Thomas L. Anderson [aut], Jonathan A. Walter [aut], Lei Zhao [aut], Lawrence W. Sheppard [aut] |
| Maintainer: | Daniel C. Reuman <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.4 |
| Built: | 2026-05-27 10:10:15 UTC |
| Source: | https://github.com/reumandc/wsyn |
coh or wlmtest objectWhen a coh or wlmtets object is created, the ranks slot is NA.
This function fills it in.
addranks(obj)addranks(obj)
obj |
An object of class |
addranks returns another coh or wlmtest object with ranks
slot now included. If obj$ranks was not NA, the object is returned as is.
Internal function, no error checking performed
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
coh, wlmtest, bandtest, browseVignettes("wsyn")
clust objectWhen a clust object is created, the wmfs slot is NA. This function fills it in.
addwmfs(obj)addwmfs(obj)
obj |
An object of class |
This function uses the values of scale.min, scale.max.input,
sigma and f0 stored in obj$methodspecs. It is possible to create
a clust object with bad values for these slots. This function throws an error in that
case. You can use a correlation-based method for calculating the synchrony matrix and
still pass values of scale.min, scale.max.input, sigma and f0
to clust (in fact, this happens by default) - they won't be used by clust,
but they will be there for later use by addwmfs and addwpmfs.
addwmfs returns another clust object with wmfs slot now included.
If obj$wmfs was not NA, the object is returned as is.
Daniel Reuman, [email protected]
clust, addwpmfs, browseVignettes("wsyn")
sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" clustobj<-clust(dat,times,coords,method,nsurrogs = 100) res<-addwmfs(clustobj)sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" clustobj<-clust(dat,times,coords,method,nsurrogs = 100) res<-addwmfs(clustobj)
clust objectWhen a clust object is created, the wpmfs slot is NA. This function fills it in,
or adds to it.
addwpmfs( obj, level = 1:length(obj$clusters), sigmethod = "quick", nrand = 1000 )addwpmfs( obj, level = 1:length(obj$clusters), sigmethod = "quick", nrand = 1000 )
obj |
An object of class |
level |
The clustering level(s) to use. 1 corresponds to no clustering. The default is all levels of clustering. |
sigmethod |
Method for significance testing the |
nrand |
The number of randomizations to be used for significance testing |
This function uses the values of scale.min, scale.max.input,
sigma and f0 stored in obj$methodspecs. It is possible to create
a clust object with bad values for these slots. This function throws an error in that
case. You can use a correlation-based method for calculating the synchrony matrix and
still pass values of scale.min, scale.max.input, sigma and f0
to clust (in fact, this happens by default) - they won't be used by clust,
but they will be there for later use by addwmfs and addwpmfs.
addwpmfs returns another clust object with wpmfs slot now included,
or more filled in than it was previously. With values of sigmethod other than
"quick", this function can be slow, particularly with large nrand. So in that
case the user may want to set level equal only to one clustering level of interest.
Unlike wmf, old values in obj$wpmfs are overwritten.
Daniel Reuman, [email protected]
clust, addwmfs, browseVignettes("wsyn")
sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" clustobj<-clust(dat,times,coords,method,nsurrogs = 100) res<-addwpmfs(clustobj)sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" clustobj<-clust(dat,times,coords,method,nsurrogs = 100) res<-addwpmfs(clustobj)
Computes the aggregate significance of coherence (coh) or of a wavelet linear model test object
(wlmtest) across a timescale band, accounting for non-independence of timescales. Also gets the
average phase across the band, in the case of coherence.
bandtest(object, ...) ## Default S3 method: bandtest(object, ...) ## S3 method for class 'coh' bandtest(object, band, ...) ## S3 method for class 'wlmtest' bandtest(object, band, ...)bandtest(object, ...) ## Default S3 method: bandtest(object, ...) ## S3 method for class 'coh' bandtest(object, band, ...) ## S3 method for class 'wlmtest' bandtest(object, band, ...)
object |
An object of class |
... |
Passed from the generic to specific methods. Not currently used. |
band |
A length-two numeric vector indicating a timescale band |
bandtest returns an object of the same class as its first input but with a
bandp slot added. Or if there was already a bandp slot, the output has a
bandp slot with an additional row. For a coh object, the bandp slot
is a data frame with four columns, the first two indicating the timescale band and the third
an associated p-value for the test of coherence over that band. The fourth column is the
average phase over the band. For a wlmtest object, the result is only the first three
of the above columns.
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
coh, wlm, wlmtest, browseVignettes("wsyn")
#Example for a coh object times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat cohobj<-coh(dat1=artsig_x,dat2=artsig_y,times=times,norm="powall",sigmethod="fast",nrand=1000, f0=0.5,scale.max.input=28) cohobj<-bandtest(cohobj,c(2,4)) #Example for a wlmtest object - see vignette#Example for a coh object times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat cohobj<-coh(dat1=artsig_x,dat2=artsig_y,times=times,norm="powall",sigmethod="fast",nrand=1000, f0=0.5,scale.max.input=28) cohobj<-bandtest(cohobj,c(2,4)) #Example for a wlmtest object - see vignette
The one-parameter family of Box-Cox transformations
bctrans(y, lambda)bctrans(y, lambda)
y |
A numeric, positive values assumed |
lambda |
The Box-Cox parameter |
Internal function. No error checking done. It is assumed the entries of y are positive.
bctrans gives ((y^lambda)-1)/lambda for lambda not 0 or ln(y) for lambda equal to 0.
Daniel Reuman, [email protected]
Box, GEP and Cox, DR (1964) An analysis of transformations (with discussion). Journal of the Royal Statistical Society B, 26, 211–252.
Venables, WN and Ripley, BD (2002) Modern Applied Statistics with S. Fourth edition. Springer.
cleandat, browseVignettes("wsyn")
wsyn packageA data cleaning function for optimal Box-Cox transformation, detrending, standarizing variance, de-meaning
cleandat(dat, times, clev, lambdas = seq(-10, 10, by = 0.01), mints = NA)cleandat(dat, times, clev, lambdas = seq(-10, 10, by = 0.01), mints = NA)
dat |
A locations x time data matrix, or a time series vector (for 1 location) |
times |
The times of measurement, spacing 1 |
clev |
The level of cleaning to do, 1 through 5. See details. |
lambdas |
A vector of lambdas to test for optimal Box-Cox transformation, if Box-Cox is
performed. Ignored for |
mints |
If |
NAs, Infs, etc. in dat trigger an error. If clev==1, time series are (individually)
de-meaned. If clev==2, time series are (individually) linearly detrended and de-meaned. If clev==3,
time series are (individually) linearly detrended and de-meaned, and variances are standardized to 1. If
clev==4, an optimal Box-Cox normalization procedure is applied jointly to all time series (so the same
Box-Cox transformation is applied to all time series after they are individually shifted depending on the value
of mints). Transformed time series are then individually linearly detrended, de-meaned, and variances are
standardized to 1. If clev==5, an optimal Box-Cox normalization procedure is applied to each time series
individually (again after individually shifting according to mints), and transformed time series are then
individually linearly detrended, de-meaned, and variances are standardized to 1. Constant time series and perfect
linear trends trigger an error for clev>=3. If clev>=4 and the optimal lambda for one or
more time series is a boundary case or if there is more than one optimal lambda, it triggers a warning. A wider
range of lambda should be considered in the former case.
cleandat returns a list containing the cleaned data, clev, and the optimal
lambdas from the Box-Cox procedure (NA for clev<4, see details).
Jonathan Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]; Lei Zhao, [email protected]
Box, GEP and Cox, DR (1964) An analysis of transformations (with discussion). Journal of the Royal Statistical Society B, 26, 211–252.
Venables, WN and Ripley, BD (2002) Modern Applied Statistics with S. Fourth edition. Springer.
Sheppard, LW, et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
wt, wmf, wpmf, coh, wlm,
wlmtest, clust, browseVignettes("wsyn")
times<-1:100 dat<-rnorm(100) res1<-cleandat(dat,times,1) #this removes the mean res2<-cleandat(dat,times,2) #detrends and removes the mean res3<-cleandat(dat,times,3) #variances also standardized res4<-cleandat(dat,times,4) #also joint Box-Cox applied res5<-cleandat(dat,times,5) #1-3, also indiv Box-Coxtimes<-1:100 dat<-rnorm(100) res1<-cleandat(dat,times,1) #this removes the mean res2<-cleandat(dat,times,2) #detrends and removes the mean res3<-cleandat(dat,times,3) #variances also standardized res4<-cleandat(dat,times,4) #also joint Box-Cox applied res5<-cleandat(dat,times,5) #1-3, also indiv Box-Cox
Community structure detection in networks based on the leading eigenvector of the community matrix
cluseigen(adj)cluseigen(adj)
adj |
An adjacency matrix. Should be symmetric with diagonal containing zeros. |
The difference between this function and the algorithm described by Newman is that this function can be used on an adjacency matrix with negative elements, which is very common for correlation matrices and other measures of pairwise synchrony of time series.
cluseigen returns a list with one element for each of the splits
performed by the clustering algorithm. Each element is a vector with entries
corresponding to rows and columns of adj and indicating the module membership
of the node, following the split. The last element of the list is the final
clustering determined by the algorithm when its halting condition is satisfied.
The first element is always a vector of all 1s (corresponding to before any
splits are performed).
Lei Zhao, [email protected]; Daniel Reuman, [email protected]
Gomez S., Jensen P. & Arenas A. (2009). Analysis of community structure in networks of correlated data. Phys Rev E, 80, 016114.
Newman M.E.J. (2006). Finding community structure in networks using the eigenvectors of matrices. Phys Rev E, 74, 036104.
Newman M.E.J. (2006) Modularity and community structure in networks. PNAS 103, 8577-8582.
clust, modularity, browseVignettes("wsyn")
adj<-matrix(0, 10, 10) # create a fake adjacency matrix adj[lower.tri(adj)]<-runif(10*9/2, -1, 1) adj<-adj+t(adj) colnames(adj)<-letters[1:10] z<-cluseigen(adj)adj<-matrix(0, 10, 10) # create a fake adjacency matrix adj[lower.tri(adj)]<-runif(10*9/2, -1, 1) adj<-adj+t(adj) colnames(adj)<-letters[1:10] z<-cluseigen(adj)
Generator function for the clust S3 class, which supports tools for detecting clusters
(aka, modules, sub-networks, communities, etc.) of especially synchronous locations.
clust( dat, times, coords, method, tsrange = c(0, Inf), nsurrogs = 1000, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1, weighted = TRUE, sigthresh = 0.95 )clust( dat, times, coords, method, tsrange = c(0, Inf), nsurrogs = 1000, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1, weighted = TRUE, sigthresh = 0.95 )
dat |
A locations (rows) x time (columns) matrix of measurements |
times |
The times at which measurements were made, spacing 1 |
coords |
A data frame containing X,Y coordinates of locations in |
method |
Method for synchrony calculation. See details. |
tsrange |
A vector containing the min and max of the focal timescale range. Defaults to all timescales that are valid given choices for scale.min, scale.max.input, f0, sigma. Only used for wavelet-based methods. |
nsurrogs |
Number of surrogates for significance test. Defaults to 1000. Only used for surrogate-based methods. |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. Used only for wavelet-based methods. |
scale.max.input |
The largest scale of fluctuation guaranteed to be examined. Only used for wavelet-based methods. |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. Only used for wavelet-based methods. |
f0 |
The ratio of the period of fluctuation to the width of the envelope. Only used for wavelet-based methods. |
weighted |
If |
sigthresh |
Significance threshold needed, if |
The following values are valid for method:
"pearson", "pearson.sig.std", "pearson.sig.fft",
"pearson.sig.aaft",
"spearman", "spearman.sig.std", "spearman.sig.fft",
"spearman.sig.aaft",
"kendall", "kendall.sig.std", "kendall.sig.fft",
"kendall.sig.aaft",
"ReXWT", "ReXWT.sig.fft", "ReXWT.sig.aaft", "ReXWT.sig.fast",
"coh", "coh.sig.fft", "coh.sig.aaft", "coh.sig.fast",
"phasecoh", "phasecoh.sig.fft", and "phasecoh.sig.aaft".
The first portions of these identifiers correspond to the Pearson, Spearman, and Kendall
correlations, the real part of the cross-wavelet transform, the wavelet coherence, and the
wavelet phase coherence. The second portions of these identifiers, when present, indicates
that significance of the measure specified in the first portion of the identifies is to
be used for establishing the synchrony matrix. Otherwise the value itself is used. The
third part of the method identifier indicates what type of significance is used.
Significance testing is performed using standard approaches (method flag containg
std; for correlation coefficients,
although these are inappropriate for autocorrelated data), or surrogates generated using the
Fourier (method flag containing "fft") or amplitude adjusted Fourier
surrogates ("aaft"). For
"coh" and "ReXWT", the fast testing algorithm of Sheppard et al. (2017) is also
implemented ("fast"). That method uses implicit Fourier surrogates. The choice of
wavelet coherence (method flag containing "coh") or the real part of
the cross-wavelet
transform (method flag containing "ReXWT") depends mainly
on treatment of out-of-phase
relationships. The "ReXWT" is more akin to a correlation coefficient in that
strong in-phase relationships approach 1 and strong antiphase relationships approach -1.
Wavelet coherence allows any phase relationship and ranges from 0 to 1. Power normalization
is applied for "coh" and for "ReXWT". All significance tests are one-tailed.
Synchrony matrices for significance-based methods when weighted is TRUE
contain 1 minus the p-values.
Clustering is performed using the the eigenvector-based modularity method of Newman (2006).
clust returns an object of class clust. Slots are:
dat |
The input |
times |
The input |
coords |
The input |
methodspecs |
A list with elements specifying the method used, and methodological parameters that were in the input. |
adj |
The adjacency matrix that defines the synchrony network |
clusters |
A list with one element for each successive split of the networks into subcomponents carried out by the clustering algorithm. Each element is a vector of length equal to the number of nodes in the original network, giving cluster membership of the nodes. The first element is a vector of all 1s, corresponding to before the first clustering split was performed. |
modres |
A list of the same length as |
mns |
Mean time series for modules. A list of the same length as |
wmfs |
Wavelet mean fields for modules. |
wpmfs |
Wavelet phasor mean fields for modules. |
Jonathan Walter, [email protected]; Daniel Reuman, [email protected]; Lei Zhao, [email protected]
Walter, J. A., et al. (2017) The geography of spatial synchrony. Ecology Letters. doi: 10.1111/ele.12782
Newman M.E.J. (2006). Finding community structure in networks using the eigenvectors of matrices. Phys Rev E, 74, 036104.
Newman M.E.J. (2006) Modularity and community structure in networks. PNAS 103, 8577-8582.
cluseigen, modularity, addwmfs,
addwpmfs,clust_methods, synmat, plotmap,
browseVignettes("wsyn")
sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" res<-clust(dat,times,coords,method,nsurrogs = 50) #nsurrogs should be much higher for a real applicationsig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" res<-clust(dat,times,coords,method,nsurrogs = 50) #nsurrogs should be much higher for a real application
clust classSet, get, summary, and print methods for the clust class.
## S3 method for class 'clust' summary(object, ...) ## S3 method for class 'clust' print(x, ...) ## S3 method for class 'clust' set_times(obj, newval) ## S3 method for class 'clust' set_adj(obj, newval) ## S3 method for class 'clust' set_clusters(obj, newval) ## S3 method for class 'clust' set_modres(obj, newval) ## S3 method for class 'clust' set_mns(obj, newval) ## S3 method for class 'clust' set_dat(obj, newval) ## S3 method for class 'clust' set_coords(obj, newval) ## S3 method for class 'clust' set_methodspecs(obj, newval) ## S3 method for class 'clust' set_wmfs(obj, newval) ## S3 method for class 'clust' set_wpmfs(obj, newval) ## S3 method for class 'clust' get_times(obj) ## S3 method for class 'clust' get_adj(obj) ## S3 method for class 'clust' get_clusters(obj) ## S3 method for class 'clust' get_modres(obj) ## S3 method for class 'clust' get_mns(obj) ## S3 method for class 'clust' get_dat(obj) ## S3 method for class 'clust' get_coords(obj) ## S3 method for class 'clust' get_methodspec(obj) ## S3 method for class 'clust' get_wmfs(obj) ## S3 method for class 'clust' get_wpmfs(obj)## S3 method for class 'clust' summary(object, ...) ## S3 method for class 'clust' print(x, ...) ## S3 method for class 'clust' set_times(obj, newval) ## S3 method for class 'clust' set_adj(obj, newval) ## S3 method for class 'clust' set_clusters(obj, newval) ## S3 method for class 'clust' set_modres(obj, newval) ## S3 method for class 'clust' set_mns(obj, newval) ## S3 method for class 'clust' set_dat(obj, newval) ## S3 method for class 'clust' set_coords(obj, newval) ## S3 method for class 'clust' set_methodspecs(obj, newval) ## S3 method for class 'clust' set_wmfs(obj, newval) ## S3 method for class 'clust' set_wpmfs(obj, newval) ## S3 method for class 'clust' get_times(obj) ## S3 method for class 'clust' get_adj(obj) ## S3 method for class 'clust' get_clusters(obj) ## S3 method for class 'clust' get_modres(obj) ## S3 method for class 'clust' get_mns(obj) ## S3 method for class 'clust' get_dat(obj) ## S3 method for class 'clust' get_coords(obj) ## S3 method for class 'clust' get_methodspec(obj) ## S3 method for class 'clust' get_wmfs(obj) ## S3 method for class 'clust' get_wpmfs(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.clust produces a summary of a clust object.
A print.clust method is also available. For clust objects,
set_* and get_* methods are available for all slots (see
the documentation for clust for a list). The set_* methods
just throw an error, to prevent breaking the consistency between the
slots of a clust object.
Daniel Reuman, [email protected]
sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" h<-clust(dat,times,coords,method,nsurrogs = 50) #nsurrogs should be much higher for a real application get_times(h) summary(h) print(h)sig<-matrix(.8,5,5) diag(sig)<-1 lents<-50 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(lents,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(lents),times=5),lents,5)) dat2<-t(matrix(rep(rnorm(lents),times=5),lents,5)) } dat<-rbind(dat1,dat2) times<-1:lents dat<-cleandat(dat,times,clev=1)$cdat coords<-data.frame(Y=rep(0,10),X=1:10) method<-"coh.sig.fast" h<-clust(dat,times,coords,method,nsurrogs = 50) #nsurrogs should be much higher for a real application get_times(h) summary(h) print(h)
Wavelet coherence and wavelet phase coherence, spatial or for single time series.
Also the generator function for the coh class, which inherits from the list
class.
coh( dat1, dat2, times, norm, sigmethod = "none", nrand = 1000, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1 )coh( dat1, dat2, times, norm, sigmethod = "none", nrand = 1000, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1 )
dat1 |
A locations (rows) x time (columns) matrix (for spatial coherence), or a single time series |
dat2 |
Same format as dat1, same locations and times |
times |
The times at which measurements were made, spacing 1 |
norm |
The normalization of wavelet transforms to use. Controls the version of the coherence that is performed. One of "none", "phase", "powall", "powind". See details. |
sigmethod |
The method for significance testing. One of "none", "fftsurrog1", "fftsurrog2", "fftsurrog12", "aaftsurrog1", "aaftsurrog2", "aaftsurrog12", "fast". See details. |
nrand |
Number of surrogate randomizations to use for significance testing. |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation guaranteed to be examined |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope |
If the dimensions of dat1 and dat2 are by
( is 1 for
vector dat1 and dat2), and if the wavelet transform of the th row
of dati is denoted , then the coherence is the
average, over all
locations and times for which wavelet transforms are
available, of the quantity
, where the represents
complex conjugation and
is a normalization of the wavelet
transform. The normalization used depends
on norm. If norm is "none" then raw wavelet transforms are used.
If norm is "phase" then
,
which gives the wavelet phase coherence, or the spatial wavelet phase coherence if .
If norm is "powall" then the normalization is that descibed in the "Wavelet
mean field" section of the Methods of Sheppard et al. (2016), giving the version of the
coherence that was there called simply the wavelet coherence, or the spatial wavelet
coherence if . If norm is "powind",
then is obtained
by dividing by the square root of the average of
over the times for
which it is defined; this is done
separately for each and .
The slot signif is NA if sigmethod is "none". Otherwise, and
if sigmethod is not "fast", then signif$coher is the same as
coher, and signif$scoher is a matrix of dimensions nrand by
length(coher) with rows with magnitudes equal to coherences of surrogate
datasets, computed using
the normalization specified by norm. The type of surrogate used (Fourier surrogates
or amplitude adjusted Fourier surrogates, see surrog), as well as which of the
datasets surrogates are computed on (dat1, dat2, or both) is determined by
sigmethod. The first part of the value of sigmethod specifies the
type of surrogate used, and the numbers in the second part (1, 2, or 12) specify
whether surrogates are applied to dat1, dat2, or both, respectively.
Synchrony-preserving surrogates are used. A variety of
statements of significance (or lack thereof) can be made
by comparing signif$coher with signif$scoher (see the plotmag,
plotrank, and bandtest methods
for the coh class). If sigmethod is
"fast", the fast algorithm of Sheppard et al. (2017) is used. In that case
signif$coher can be compared to signif$scoher to make significance
statements about the coherence in exactly the same way, but signif$coher will no
longer precisely equal coher, and coher should not be compared
directly to signif$scoher. Statements about significance of the coherence
should be made using signif$coher and signif$scoher, whereas coher
should be used whenever the actual value of the coherence is needed. No fast algorithm
exists for norm equal to "phase" (the phase coherence; Sheppard et al, 2017),
so if norm is "phase" and sigmethod is "fast", the function
throws an error.
The slots ranks and bandp are empty on an initial call to coh.
They are made to compute and hold
aggregate significance results over any timescale band of choice. These are filled in
when needed by other methods, see plotrank and bandtest.
Regardless of what the variables represent, the normalized transform of dat1 is multiplied by the conjugate of the normalized transform of dat2. Thus, a positive phase of the coherence indicates dat1 would be leading dat2.
coh returns an object of class coh. Slots are:
dat1, dat2
|
The input data |
times |
The times associated with the data |
sigmethod |
The method for significance testing, as inputted. |
norm |
The normalization of the wavelet transforms that will be used in computing the coherence. Different values result in different versions of the coherence. One of "none", "phase", "powall", "powind". See details. |
wtopt |
The inputted wavelet transform options scale.min, scale.max.input, sigma, f0 in a list |
timescales |
The timescales associated with the coherence |
coher |
The complex magnitude of this quantity is the coherence, calculated in the usual way (which depends
on |
signif |
A list with information from the significance testing. Elements are |
ranks |
A list with ranking information for |
bandp |
A data frame containing results of computing significances of the coherence across timescale bands.
Empty on an initial call to |
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
Sheppard, L.W., et al. (2017) Rapid surrogate testing of wavelet coherences. European Physical Journal, Nonlinear and Biomedical Physics, 5, 1. DOI: 10.1051/epjnbp/2017000
cleandat, coh_methods, bandtest, plotmag,
plotphase, plotrank, browseVignettes("wsyn")
times<-1:100 dat1<-matrix(rnorm(1000),10,100) dat2<-matrix(rnorm(1000),10,100) dat1<-cleandat(dat1,times,1)$cdat dat2<-cleandat(dat2,times,1)$cdat norm<-"powall" sigmethod<-"fast" nrand<-10 res<-coh(dat1,dat2,times,norm,sigmethod,nrand) #for real applications, use a much bigger nrandtimes<-1:100 dat1<-matrix(rnorm(1000),10,100) dat2<-matrix(rnorm(1000),10,100) dat1<-cleandat(dat1,times,1)$cdat dat2<-cleandat(dat2,times,1)$cdat norm<-"powall" sigmethod<-"fast" nrand<-10 res<-coh(dat1,dat2,times,norm,sigmethod,nrand) #for real applications, use a much bigger nrand
coh classSet, get, summary, and print methods for the coh class.
## S3 method for class 'coh' summary(object, ...) ## S3 method for class 'coh' print(x, ...) ## S3 method for class 'coh' set_times(obj, newval) ## S3 method for class 'coh' set_timescales(obj, newval) ## S3 method for class 'coh' set_coher(obj, newval) ## S3 method for class 'coh' set_dat1(obj, newval) ## S3 method for class 'coh' set_dat2(obj, newval) ## S3 method for class 'coh' set_wtopt(obj, newval) ## S3 method for class 'coh' set_norm(obj, newval) ## S3 method for class 'coh' set_sigmethod(obj, newval) ## S3 method for class 'coh' set_signif(obj, newval) ## S3 method for class 'coh' set_ranks(obj, newval) ## S3 method for class 'coh' set_bandp(obj, newval) ## S3 method for class 'coh' get_times(obj) ## S3 method for class 'coh' get_timescales(obj) ## S3 method for class 'coh' get_coher(obj) ## S3 method for class 'coh' get_dat1(obj) ## S3 method for class 'coh' get_dat2(obj) ## S3 method for class 'coh' get_wtopt(obj) ## S3 method for class 'coh' get_norm(obj) ## S3 method for class 'coh' get_sigmethod(obj) ## S3 method for class 'coh' get_signif(obj) ## S3 method for class 'coh' get_ranks(obj) ## S3 method for class 'coh' get_bandp(obj)## S3 method for class 'coh' summary(object, ...) ## S3 method for class 'coh' print(x, ...) ## S3 method for class 'coh' set_times(obj, newval) ## S3 method for class 'coh' set_timescales(obj, newval) ## S3 method for class 'coh' set_coher(obj, newval) ## S3 method for class 'coh' set_dat1(obj, newval) ## S3 method for class 'coh' set_dat2(obj, newval) ## S3 method for class 'coh' set_wtopt(obj, newval) ## S3 method for class 'coh' set_norm(obj, newval) ## S3 method for class 'coh' set_sigmethod(obj, newval) ## S3 method for class 'coh' set_signif(obj, newval) ## S3 method for class 'coh' set_ranks(obj, newval) ## S3 method for class 'coh' set_bandp(obj, newval) ## S3 method for class 'coh' get_times(obj) ## S3 method for class 'coh' get_timescales(obj) ## S3 method for class 'coh' get_coher(obj) ## S3 method for class 'coh' get_dat1(obj) ## S3 method for class 'coh' get_dat2(obj) ## S3 method for class 'coh' get_wtopt(obj) ## S3 method for class 'coh' get_norm(obj) ## S3 method for class 'coh' get_sigmethod(obj) ## S3 method for class 'coh' get_signif(obj) ## S3 method for class 'coh' get_ranks(obj) ## S3 method for class 'coh' get_bandp(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.coh produces a summary of a coh object.
A print.coh method is also available. For coh objects,
set_* and get_* methods are available for all slots (see
the documentation for coh for a list). The set_* methods
just throw an error, to prevent breaking the consistency between the
slots of a coh object.
Daniel Reuman, [email protected]
times<-1:100 dat1<-matrix(rnorm(1000),10,100) dat2<-matrix(rnorm(1000),10,100) dat1<-cleandat(dat1,times,1)$cdat dat2<-cleandat(dat2,times,1)$cdat norm<-"powall" sigmethod<-"fast" nrand<-10 h<-coh(dat1,dat2,times,norm,sigmethod,nrand) get_times(h) summary(h) print(h)times<-1:100 dat1<-matrix(rnorm(1000),10,100) dat2<-matrix(rnorm(1000),10,100) dat1<-cleandat(dat1,times,1)$cdat dat2<-cleandat(dat2,times,1)$cdat norm<-"powall" sigmethod<-"fast" nrand<-10 h<-coh(dat1,dat2,times,norm,sigmethod,nrand) get_times(h) summary(h) print(h)
Error checking whether a times vector and a matrix with each row a time series make a legitimate spatio-temporal data set for wavelet analysis
errcheck_stdat(times, dat, callfunc)errcheck_stdat(times, dat, callfunc)
times |
the times of measurement, spacing 1 |
dat |
each row is a time series - must have at least two rows |
callfunc |
the function calling this one, for error tracking |
errcheck_stdat returns nothing but throws and error if inputs not appropriate
Daniel Reuman, [email protected]
times
Error check whether a vector can represent times at which data suitable for wavelet transforms were measured
errcheck_times(times, callfunc)errcheck_times(times, callfunc)
times |
Tests whether this is a numeric vector with unit-spaced increasing values |
callfunc |
Function calling this one, for better error messaging |
errcheck_times returns nothing but throws and error if the conditions are not met
Daniel Reuman, [email protected]
Error checking whether a times vector and t.series vector make a legitimate time series for wavelet analysis
errcheck_tsdat(times, t.series, callfunc)errcheck_tsdat(times, t.series, callfunc)
times |
times of measurement, spacing 1 |
t.series |
the measurements |
callfunc |
the function from which this one was called, for error tracking |
errcheck_tsdat returns nothing but throws and error if inputs not appropriate
Daniel Reuman, [email protected]
Error check whether inputs are suitable for a tts object
errcheck_tts(times, timescales, values, callfunc)errcheck_tts(times, timescales, values, callfunc)
times |
times of measurement, spacing 1 |
timescales |
timescales of analysis |
values |
a times by timescales matrix |
callfunc |
the function from which this one was called, for error tracking |
errcheck_tts returns nothing but throws and error if inputs not appropriate
Daniel Reuman, [email protected]
Error check the parameters scale.min, scale.max.input, sigma, f0
errcheck_wavparam(scale.min, scale.max.input, sigma, f0, times, callfunc)errcheck_wavparam(scale.min, scale.max.input, sigma, f0, times, callfunc)
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation that is guaranteed to be examined |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope. Defaults to 1. |
times |
The times data were measured at, spacing 1 |
callfunc |
Function calling this one, for better error messaging |
errcheck_wavparam returns nothing but throws and error if the conditions are not met
Daniel Reuman, [email protected]
This is the algorithm of Sheppard et al. (2017) (see references).
fastcohtest( dat1, dat2, scale.min, scale.max.input, sigma, f0, nrand, randnums, randbits, norm )fastcohtest( dat1, dat2, scale.min, scale.max.input, sigma, f0, nrand, randnums, randbits, norm )
dat1 |
A locations (rows) x time (columns) matrix (for spatial coherence), or a single time series |
dat2 |
Same format as |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation guaranteed to be examined |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope |
nrand |
Number of surrogate randomizations to use for significance testing |
randnums |
A bunch of independent random numbers uniformly distributed on (0,1).
There must be |
randbits |
A bunch of random bits (0 or 1). There must be |
norm |
The normalization of wavelet transforms to use. Controls the version of the
coherence that is performed. One of "none", "powall", "powind". See details in
the documentation of |
fastcohtest returns a list with these elements:
timescales |
The timescales used |
coher |
The magnitude of this is the fast-algorithm version of the coherence between
the two datasets, for comparison with |
scoher |
A matrix with |
Internal function, minimal error checking.
Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2017) Rapid surrogate testing of wavelet coherences. European Physical Journal, Nonlinear and Biomedical Physics, 5, 1. DOI: 10.1051/epjnbp/2017000
Creates surrogate time series using Fourier surrogates
fftsurrog(dat, nsurrogs, syncpres)fftsurrog(dat, nsurrogs, syncpres)
dat |
A locations x time matrix of observations |
nsurrogs |
The number of surrogates to produce |
syncpres |
Logical. TRUE for "synchrony preserving" surrogates (same phase randomizations used for all time series). FALSE leads to independent phase randomizations for all time series. |
fftsurrog returns a list of nsurrogs surrogate datasets
For internal use, no error checking
Jonathan Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, LW, et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
Schreiber, T and Schmitz, A (2000) Surrogate time series. Physica D 142, 346-382.
Prichard, D and Theiler, J (1994) Generating surrogate data for time series with several simultaneously measured variables. Physical Review Letters 73, 951-954.
Tests if a graph represented by an adjacency matrix is connected.
is.connected(adj)is.connected(adj)
adj |
An adjacency matrix. Must be a numeric matrix with non-negative entries. |
Idea by Ed Scheinerman, circa 2006. Source: http://www.ams.jhu.edu/~ers/matgraph/; routine: matgraph/@graph/isconnected.m
is.connected returns TRUE or FALSE depending on whether
the graph represented in adj is a connected graph.
Lei Zhao, [email protected]
cluseigen, clust, browseVignettes("wsyn")
g1<-matrix(c(0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0),4,4) is.connected(g1) g2<-matrix(c(0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0),4,4) is.connected(g2)g1<-matrix(c(0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0),4,4) is.connected(g1) g2<-matrix(c(0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0),4,4) is.connected(g2)
Convenience function for converting certain synchrony matrices to unweighted versions
makeunweighted(mat, sigthresh)makeunweighted(mat, sigthresh)
mat |
A synchrony matrix based on significance testing |
sigthresh |
Significance threshold to use |
makeunweighted converts to an unweighted version of the input. Entries of
mat less than sigthresh become a 1, other entries become a 0. The diagonal
is NA.
Internal function, no error checking
Lei Zhao, [email protected], Daniel Reuman [email protected]
Gets the mean phase of a bunch of complex numbers
mnphase(nums)mnphase(nums)
nums |
A vector of complex numbers |
mnphase returns the mean phase
Internal funcion, no error catching
Daniel Reuman, [email protected]
Computes the modularity of partitioning of a graph into sub-graphs. Similar to the
modularity function in the igraph package, but allows negative
edge weights.
modularity(adj, membership, decomp = FALSE)modularity(adj, membership, decomp = FALSE)
adj |
An adjacency matrix, which should be symmetric with zeros on the diagonal. |
membership |
Vector of length equal to the number of graph nodes (columns/rows
of |
decomp |
Logical. If |
The difference between this function and the function modularity
in the package igraph is that this function can be used with an adjacency
matrix with negative elements. This is a common case for matrices arrising from a
for correlation matrix or another synchrony matrix. If the matrix is non-negative,
the result of this function should be exactly the same as the result from
modularity in the igraph package.
modularity returns a list containing the following:
totQ |
The total modularity. This is the only output if |
modQ |
The contribution of each module to the total modularity |
nodeQ |
The contribution of each node to the total modularity |
Adapted from code developed by Robert J. Fletcher, Jr.
Jonathan Walter, [email protected]; Lei Zhao, [email protected]; Daniel Reuman, [email protected]
Fletcher Jr., R.J., et al. (2013) Network modularity reveals critical scales for connectivity in ecology and evolution. Nature Communications. doi: 10.1038//ncomms3572.
Gomez S., Jensen P. & Arenas A. (2009). Analysis of community structure in networks of correlated data. Phys Rev E, 80, 016114.
Newman M.E. (2006). Finding community structure in networks using the eigenvectors of matrices. Phys Rev E, 74, 036104.
clust, cluseigen, browseVignettes("wsyn")
adj<-matrix(0, 10, 10) # create a fake adjacency matrix adj[lower.tri(adj)]<-runif(10*9/2, -1, 1) adj<-adj+t(adj) colnames(adj)<-letters[1:10] m<-cluseigen(adj) z<-modularity(adj, m[[length(m)]], decomp=TRUE)adj<-matrix(0, 10, 10) # create a fake adjacency matrix adj[lower.tri(adj)]<-runif(10*9/2, -1, 1) adj<-adj+t(adj) colnames(adj)<-letters[1:10] m<-cluseigen(adj) z<-modularity(adj, m[[length(m)]], decomp=TRUE)
coh functionA convenience function for performing the normalization step for the coh function.
normforcoh(W, norm)normforcoh(W, norm)
W |
An array of wavelet transforms, locations by times by timescales |
norm |
The normalization of wavelet transforms to use. Controls the version of the coherence that is performed. One of "none", "phase", "powall", "powind". See details section of the documentation for |
normforcoh returns an array the same dimensions as W of normalized transforms
Internal function, no error checking
Daniel Reuman, [email protected]
tts, coh and wlmtest objectsFor plotting the magnitude of values in tts objects (and derived classes)
against time and timescale, and coh and wlmtest objects against timescale
plotmag(object, ...) ## S3 method for class 'tts' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'wt' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'wmf' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'wpmf' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, sigthresh = 0.95, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'coh' plotmag( object, sigthresh = c(0.95, 0.99), bandprows = "all", filename = NA, ... ) ## S3 method for class 'wlmtest' plotmag( object, sigthresh = c(0.95, 0.99), bandprows = "all", filename = NA, ... ) ## Default S3 method: plotmag(object, ...)plotmag(object, ...) ## S3 method for class 'tts' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'wt' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'wmf' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'wpmf' plotmag( object, zlims = NULL, neat = TRUE, colorfill = NULL, sigthresh = 0.95, colorbar = TRUE, title = NULL, filename = NA, ... ) ## S3 method for class 'coh' plotmag( object, sigthresh = c(0.95, 0.99), bandprows = "all", filename = NA, ... ) ## S3 method for class 'wlmtest' plotmag( object, sigthresh = c(0.95, 0.99), bandprows = "all", filename = NA, ... ) ## Default S3 method: plotmag(object, ...)
object |
An object of class |
... |
Additional graphics parameters passed to |
zlims |
z axis limits. If specified, must encompass the range of
|
neat |
Logical. Should timescales with no values be trimmed? |
colorfill |
Color spectrum to use, set through colorRampPalette. Default value NULL produces jet colors from Matlab. |
colorbar |
Logical. Should a colorbar legend be plotted? |
title |
Title for the top of the plot. |
filename |
Filename (without extension), for saving as pdf. Default value NA saves no file and uses the default graphics device. |
sigthresh |
Significance threshold(s). Numeric vector with values between 0 and 1.
Typically 0.95, 0.99, 0.999, etc. For |
bandprows |
The rows of |
For coh (respectively, wlmtest) objects, the modulus of
object$coher (respectively, object$wlmobj$coher) is plotted using a solid red line, and
the modulus of object$signif$coher is plotted using a dashed red line. The two coherences
agree except for sigmethod="fast", for which they are close. The dashed line is what
should be compared to the distribution of surrogate coherences (black lines, which only appear
for coh objects if signif is not NA). Horizontal axis ticks are labeled
as timescales, but are spaced on the axis as log(1/timescale), i.e., log frequencies.
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
tts, wt, wmf, wpmf, coh,
wlmtest, plotphase, bandtest, plotrank,
browseVignettes("wsyn")
#For a wt object time1<-1:100 time2<-101:200 ts1p1<-sin(2*pi*time1/15) ts1p2<-0*time1 ts2p1<-0*time2 ts2p2<-sin(2*pi*time2/8) ts1<-ts1p1+ts1p2 ts2<-ts2p1+ts2p2 ts<-c(ts1,ts2) ra<-rnorm(200,mean=0,sd=0.5) t.series<-ts+ra t.series<-t.series-mean(t.series) times<-c(time1,time2) res<-wt(t.series, times) plotmag(res) #For a wmf object x1<-0:50 x2<-51:100 x<-c(x1,x2) ts1<-c(sin(2*pi*x1/10),sin(2*pi*x2/5))+1.1 dat<-matrix(NA,11,length(x)) for (counter in 1:dim(dat)[1]) { ts2<-3*sin(2*pi*x/3+2*pi*runif(1))+3.1 ts3<-rnorm(length(x),0,1.5) dat[counter,]<-ts1+ts2+ts3 dat[counter,]<-dat[counter,]-mean(dat[counter,]) } times<-x res<-wmf(dat,times) plotmag(res) #similar calls for wpmf, coh, wlm, wlmtest objects #see documentation#For a wt object time1<-1:100 time2<-101:200 ts1p1<-sin(2*pi*time1/15) ts1p2<-0*time1 ts2p1<-0*time2 ts2p2<-sin(2*pi*time2/8) ts1<-ts1p1+ts1p2 ts2<-ts2p1+ts2p2 ts<-c(ts1,ts2) ra<-rnorm(200,mean=0,sd=0.5) t.series<-ts+ra t.series<-t.series-mean(t.series) times<-c(time1,time2) res<-wt(t.series, times) plotmag(res) #For a wmf object x1<-0:50 x2<-51:100 x<-c(x1,x2) ts1<-c(sin(2*pi*x1/10),sin(2*pi*x2/5))+1.1 dat<-matrix(NA,11,length(x)) for (counter in 1:dim(dat)[1]) { ts2<-3*sin(2*pi*x/3+2*pi*runif(1))+3.1 ts3<-rnorm(length(x),0,1.5) dat[counter,]<-ts1+ts2+ts3 dat[counter,]<-dat[counter,]-mean(dat[counter,]) } times<-x res<-wmf(dat,times) plotmag(res) #similar calls for wpmf, coh, wlm, wlmtest objects #see documentation
clust objectProduces a map of the locations of sampling for a clust object, with colors indicating
module (cluster) identity.
The sizes of nodes (locations) are scaled according to the strength of membership in its module.
plotmap( inclust, spltlvl = length(inclust$clusters), nodesize = c(1, 3), filename = NA )plotmap( inclust, spltlvl = length(inclust$clusters), nodesize = c(1, 3), filename = NA )
inclust |
A |
spltlvl |
The split level in the clustering to use. This is the index of inclust$clusters. Default the final split. |
nodesize |
A length = 2 vector giving the minimum and maximum node size for plotting. Defaults to c(1,3). |
filename |
a filename, possibly including path info, but without a file extension. If present,
exports the plot as a .pdf using the specified filename. Default |
plotmap produces a map.
Jonathan Walter, [email protected]
Walter, J. A., et al. (2017) The geography of spatial synchrony. Ecology Letters. doi: 10.1111/ele.12782
clust, browseVignettes("wsyn")
Tmax<-500 tim<-1:Tmax ts1<-sin(2*pi*tim/5) ts1s<-sin(2*pi*tim/5+pi/2) ts2<-sin(2*pi*tim/12) ts2s<-sin(2*pi*tim/12+pi/2) gp1A<-1:2 gp1B<-3:4 gp2A<-5:6 gp2B<-7:8 d<-matrix(NA,Tmax,8) d[,c(gp1A,gp1B)]<-ts1 d[,c(gp2A,gp2B)]<-ts1s d[,c(gp1A,gp2A)]<-d[,c(gp1A,gp2A)]+matrix(ts2,Tmax,4) d[,c(gp1B,gp2B)]<-d[,c(gp1B,gp2B)]+matrix(ts2s,Tmax,4) d<-d+matrix(rnorm(Tmax*8,0,2),Tmax,8) d<-t(d) d<-cleandat(d,1:Tmax,1)$cdat coords<-data.frame(X=c(rep(1,4),rep(2,4)),Y=rep(c(1:2,4:5),times=2)) cl5<-clust(dat=d,times=1:Tmax,coords=coords,method="ReXWT",tsrange=c(4,6)) plotmap(cl5) cl12<-clust(dat=d,times=1:Tmax,coords=coords,method="ReXWT",tsrange=c(11,13)) plotmap(cl12)Tmax<-500 tim<-1:Tmax ts1<-sin(2*pi*tim/5) ts1s<-sin(2*pi*tim/5+pi/2) ts2<-sin(2*pi*tim/12) ts2s<-sin(2*pi*tim/12+pi/2) gp1A<-1:2 gp1B<-3:4 gp2A<-5:6 gp2B<-7:8 d<-matrix(NA,Tmax,8) d[,c(gp1A,gp1B)]<-ts1 d[,c(gp2A,gp2B)]<-ts1s d[,c(gp1A,gp2A)]<-d[,c(gp1A,gp2A)]+matrix(ts2,Tmax,4) d[,c(gp1B,gp2B)]<-d[,c(gp1B,gp2B)]+matrix(ts2s,Tmax,4) d<-d+matrix(rnorm(Tmax*8,0,2),Tmax,8) d<-t(d) d<-cleandat(d,1:Tmax,1)$cdat coords<-data.frame(X=c(rep(1,4),rep(2,4)),Y=rep(c(1:2,4:5),times=2)) cl5<-clust(dat=d,times=1:Tmax,coords=coords,method="ReXWT",tsrange=c(4,6)) plotmap(cl5) cl12<-clust(dat=d,times=1:Tmax,coords=coords,method="ReXWT",tsrange=c(11,13)) plotmap(cl12)
tts and coh objectsFor plotting the phases of values in tts objects (and derived classes)
against time and timescale, and coh objects against timescale
plotphase(object, ...) ## S3 method for class 'tts' plotphase(object, filename = NA, ...) ## S3 method for class 'wt' plotphase(object, filename = NA, ...) ## S3 method for class 'wmf' plotphase(object, filename = NA, ...) ## S3 method for class 'wpmf' plotphase(object, filename = NA, ...) ## S3 method for class 'coh' plotphase(object, bandprows = "all", filename = NA, ...) ## Default S3 method: plotphase(object, ...)plotphase(object, ...) ## S3 method for class 'tts' plotphase(object, filename = NA, ...) ## S3 method for class 'wt' plotphase(object, filename = NA, ...) ## S3 method for class 'wmf' plotphase(object, filename = NA, ...) ## S3 method for class 'wpmf' plotphase(object, filename = NA, ...) ## S3 method for class 'coh' plotphase(object, bandprows = "all", filename = NA, ...) ## Default S3 method: plotphase(object, ...)
object |
A |
... |
Passed from the generic to specific methods. The plotphase.tss method passes it to fields::image.plot. |
filename |
Filename (without extension), for saving as pdf. Default value NA saves no file and uses the default graphics device. |
bandprows |
The rows of |
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
tts, wt, wmf, wpmf, coh,
plotmag, plotrank, browseVignettes("wsyn")
#For a tts object times<-1:100 timescales<-1:100 cplx<-complex(modulus=1,argument=seq(from=-pi,to=pi,length.out=100)) values1<-matrix(cplx,length(times),length(timescales)) tts1<-tts(times,timescales,values1) plotphase(tts1) #For a coh oject times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat res<-coh(dat1=artsig_x,dat2=artsig_y,times=times,norm="powall",sigmethod="fast",nrand=50, f0=0.5,scale.max.input=28) res<-bandtest(res,c(2,4)) res<-bandtest(res,c(4,30)) res<-bandtest(res,c(8,12)) plotphase(res)#For a tts object times<-1:100 timescales<-1:100 cplx<-complex(modulus=1,argument=seq(from=-pi,to=pi,length.out=100)) values1<-matrix(cplx,length(times),length(timescales)) tts1<-tts(times,timescales,values1) plotphase(tts1) #For a coh oject times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat res<-coh(dat1=artsig_x,dat2=artsig_y,times=times,norm="powall",sigmethod="fast",nrand=50, f0=0.5,scale.max.input=28) res<-bandtest(res,c(2,4)) res<-bandtest(res,c(4,30)) res<-bandtest(res,c(8,12)) plotphase(res)
ranks slot for coh and wlmtest objectsPlots the ranks slot for coh and wlmtest objects to help identify statistical
significance of coherence
plotrank(object, ...) ## S3 method for class 'coh' plotrank(object, sigthresh = 0.95, bandprows = "all", filename = NA, ...) ## S3 method for class 'wlmtest' plotrank(object, sigthresh = 0.95, bandprows = "all", filename = NA, ...) ## Default S3 method: plotrank(object, ...)plotrank(object, ...) ## S3 method for class 'coh' plotrank(object, sigthresh = 0.95, bandprows = "all", filename = NA, ...) ## S3 method for class 'wlmtest' plotrank(object, sigthresh = 0.95, bandprows = "all", filename = NA, ...) ## Default S3 method: plotrank(object, ...)
object |
A |
... |
Passed from the generic to specific methods. Not currently used. |
sigthresh |
Significance threshold(s). Numeric vector with values between 0 and 1. Typically 0.95, 0.99, 0.999, etc. The threshhold(s) are plotted on the rank plot as dashed horizontal line(s). |
bandprows |
The rows of |
filename |
Filename (without extension), for saving as pdf. Default value NA saves no file and uses the default graphics device. |
The plot shows the modulus of object$ranks$coher versus log(1/object$timescales).
Horizontal axis ticks are labeled as timescales, but are spaced on the axis as
log(1/timescale), i.e., log frequencies. p-values from object$bandp are displayed
above the rank plot.
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
coh, wlmtest, bandtest, plotphase,
plotmag, browseVignettes("wsyn")
#For a coh object times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat res<-coh(dat1=artsig_x,dat2=artsig_y,times=times,norm="powall",sigmethod="fast", nrand=100,f0=0.5,scale.max.input=28) #use larger nrand for a real application res<-bandtest(res,c(2,4)) res<-bandtest(res,c(8,12)) plotrank(res) #For a wlmtest object, see vignette#For a coh object times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat res<-coh(dat1=artsig_x,dat2=artsig_y,times=times,norm="powall",sigmethod="fast", nrand=100,f0=0.5,scale.max.input=28) #use larger nrand for a real application res<-bandtest(res,c(2,4)) res<-bandtest(res,c(8,12)) plotrank(res) #For a wlmtest object, see vignette
tts objectReturns the power of a tts object, i.e., the mean over
time of the squared magnitude (which is a function of timescale)
power(object) ## S3 method for class 'tts' power(object)power(object) ## S3 method for class 'tts' power(object)
object |
A |
power returns a data frame with columns timescales and power
Daniel Reuman, [email protected]
tts, wt, wmf, wpmf,
browseVignettes("wsyn")
times<-1:10 timescales<-1:10 values<-matrix(rep(complex(modulus=1,argument=2*pi*c(0:9)/10),times=10),10,10) ttsobj<-tts(times,timescales,values) res<-power(ttsobj)times<-1:10 timescales<-1:10 values<-matrix(rep(complex(modulus=1,argument=2*pi*c(0:9)/10),times=10),10,10) ttsobj<-tts(times,timescales,values) res<-power(ttsobj)
Predicted synchrony of a wlm object. This is described in the
first paragraph of Appendix S15 of Sheppard et al (2019).
predsync(wlmobj) ## S3 method for class 'wlm' predsync(wlmobj)predsync(wlmobj) ## S3 method for class 'wlm' predsync(wlmobj)
wlmobj |
A |
predsync returns a tts object. Plotting the magnitude
(see plotmag) displays a picture of predicted synchrony versus time and
timescale that is comparable with the wavelet mean field (see wmf) of
the response variable of the model. Calling the power function on that
tts object should give the same results as one of the columns of output
of syncexpl. Only norm="powall" implemented so far.
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
wlm, tts, plotmag, wmf, power,
syncexpl, browseVignettes("wsyn")
times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]<-ts1+ts2+rnorm(length(times),mean=0,sd=.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=1),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_i<-matrix(rnorm(11*length(times)),11,length(times)) #the irrelevant artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat artsig_i<-cleandat(artsig_i,times,1)$cdat dat<-list(driven=artsig_y,driver=artsig_x,irrelevant=artsig_i) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) res<-predsync(wlmobj)times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]<-ts1+ts2+rnorm(length(times),mean=0,sd=.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=1),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_i<-matrix(rnorm(11*length(times)),11,length(times)) #the irrelevant artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat artsig_i<-cleandat(artsig_i,times,1)$cdat dat<-list(driven=artsig_y,driver=artsig_x,irrelevant=artsig_i) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) res<-predsync(wlmobj)
summary_wsyn classPrint method for summary_wsyn class
## S3 method for class 'summary_wsyn' print(x, ...)## S3 method for class 'summary_wsyn' print(x, ...)
x |
A |
... |
Not currently used. Included for argument consistency with existing generics. |
print.summary_wsyn is called for its effect of
printing to the screen.
Daniel Reuman, [email protected]
tts_methods, wt_methods, wmf_methods, wpmf_methods,
coh_methods, wlm_methods, wlmtest_methods, clust_methods,
browseVignettes("wsyn")
times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values) print(summary(h))times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values) print(summary(h))
wsyn packageSet and get methods for classes in the wsyn package. There
are methods for each slot of each class, named set_* and
get_* for * the slot name. Below are listed function
specs for the generics and the default methods.
set_adj(obj, newval) ## Default S3 method: set_adj(obj, newval) set_clusters(obj, newval) ## Default S3 method: set_clusters(obj, newval) set_modres(obj, newval) ## Default S3 method: set_modres(obj, newval) set_mns(obj, newval) ## Default S3 method: set_mns(obj, newval) set_coords(obj, newval) ## Default S3 method: set_coords(obj, newval) set_methodspecs(obj, newval) ## Default S3 method: set_methodspecs(obj, newval) set_wmfs(obj, newval) ## Default S3 method: set_wmfs(obj, newval) set_wpmfs(obj, newval) ## Default S3 method: set_wpmfs(obj, newval) get_adj(obj) ## Default S3 method: get_adj(obj) get_clusters(obj) ## Default S3 method: get_clusters(obj) get_modres(obj) ## Default S3 method: get_modres(obj) get_mns(obj) ## Default S3 method: get_mns(obj) get_coords(obj) ## Default S3 method: get_coords(obj) get_methodspec(obj) ## Default S3 method: get_methodspec(obj) get_wmfs(obj) ## Default S3 method: get_wmfs(obj) get_wpmfs(obj) ## Default S3 method: get_wpmfs(obj) set_coher(obj, newval) ## Default S3 method: set_coher(obj, newval) set_dat1(obj, newval) ## Default S3 method: set_dat1(obj, newval) set_dat2(obj, newval) ## Default S3 method: set_dat2(obj, newval) set_norm(obj, newval) ## Default S3 method: set_norm(obj, newval) set_sigmethod(obj, newval) ## Default S3 method: set_sigmethod(obj, newval) set_ranks(obj, newval) ## Default S3 method: set_ranks(obj, newval) set_bandp(obj, newval) ## Default S3 method: set_bandp(obj, newval) get_coher(obj) ## Default S3 method: get_coher(obj) get_dat1(obj) ## Default S3 method: get_dat1(obj) get_dat2(obj) ## Default S3 method: get_dat2(obj) get_norm(obj) ## Default S3 method: get_norm(obj) get_sigmethod(obj) ## Default S3 method: get_sigmethod(obj) get_ranks(obj) ## Default S3 method: get_ranks(obj) get_bandp(obj) ## Default S3 method: get_bandp(obj) set_times(obj, newval) ## Default S3 method: set_times(obj, newval) set_timescales(obj, newval) ## Default S3 method: set_timescales(obj, newval) set_values(obj, newval) ## Default S3 method: set_values(obj, newval) get_times(obj) ## Default S3 method: get_times(obj) get_timescales(obj) ## Default S3 method: get_timescales(obj) get_values(obj) ## Default S3 method: get_values(obj) set_coefs(obj, newval) ## Default S3 method: set_coefs(obj, newval) set_modval(obj, newval) ## Default S3 method: set_modval(obj, newval) set_wts(obj, newval) ## Default S3 method: set_wts(obj, newval) get_coefs(obj) ## Default S3 method: get_coefs(obj) get_modval(obj) ## Default S3 method: get_modval(obj) get_wts(obj) ## Default S3 method: get_wts(obj) set_wlmobj(obj, newval) ## Default S3 method: set_wlmobj(obj, newval) set_drop(obj, newval) ## Default S3 method: set_drop(obj, newval) get_wlmobj(obj) ## Default S3 method: get_wlmobj(obj) get_drop(obj) ## Default S3 method: get_drop(obj) set_signif(obj, newval) ## Default S3 method: set_signif(obj, newval) get_signif(obj) ## Default S3 method: get_signif(obj) set_dat(obj, newval) ## Default S3 method: set_dat(obj, newval) set_wtopt(obj, newval) ## Default S3 method: set_wtopt(obj, newval) get_dat(obj) ## Default S3 method: get_dat(obj) get_wtopt(obj) ## Default S3 method: get_wtopt(obj)set_adj(obj, newval) ## Default S3 method: set_adj(obj, newval) set_clusters(obj, newval) ## Default S3 method: set_clusters(obj, newval) set_modres(obj, newval) ## Default S3 method: set_modres(obj, newval) set_mns(obj, newval) ## Default S3 method: set_mns(obj, newval) set_coords(obj, newval) ## Default S3 method: set_coords(obj, newval) set_methodspecs(obj, newval) ## Default S3 method: set_methodspecs(obj, newval) set_wmfs(obj, newval) ## Default S3 method: set_wmfs(obj, newval) set_wpmfs(obj, newval) ## Default S3 method: set_wpmfs(obj, newval) get_adj(obj) ## Default S3 method: get_adj(obj) get_clusters(obj) ## Default S3 method: get_clusters(obj) get_modres(obj) ## Default S3 method: get_modres(obj) get_mns(obj) ## Default S3 method: get_mns(obj) get_coords(obj) ## Default S3 method: get_coords(obj) get_methodspec(obj) ## Default S3 method: get_methodspec(obj) get_wmfs(obj) ## Default S3 method: get_wmfs(obj) get_wpmfs(obj) ## Default S3 method: get_wpmfs(obj) set_coher(obj, newval) ## Default S3 method: set_coher(obj, newval) set_dat1(obj, newval) ## Default S3 method: set_dat1(obj, newval) set_dat2(obj, newval) ## Default S3 method: set_dat2(obj, newval) set_norm(obj, newval) ## Default S3 method: set_norm(obj, newval) set_sigmethod(obj, newval) ## Default S3 method: set_sigmethod(obj, newval) set_ranks(obj, newval) ## Default S3 method: set_ranks(obj, newval) set_bandp(obj, newval) ## Default S3 method: set_bandp(obj, newval) get_coher(obj) ## Default S3 method: get_coher(obj) get_dat1(obj) ## Default S3 method: get_dat1(obj) get_dat2(obj) ## Default S3 method: get_dat2(obj) get_norm(obj) ## Default S3 method: get_norm(obj) get_sigmethod(obj) ## Default S3 method: get_sigmethod(obj) get_ranks(obj) ## Default S3 method: get_ranks(obj) get_bandp(obj) ## Default S3 method: get_bandp(obj) set_times(obj, newval) ## Default S3 method: set_times(obj, newval) set_timescales(obj, newval) ## Default S3 method: set_timescales(obj, newval) set_values(obj, newval) ## Default S3 method: set_values(obj, newval) get_times(obj) ## Default S3 method: get_times(obj) get_timescales(obj) ## Default S3 method: get_timescales(obj) get_values(obj) ## Default S3 method: get_values(obj) set_coefs(obj, newval) ## Default S3 method: set_coefs(obj, newval) set_modval(obj, newval) ## Default S3 method: set_modval(obj, newval) set_wts(obj, newval) ## Default S3 method: set_wts(obj, newval) get_coefs(obj) ## Default S3 method: get_coefs(obj) get_modval(obj) ## Default S3 method: get_modval(obj) get_wts(obj) ## Default S3 method: get_wts(obj) set_wlmobj(obj, newval) ## Default S3 method: set_wlmobj(obj, newval) set_drop(obj, newval) ## Default S3 method: set_drop(obj, newval) get_wlmobj(obj) ## Default S3 method: get_wlmobj(obj) get_drop(obj) ## Default S3 method: get_drop(obj) set_signif(obj, newval) ## Default S3 method: set_signif(obj, newval) get_signif(obj) ## Default S3 method: get_signif(obj) set_dat(obj, newval) ## Default S3 method: set_dat(obj, newval) set_wtopt(obj, newval) ## Default S3 method: set_wtopt(obj, newval) get_dat(obj) ## Default S3 method: get_dat(obj) get_wtopt(obj) ## Default S3 method: get_wtopt(obj)
obj |
An object of one of the classes defined in the package |
newval |
A newvalue of the slot in question, for the |
There are methods for the tts, wt, wmf,
wpmf, coh, wlm, wlmtest, and clust
classes. See documentation for the generator functions for these classes
(which in all cases have the same name as the class) for lists of slots
for each class.
set_* methods throw an error - setting of individual
slots is not allowed, as it breaks consistency with the other slots.
get_* just returns the value in question.
Daniel Reuman, [email protected]
times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values) get_times(h)times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values) get_times(h)
Shifts a vector according to the argument mints
setmints(ts, mints)setmints(ts, mints)
ts |
A vector of numeric values representing a time series |
mints |
The time series is shifted to have this minimum value. Default NA means use the smallest difference between consecutive, distinct sorted values of the time series. NaN means perform no shift. |
setmints returns the shifted vector.
Daniel Reuman, [email protected]
This is an internal function, and no error checking is done.
For significance testing wavelet coherence and other purposes
surrog(dat, nsurrogs, surrtype, syncpres)surrog(dat, nsurrogs, surrtype, syncpres)
dat |
A locations x time matrix of observations (for multiple-time series input), or a single vector |
nsurrogs |
The number of surrogates to produce |
surrtype |
Either "fft" (for Fourier surrogates) or "aaft" (for amplitude adjusted Fourier surrogates). Fourier surrogates are appropriate for time series with normal marginals; otherwise consider aaft surrogates. |
syncpres |
Logical. TRUE for "synchrony preserving" surrogates (same phase randomizations used for all time series). FALSE leads to independent phase randomizations for all time series. |
Fourier surrogates are somewhat faster than aaft surrogates, and may be much faster when
some of the time series in the data have ties. Prenormalization (e.g., using cleandat) can
make it possible to use fft surrogates.
surrog returns a list of nsurrogs surrogate datasets
Jonathan Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, LW, et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
Schreiber, T and Schmitz, A (2000) Surrogate time series. Physica D 142, 346-382.
Prichard, D and Theiler, J (1994) Generating surrogate data for time series with several simultaneously measured variables. Physical Review Letters 73, 951-954.
wpmf, coh, wlmtest, synmat,
browseVignettes("wsyn")
times<-1:100 dat<-sin(2*pi*times/10) nsurrogs<-10 surrtype<-"fft" syncpres<-TRUE res<-surrog(dat,nsurrogs,surrtype,syncpres)times<-1:100 dat<-sin(2*pi*times/10) nsurrogs<-10 surrtype<-"fft" syncpres<-TRUE res<-surrog(dat,nsurrogs,surrtype,syncpres)
Gives amount of synchrony explained by a wavelet linear model, as a function of timescale, and related quantities (see details)
syncexpl(object) ## S3 method for class 'wlm' syncexpl(object)syncexpl(object) ## S3 method for class 'wlm' syncexpl(object)
object |
A |
This function only works for norm="powall" at present. See
Sheppard et al (2018) for details of the meaning and computation of the
columns.
syncexpl returns a data frame with columns for timescales,
sync (the time-averaged square magnitude of the wavelet mean field of the
response transforms), syncexpl (synchrony explained by the model
predictors), columns named for each predictor (synchrony explained by that
predictor), interactions (synchrony explained by all interaction effects),
columns named for each pair of predictors (synchrony explained by individual
pairwise interactions). There are also columns for crossterms and
resids (residuals). The cross terms must be small for a given timescale band for
the other results to be meaningful. All columns are functions of timescales.
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
wlm, predsync, wlmtest,
browseVignettes("wsyn")
times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_i<-matrix(rnorm(11*length(times)),11,length(times)) #the irrelevant artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat artsig_i<-cleandat(artsig_i,times,1)$cdat dat<-list(driven=artsig_y,driver=artsig_x,irrelevant=artsig_i) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) res<-syncexpl(wlmobj)times<-(-3:100) ts1<-sin(2*pi*times/10) ts2<-5*sin(2*pi*times/3) artsig_x<-matrix(NA,11,length(times)) #the driver for (counter in 1:11) { artsig_x[counter,]=ts1+ts2+rnorm(length(times),mean=0,sd=1.5) } times<-0:100 artsig_y<-matrix(NA,11,length(times)) #the driven for (counter1 in 1:11) { for (counter2 in 1:101) { artsig_y[counter1,counter2]<-mean(artsig_x[counter1,counter2:(counter2+2)]) } } artsig_y<-artsig_y+matrix(rnorm(length(times)*11,mean=0,sd=3),11,length(times)) artsig_x<-artsig_x[,4:104] artsig_i<-matrix(rnorm(11*length(times)),11,length(times)) #the irrelevant artsig_x<-cleandat(artsig_x,times,1)$cdat artsig_y<-cleandat(artsig_y,times,1)$cdat artsig_i<-cleandat(artsig_i,times,1)$cdat dat<-list(driven=artsig_y,driver=artsig_x,irrelevant=artsig_i) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) res<-syncexpl(wlmobj)
Calculate synchrony matrices using a variety of methods
synmat( dat, times, method, tsrange = c(0, Inf), nsurrogs = 1000, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1, weighted = TRUE, sigthresh = 0.95 )synmat( dat, times, method, tsrange = c(0, Inf), nsurrogs = 1000, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1, weighted = TRUE, sigthresh = 0.95 )
dat |
A locations (rows) x time (columns) matrix of measurements |
times |
The times at which measurements were made, spacing 1 |
method |
Method for synchrony calculation. See details. |
tsrange |
A vector containing the min and max of the focal timescale range. Defaults to all timescales that are valid given choices for scale.min, scale.max.input, f0, sigma. Only used for wavelet-based methods. |
nsurrogs |
Number of surrogates for significance test. Defaults to 1000. Only used for surrogate-based methods. |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. Used only for wavelet-based methods. |
scale.max.input |
The largest scale of fluctuation guaranteed to be examined. Only used for wavelet-based methods. |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. Only used for wavelet-based methods. |
f0 |
The ratio of the period of fluctuation to the width of the envelope. Only used for wavelet-based methods. |
weighted |
If |
sigthresh |
Significance threshold needed, if |
The following values are valid for method:
"pearson", "pearson.sig.std", "pearson.sig.fft",
"pearson.sig.aaft",
"spearman", "spearman.sig.std", "spearman.sig.fft",
"spearman.sig.aaft",
"kendall", "kendall.sig.std", "kendall.sig.fft",
"kendall.sig.aaft",
"ReXWT", "ReXWT.sig.fft", "ReXWT.sig.aaft", "ReXWT.sig.fast",
"coh", "coh.sig.fft", "coh.sig.aaft", "coh.sig.fast",
"phasecoh", "phasecoh.sig.fft", and "phasecoh.sig.aaft".
The first portions of these identifiers correspond to the Pearson, Spearman, and Kendall
correlations, the real part of the cross-wavelet transform, the wavelet coherence, and the
wavelet phase coherence. The second portions of these identifiers, when present, indicates
that significance of the measure specified in the first portion of the identifies is to
be used for establishing the synchrony matrix. Otherwise the value itself is used. The
third part of the method identifier indicates what type of significance is used.
Significance testing is performed using standard approaches (method flag containg
std; for correlation coefficients,
although these are inappropriate for autocorrelated data), or surrogates generated using the
Fourier (method flag containing "fft") or amplitude adjusted Fourier
surrogates ("aaft"). For
"coh" and "ReXWT", the fast testing algorithm of Sheppard et al. (2017) is also
implemented ("fast"). That method uses implicit Fourier surrogates. The choice of
wavelet coherence (method flag containing "coh") or the real part of
the cross-wavelet
transform (method flag containing "ReXWT") depends mainly
on treatment of out-of-phase
relationships. The "ReXWT" is more akin to a correlation coefficient in that
strong in-phase relationships approach 1 and strong antiphase relationships approach -1.
Wavelet coherence allows any phase relationship and ranges from 0 to 1. Power normalization
is applied for "coh" and for "ReXWT". All significance tests are one-tailed.
Synchrony matrices for significance-based methods when weighted is TRUE
contain 1 minus the p-values.
synmat returns a synchrony matrix, of type depending on the method
argument. See details. Diagonal entries are left as NA.
Jonathan Walter, [email protected]; Daniel Reuman, [email protected]; Lei Zhao, [email protected]
Walter, J. A., et al. (2017) The geography of spatial synchrony. Ecology Letters. doi: 10.1111/ele.12782
clust, coh, surrog, browseVignettes("wsyn")
sig<-matrix(.9,5,5) diag(sig)<-1 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(30,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(30,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(30),times=5),30,5)) dat2<-t(matrix(rep(rnorm(30),times=5),30,5)) } dat<-rbind(dat1,dat2) times<-1:30 dat<-cleandat(dat,times,clev=2)$cdat method<-"pearson.sig.fft" res<-synmat(dat,times,method,nsurrogs=100,weighted=FALSE, sigthresh=0.95)sig<-matrix(.9,5,5) diag(sig)<-1 if (requireNamespace("mvtnorm",quietly=TRUE)) { dat1<-t(mvtnorm::rmvnorm(30,mean=rep(0,5),sigma=sig)) dat2<-t(mvtnorm::rmvnorm(30,mean=rep(0,5),sigma=sig)) }else { dat1<-t(matrix(rep(rnorm(30),times=5),30,5)) dat2<-t(matrix(rep(rnorm(30),times=5),30,5)) } dat<-rbind(dat1,dat2) times<-1:30 dat<-cleandat(dat,times,clev=2)$cdat method<-"pearson.sig.fft" res<-synmat(dat,times,method,nsurrogs=100,weighted=FALSE, sigthresh=0.95)
tts classThe tts (time/timescale) class is for matrices for which the rows correspond
to times and the columns correspond to timescales. This is a general class from
which other classes inherit (e.g., wt, wmf, wpmf). tts
inherits from the list class.
tts(times, timescales, values)tts(times, timescales, values)
times |
A numeric vector of increasing real values, spacing 1 |
timescales |
A numeric vector with positive entries |
values |
A complex or numeric matrix of dimensions |
tts returns an object of class tts. Slots are:
times |
a numeric vector of evenly spaced times |
timescales |
a numeric vector of positive timescales |
values |
a complex or numeric matrix of dimensions |
Daniel Reuman, [email protected]
tts_methods, wt, wmf, wpmf,
browseVignettes("wsyn")
times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values)times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values)
tts classSet, get, summary, and print methods for the tts class.
## S3 method for class 'tts' summary(object, ...) ## S3 method for class 'tts' print(x, ...) ## S3 method for class 'tts' set_times(obj, newval) ## S3 method for class 'tts' set_timescales(obj, newval) ## S3 method for class 'tts' set_values(obj, newval) ## S3 method for class 'tts' get_times(obj) ## S3 method for class 'tts' get_timescales(obj) ## S3 method for class 'tts' get_values(obj)## S3 method for class 'tts' summary(object, ...) ## S3 method for class 'tts' print(x, ...) ## S3 method for class 'tts' set_times(obj, newval) ## S3 method for class 'tts' set_timescales(obj, newval) ## S3 method for class 'tts' set_values(obj, newval) ## S3 method for class 'tts' get_times(obj) ## S3 method for class 'tts' get_timescales(obj) ## S3 method for class 'tts' get_values(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.tts produces a summary of a tts object.
A print.tts method is also available. For tts objects,
set_* and get_* methods are available for all slots,
i.e., * equal to times, timescales, and
values. The set_* methods just throw an error. Although
class tts is flexible enough that setting of individual slots
could have been allowed, because wt and other classes are
based on it and because individual slots of those classes should not
be changed, for consistency the same is forced for the tts
class.
Daniel Reuman, [email protected]
times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values) get_times(h) summary(h) print(h)times<-1:10 timescales<-1/c(1:10) values<-matrix(1,length(times),length(timescales)) h<-tts(times,timescales,values) get_times(h) summary(h) print(h)
Creates an array of wavelet transforms from input timeseries
warray(dat, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1)warray(dat, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1)
dat |
A locations (rows) x time (columns) matrix |
times |
A vector of timestep values (e.g. years), spacing 1 |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation that will be examined. Note that if this is set too high relative to the length of the timeseries it will be truncated. |
sigma |
The ratio of each time scale examined relative to the next timescale. Greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope |
warray returns a list containing:
wavarray |
locations x time x timescales array of wavelet transforms |
times |
the time steps specified (e.g., years) |
timescales |
the timescales (1/frequency) computed for the wavelet transforms |
Important for interpreting the phase: the phases grow through time, i.e., they turn anti-clockwise. This function is internal, no error checking.
Lauren Hallett, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Worker/utility function serving the analysis carried out in synmat for methods based on coherence or real part of the cross-wavelet transform.
wavmatwork(dat, times, scale.min, scale.max.input, sigma, f0, norm, treatment)wavmatwork(dat, times, scale.min, scale.max.input, sigma, f0, norm, treatment)
dat |
A locations (rows) x time (columns) matrix of measurements |
times |
The times at which measurements were made, spacing 1 |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. Used only for wavelet-based methods. |
scale.max.input |
The largest scale of fluctuation guaranteed to be examined. Only used for wavelet-based methods. |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. Only used for wavelet-based methods. |
f0 |
The ratio of the period of fluctuation to the width of the envelope. Only used for wavelet-based methods. |
norm |
The normalization of wavelet transforms to be used. One of "none", "phase", "powind". |
treatment |
Either "Mod" or "Re" |
wavmatwork returns a list consisting of:
timescales |
The timescales of analysis |
wavarray |
An array, locations by locations by timescales, containing either the
coherences (for |
Internal function, no error checking done.
Daniel Reuman, [email protected]
Fits wavelet linear models. Also the generator function of the wlm class, which
inherits from the list class.
wlm( dat, times, resp, pred, norm, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1 )wlm( dat, times, resp, pred, norm, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1 )
dat |
A list of matrices representing the data (or in the case of one location, a list of vectors). All the same dimensions (respectively, lengths) |
times |
The times at which measurements were made, spacing 1 |
resp |
Index in dat for the response variable of the model |
pred |
Vector of indices in dat for the predictor variables of the model; must differ from |
norm |
The normalization of wavelet transforms to use. One of "none", "powall", "powind". See details. |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation that will be examined. Note that if this is set too high relative to the length of the timeseries it will be truncated. |
sigma |
The ratio of each time scale examined relative to the next timescale. Greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope |
Normalization is as specified in the documentation for coh, HOWEVER, only
the "powall" option is currently implemented, other choices throw an error. Details
are specified in appendices S7 and S9 of Sheppard et al, 2018. The output modval
is v in appendix S7, and coefs are the betas in equation 12 in that appendix.
wlm returns an object of class wlm. Slots are:
dat |
The input data list, but reordered and subsetted so the response is first and only used predictors are included |
times |
The times associated with the data |
norm |
The input |
wtopt |
The inputted wavelet transform options scale.min, scale.max.input, sigma, f0 in a list |
wts |
List of transforms, normalized as specified in |
timescales |
The timescales associated with the wavelet transforms of the data |
coefs |
A list (data frame, actually) of complex vectors, each of length the same
as |
modval |
The model values. |
coher |
Appropriately normalized version of coherence of the model and response transforms. See details. |
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
wlm_methods, wlmtest, syncexpl, predsync,
browseVignettes("wsyn")
times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-2 pred<-c(1,3,4) norm<-"powall" res<-wlm(dat,times,resp,pred,norm)times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-2 pred<-c(1,3,4) norm<-"powall" res<-wlm(dat,times,resp,pred,norm)
wlm classSet, get, summary, and print methods for the wlm class.
## S3 method for class 'wlm' summary(object, ...) ## S3 method for class 'wlm' print(x, ...) ## S3 method for class 'wlm' set_times(obj, newval) ## S3 method for class 'wlm' set_timescales(obj, newval) ## S3 method for class 'wlm' set_coefs(obj, newval) ## S3 method for class 'wlm' set_modval(obj, newval) ## S3 method for class 'wlm' set_coher(obj, newval) ## S3 method for class 'wlm' set_dat(obj, newval) ## S3 method for class 'wlm' set_wtopt(obj, newval) ## S3 method for class 'wlm' set_norm(obj, newval) ## S3 method for class 'wlm' set_wts(obj, newval) ## S3 method for class 'wlm' get_times(obj) ## S3 method for class 'wlm' get_timescales(obj) ## S3 method for class 'wlm' get_coefs(obj) ## S3 method for class 'wlm' get_modval(obj) ## S3 method for class 'wlm' get_coher(obj) ## S3 method for class 'wlm' get_dat(obj) ## S3 method for class 'wlm' get_wtopt(obj) ## S3 method for class 'wlm' get_norm(obj) ## S3 method for class 'wlm' get_wts(obj)## S3 method for class 'wlm' summary(object, ...) ## S3 method for class 'wlm' print(x, ...) ## S3 method for class 'wlm' set_times(obj, newval) ## S3 method for class 'wlm' set_timescales(obj, newval) ## S3 method for class 'wlm' set_coefs(obj, newval) ## S3 method for class 'wlm' set_modval(obj, newval) ## S3 method for class 'wlm' set_coher(obj, newval) ## S3 method for class 'wlm' set_dat(obj, newval) ## S3 method for class 'wlm' set_wtopt(obj, newval) ## S3 method for class 'wlm' set_norm(obj, newval) ## S3 method for class 'wlm' set_wts(obj, newval) ## S3 method for class 'wlm' get_times(obj) ## S3 method for class 'wlm' get_timescales(obj) ## S3 method for class 'wlm' get_coefs(obj) ## S3 method for class 'wlm' get_modval(obj) ## S3 method for class 'wlm' get_coher(obj) ## S3 method for class 'wlm' get_dat(obj) ## S3 method for class 'wlm' get_wtopt(obj) ## S3 method for class 'wlm' get_norm(obj) ## S3 method for class 'wlm' get_wts(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.wlm produces a summary of a wlm object.
A print.wlm method is also available. For wlm objects,
set_* and get_* methods are available for all slots (see
the documentation for wlm for a list). The set_* methods
just throw an error, to prevent breaking the consistency between the
slots of a wlm object.
Daniel Reuman, [email protected]
times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-2 pred<-c(1,3,4) norm<-"powall" h<-wlm(dat,times,resp,pred,norm) get_times(h) summary(h) print(h)times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-2 pred<-c(1,3,4) norm<-"powall" h<-wlm(dat,times,resp,pred,norm) get_times(h) summary(h) print(h)
Stripped down internal function for doing the fitting
wlmfit(wts, norm)wlmfit(wts, norm)
wts |
List of normalized transforms, normalized as specified in |
norm |
The normalization that was used. One of "none", "powall", "powind". See details. |
Only norm="powall" works now, other options throw an error.
wlmfit returns a list with these elements:
coefs |
Model coefficients |
modval |
The right had side of the model |
coher |
Appropriately normalized coherence of the model and response variable |
Internal function, no error checking done.
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
Compares a wavelet linear model with a nested model. Also the generator function for
the wlmtest class.
wlmtest(wlmobj, drop, sigmethod, nrand = 1000)wlmtest(wlmobj, drop, sigmethod, nrand = 1000)
wlmobj |
A |
drop |
Either names or indices of variables in |
sigmethod |
Method for significance testing. One of " |
nrand |
The number of randomizations to do for significance |
The slot signif provides the core information on significance.
If sigmethod is not "fast", then signif$coher is the same as
wlmobj$coher, and signif$scoher is a matrix of dimensions nrand by
length(signif$coher) with rows equal to coherences between refitted models and the
response-variable transforms, for datasets where the variables specified in drop have
been replaced by surrogates. Normalization as specified in norm is used. The type
of surrogate used (Fourier surrogates or amplitude adjusted Fourier surrogates, see
surrog) is determined by sigmethod ("fft" or "aaft").
Synchrony-preserving surrogates are used. A variety of statements of significance (or lack
thereof) can be made by comparing signif$coher with signif$scoher (see the
plotmag, plotrank, and bandtest methods
for the wlmtest class). If sigmethod is
"fast", a fast algorithm of Lawrence Sheppard is used which is a generalization
to wavelet linear models of the fast algorithm for coherence described in Sheppard et al (2017).
In that case
signif$coher can be compared to signif$scoher to make significance
statements about the coherence in exactly the same way, but signif$coher will no
longer precisely equal wlmobj$coher, and wlmobj$coher should not be compared
directly to signif$scoher. Statements about significance of the coherence
should be made using signif$coher and signif$scoher, whereas wlmobj$coher
should be used whenever the actual value of the coherence is needed.
The slots ranks and bandp are empty on an initial call to wlmtest.
They are made to compute and hold
aggregate significance results over any timescale band of choice. These are filled in
when needed by other methods, see plotrank and bandtest.
wlmtest returns an object of class wlmtest. Slots are:
wlmobj |
The input |
drop |
The input |
signif |
A list with information from the significance testing. Elements are
|
ranks |
A list with ranking information for |
bandp |
A data frame containing results of computing significances across
timescale bands. Empty on an initial call to |
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
Sheppard, L.W., et al. (2017) Rapid surrogate testing of wavelet coherences. European Physical Journal, Nonlinear and Biomedical Physics, 5, 1. DOI: 10.1051/epjnbp/2017000
Sheppard, LW et al. (2019) Synchrony is more than its top-down and climatic parts: interacting Moran effects on phytoplankton in British seas. Plos Computational Biology 15, e1006744. doi: 10.1371/journal.pcbi.1006744
wlm, plotrank, bandtest, coh,
wlmtest_methods, browseVignettes("wsyn")
times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) drop<-3 sigmethod<-"fft" res<-wlmtest(wlmobj,drop,sigmethod,nrand=10)times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) drop<-3 sigmethod<-"fft" res<-wlmtest(wlmobj,drop,sigmethod,nrand=10)
wlmtest classSet, get, summary, and print methods for the wlmtest class.
## S3 method for class 'wlmtest' summary(object, ...) ## S3 method for class 'wlmtest' print(x, ...) ## S3 method for class 'wlmtest' set_wlmobj(obj, newval) ## S3 method for class 'wlmtest' set_drop(obj, newval) ## S3 method for class 'wlmtest' set_signif(obj, newval) ## S3 method for class 'wlmtest' set_ranks(obj, newval) ## S3 method for class 'wlmtest' set_bandp(obj, newval) ## S3 method for class 'wlmtest' get_wlmobj(obj) ## S3 method for class 'wlmtest' get_drop(obj) ## S3 method for class 'wlmtest' get_signif(obj) ## S3 method for class 'wlmtest' get_ranks(obj) ## S3 method for class 'wlmtest' get_bandp(obj)## S3 method for class 'wlmtest' summary(object, ...) ## S3 method for class 'wlmtest' print(x, ...) ## S3 method for class 'wlmtest' set_wlmobj(obj, newval) ## S3 method for class 'wlmtest' set_drop(obj, newval) ## S3 method for class 'wlmtest' set_signif(obj, newval) ## S3 method for class 'wlmtest' set_ranks(obj, newval) ## S3 method for class 'wlmtest' set_bandp(obj, newval) ## S3 method for class 'wlmtest' get_wlmobj(obj) ## S3 method for class 'wlmtest' get_drop(obj) ## S3 method for class 'wlmtest' get_signif(obj) ## S3 method for class 'wlmtest' get_ranks(obj) ## S3 method for class 'wlmtest' get_bandp(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.wlmtest produces a summary of a wlmtest object.
A print.wlmtest method is also available. For wlmtest objects,
set_* and get_* methods are available for all slots (see
the documentation for wlmtest for a list). The set_* methods
just throw an error, to prevent breaking the consistency between the
slots of a wlmtest object.
Daniel Reuman, [email protected]
times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) drop<-3 sigmethod<-"fft" h<-wlmtest(wlmobj,drop,sigmethod,nrand=10) get_times(get_wlmobj(h)) summary(h) print(h)times<-1:30 dat<-list(v1=matrix(rnorm(300),10,30),v2=matrix(rnorm(300),10,30),v3=matrix(rnorm(300),10,30), v4=matrix(rnorm(300),10,30),v5=matrix(rnorm(300),10,30)) dat<-lapply(FUN=function(x){cleandat(x,times,1)$cdat},X=dat) resp<-1 pred<-2:3 norm<-"powall" wlmobj<-wlm(dat,times,resp,pred,norm) drop<-3 sigmethod<-"fft" h<-wlmtest(wlmobj,drop,sigmethod,nrand=10) get_times(get_wlmobj(h)) summary(h) print(h)
wmf class.Computes the wavelet mean field from a matrix of spatiotemporal data. Also the
creator function for the wmf class. The wmf class inherits from the
tts class, which inherits from the list class.
wmf(dat, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1)wmf(dat, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1)
dat |
A locations (rows) x time (columns) matrix |
times |
A vector of time step values (e.g., years), spacing 1 |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation that will be examined. Note that if this is set too high relative to the length of the timeseries it will be truncated. |
sigma |
The ratio of each time scale examined relative to the next timescale. Greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope |
wmf returns an object of class wmf. Slots are:
values |
A matrix of complex numbers containing the wavelet mean field, of dimensions |
times |
The time steps specified (e.g., years) |
timescales |
The timescales (1/frequency) computed for the wavelet transforms |
dat |
The data matrix (locations by time) from which the wmf was computed |
wtopt |
The inputted wavelet transform options scale.min, scale.max.input, sigma, f0 in a list |
Jonathan Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
wmf_methods, tts, wpmf, plotmag,
browseVignettes("wsyn")
times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean wmf<-wmf(dat,times)times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean wmf<-wmf(dat,times)
wmf classSet, get, summary, and print methods for the wmf class.
## S3 method for class 'wmf' summary(object, ...) ## S3 method for class 'wmf' print(x, ...) ## S3 method for class 'wmf' set_times(obj, newval) ## S3 method for class 'wmf' set_timescales(obj, newval) ## S3 method for class 'wmf' set_values(obj, newval) ## S3 method for class 'wmf' set_dat(obj, newval) ## S3 method for class 'wmf' set_wtopt(obj, newval) ## S3 method for class 'wmf' get_times(obj) ## S3 method for class 'wmf' get_timescales(obj) ## S3 method for class 'wmf' get_values(obj) ## S3 method for class 'wmf' get_dat(obj) ## S3 method for class 'wmf' get_wtopt(obj)## S3 method for class 'wmf' summary(object, ...) ## S3 method for class 'wmf' print(x, ...) ## S3 method for class 'wmf' set_times(obj, newval) ## S3 method for class 'wmf' set_timescales(obj, newval) ## S3 method for class 'wmf' set_values(obj, newval) ## S3 method for class 'wmf' set_dat(obj, newval) ## S3 method for class 'wmf' set_wtopt(obj, newval) ## S3 method for class 'wmf' get_times(obj) ## S3 method for class 'wmf' get_timescales(obj) ## S3 method for class 'wmf' get_values(obj) ## S3 method for class 'wmf' get_dat(obj) ## S3 method for class 'wmf' get_wtopt(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.wmf produces a summary of a wmf object.
A print.wmf method is also available. For wmf objects,
set_* and get_* methods are available for all slots,
i.e., * equal to times, timescales, wtopt,
values, and dat. The set_* methods just throw an
error, to prevent breaking the consistency between the slots of a
wmf object.
Daniel Reuman, [email protected]
times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean h<-wmf(dat,times) get_times(h) summary(h) print(h)times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean h<-wmf(dat,times) get_times(h) summary(h) print(h)
Computes the wavelet phasor mean field from a matrix of spatiotemporal data. Also the
creator function for the wpmf class. The wpmf class inherits from the
tts class, which inherits from the list class.
wpmf( dat, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1, sigmethod = "none", nrand = 1000 )wpmf( dat, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1, sigmethod = "none", nrand = 1000 )
dat |
A locations (rows) x time (columns) matrix |
times |
A vector of time step values, spacing 1 |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation guaranteed to be examined |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelop |
sigmethod |
Method for significance testing the wmpf, one of |
nrand |
The number of randomizations to be used for significance testing |
For sigmethod equal to quick, the empirical wpmf is compared to a distribution of
magnitudes of sums of random phasors, using the same number of phasors as there are time series. The signif
output is a list with first element "quick" and second element a vector of nrand magnitudes of sums
of random phasors. For sigmethod equal to fft, the empirical wpmf is compared to wmpfs of
Fourier surrogate datasets. The signif output is a list with first element "fft", second element
equal to nrand, and third element the fraction of surrogate-based wpmf magnitudes that the empirical wpmf
magnitude is greater than (times by timescales matrix). For sigmethod equal to aaft, aaft
surrogates are used instead. Output has similar format to the fft case. Values other than quick,
fft, and aaft for sigmethod result in no significance testing.
wpmf returns an object of class wpmf. Slots are:
values |
A matrix of complex numbers containing the wavelet phasor mean field, of dimensions |
times |
The times associated with the data and the |
timescales |
The timescales associated with the |
signif |
A list with information from the significance testing. Format depends on |
dat |
The data matrix (locations by time) from which the |
wtopt |
The inputted wavelet transform options scale.min, scale.max.input, sigma, f0 in a list |
Thomas Anderson, [email protected], Jon Walter, [email protected]; Lawrence Sheppard, [email protected]; Daniel Reuman, [email protected]
Sheppard, L.W., et al. (2016) Changes in large-scale climate alter spatial synchrony of aphid pests. Nature Climate Change. DOI: 10.1038/nclimate2881
wpmf_methods, wmf, tts, plotmag,
browseVignettes("wsyn")
times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean res<-wpmf(dat,times)times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean res<-wpmf(dat,times)
wpmf classSet, get, summary, and print methods for the wpmf class.
## S3 method for class 'wpmf' summary(object, ...) ## S3 method for class 'wpmf' print(x, ...) ## S3 method for class 'wpmf' set_times(obj, newval) ## S3 method for class 'wpmf' set_timescales(obj, newval) ## S3 method for class 'wpmf' set_values(obj, newval) ## S3 method for class 'wpmf' set_dat(obj, newval) ## S3 method for class 'wpmf' set_wtopt(obj, newval) ## S3 method for class 'wpmf' set_signif(obj, newval) ## S3 method for class 'wpmf' get_times(obj) ## S3 method for class 'wpmf' get_timescales(obj) ## S3 method for class 'wpmf' get_values(obj) ## S3 method for class 'wpmf' get_dat(obj) ## S3 method for class 'wpmf' get_wtopt(obj) ## S3 method for class 'wpmf' get_signif(obj)## S3 method for class 'wpmf' summary(object, ...) ## S3 method for class 'wpmf' print(x, ...) ## S3 method for class 'wpmf' set_times(obj, newval) ## S3 method for class 'wpmf' set_timescales(obj, newval) ## S3 method for class 'wpmf' set_values(obj, newval) ## S3 method for class 'wpmf' set_dat(obj, newval) ## S3 method for class 'wpmf' set_wtopt(obj, newval) ## S3 method for class 'wpmf' set_signif(obj, newval) ## S3 method for class 'wpmf' get_times(obj) ## S3 method for class 'wpmf' get_timescales(obj) ## S3 method for class 'wpmf' get_values(obj) ## S3 method for class 'wpmf' get_dat(obj) ## S3 method for class 'wpmf' get_wtopt(obj) ## S3 method for class 'wpmf' get_signif(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.wpmf produces a summary of a wpmf object.
A print.wpmf method is also available. For wpmf objects,
set_* and get_* methods are available for all slots,
i.e., * equal to times, timescales, wtopt,
values, dat, and signif. The set_* methods just throw an
error, to prevent breaking the consistency between the slots of a
wpmf object.
Daniel Reuman, [email protected]
times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean h<-wpmf(dat,times) get_times(h) summary(h) print(h)times<-1:30 #generate time steps #generate fake count data for 20 locations dat<-matrix(rpois(20*length(times),20),nrow=20,ncol=length(times)) dat<-cleandat(dat=dat,times=times,clev=2)$cdat #detrend and demean h<-wpmf(dat,times) get_times(h) summary(h) print(h)
wt class.Computes the wavelet transform of a timeseries. Also the creator function for the
wt class. The wt class inherits from the tts class, which
inherits from the list class.
wt( t.series, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1 )wt( t.series, times, scale.min = 2, scale.max.input = NULL, sigma = 1.05, f0 = 1 )
t.series |
A timeseries of real values |
times |
A vector of time step values (e.g., years), spacing 1 |
scale.min |
The smallest scale of fluctuation that will be examined. At least 2. |
scale.max.input |
The largest scale of fluctuation that is guaranteed to be examined |
sigma |
The ratio of each time scale examined relative to the next timescale. Should be greater than 1. |
f0 |
The ratio of the period of fluctuation to the width of the envelope. Defaults to 1. |
wt returns an object of class wt. Slots are:
values |
A matrix of complex numbers, of dimensions |
times |
The time steps specified (e.g. years) |
wtopt |
The inputted wavelet transform options scale.min, scale.max.input, sigma, f0 in a list |
timescales |
The timescales (1/frequency) computed for the wavelet transform |
dat |
The data vector from which the transform was computed |
Important for interpreting the phase: the phases grow through time, i.e., they turn anti-clockwise.
Lawrence Sheppard [email protected], Jonathan Walter [email protected], Daniel Reuman [email protected]
wt_methods, tts, plotmag, plotphase,
browseVignettes("wsyn")
time1<-1:100 time2<-101:200 ts1p1<-sin(2*pi*time1/15) ts1p2<-0*time1 ts2p1<-0*time2 ts2p2<-sin(2*pi*time2/8) ts1<-ts1p1+ts1p2 ts2<-ts2p1+ts2p2 ts<-c(ts1,ts2) ra<-rnorm(200,mean=0,sd=0.5) t.series<-ts+ra t.series<-t.series-mean(t.series) times<-c(time1,time2) res<-wt(t.series, times)time1<-1:100 time2<-101:200 ts1p1<-sin(2*pi*time1/15) ts1p2<-0*time1 ts2p1<-0*time2 ts2p2<-sin(2*pi*time2/8) ts1<-ts1p1+ts1p2 ts2<-ts2p1+ts2p2 ts<-c(ts1,ts2) ra<-rnorm(200,mean=0,sd=0.5) t.series<-ts+ra t.series<-t.series-mean(t.series) times<-c(time1,time2) res<-wt(t.series, times)
wt classSet, get, summary, and print methods for the wt class.
## S3 method for class 'wt' summary(object, ...) ## S3 method for class 'wt' print(x, ...) ## S3 method for class 'wt' set_times(obj, newval) ## S3 method for class 'wt' set_timescales(obj, newval) ## S3 method for class 'wt' set_values(obj, newval) ## S3 method for class 'wt' set_dat(obj, newval) ## S3 method for class 'wt' set_wtopt(obj, newval) ## S3 method for class 'wt' get_times(obj) ## S3 method for class 'wt' get_timescales(obj) ## S3 method for class 'wt' get_values(obj) ## S3 method for class 'wt' get_dat(obj) ## S3 method for class 'wt' get_wtopt(obj)## S3 method for class 'wt' summary(object, ...) ## S3 method for class 'wt' print(x, ...) ## S3 method for class 'wt' set_times(obj, newval) ## S3 method for class 'wt' set_timescales(obj, newval) ## S3 method for class 'wt' set_values(obj, newval) ## S3 method for class 'wt' set_dat(obj, newval) ## S3 method for class 'wt' set_wtopt(obj, newval) ## S3 method for class 'wt' get_times(obj) ## S3 method for class 'wt' get_timescales(obj) ## S3 method for class 'wt' get_values(obj) ## S3 method for class 'wt' get_dat(obj) ## S3 method for class 'wt' get_wtopt(obj)
object, x, obj
|
An object of class |
... |
Not currently used. Included for argument consistency with existing generics. |
newval |
A new value, for the |
summary.wt produces a summary of a wt object.
A print.wt method is also available. For wt objects,
set_* and get_* methods are available for all slots,
i.e., * equal to times, timescales, wtopt,
values, and dat. The set_* methods just throw an
error, to prevent breaking the consistency between the slots of a
wt object.
Daniel Reuman, [email protected]
time1<-1:100 time2<-101:200 ts1p1<-sin(2*pi*time1/15) ts1p2<-0*time1 ts2p1<-0*time2 ts2p2<-sin(2*pi*time2/8) ts1<-ts1p1+ts1p2 ts2<-ts2p1+ts2p2 ts<-c(ts1,ts2) ra<-rnorm(200,mean=0,sd=0.5) t.series<-ts+ra t.series<-t.series-mean(t.series) times<-c(time1,time2) h<-wt(t.series, times) get_times(h) summary(h) print(h)time1<-1:100 time2<-101:200 ts1p1<-sin(2*pi*time1/15) ts1p2<-0*time1 ts2p1<-0*time2 ts2p2<-sin(2*pi*time2/8) ts1<-ts1p1+ts1p2 ts2<-ts2p1+ts2p2 ts<-c(ts1,ts2) ra<-rnorm(200,mean=0,sd=0.5) t.series<-ts+ra t.series<-t.series-mean(t.series) times<-c(time1,time2) h<-wt(t.series, times) get_times(h) summary(h) print(h)