Title: | Temporal Eigenfunctions |
---|---|
Description: | Build sets of (asymmetric) one-dimensional, temporal eigenfunctions. The set of eigenfunctions are orthogonal patterns of temporal variation at a range of scales. Two types of temporal eigenfunctions are implemented; i) asymmetric temporal eigenfunctions (ATEs), based on the Asymmetric Eigenvector Map (AEM) method of Blanchet et al (2008), and ii) principal coordinates of temporal neighbour matrices (PCTNs), based on the concept of principal coordinates of neighbour matrices. |
Authors: | Gavin L. Simpson |
Maintainer: | Gavin L. Simpson <[email protected]> |
License: | GPL-2 |
Version: | 0.1-3 |
Built: | 2024-10-24 03:43:31 UTC |
Source: | https://github.com/gavinsimpson/temporalEF |
Generate a set of asymmetric temporal eigenfunctions
ate(x, ...) ## Default S3 method: ate(x, N, weight = FALSE, FUN = NULL, link0 = TRUE, ...) ## S3 method for class 'ate' print(x, digits = 3, ...) ## S3 method for class 'ate' scores(x, choices, ...) ## S3 method for class 'ate' eigenvals(x, ...)
ate(x, ...) ## Default S3 method: ate(x, N, weight = FALSE, FUN = NULL, link0 = TRUE, ...) ## S3 method for class 'ate' print(x, digits = 3, ...) ## S3 method for class 'ate' scores(x, choices, ...) ## S3 method for class 'ate' eigenvals(x, ...)
x |
an R object. For |
... |
additional arguments passed to |
N |
numeric; the number of eigenvectors to return. If not
supplied, N is taken from the appropriate dimension of |
weight |
logical; should a weighting matrix be generated and applied to the link matrix? |
FUN |
a function to be applied to the weighting matrix.
Ignored if |
link0 |
logical; should the link from t[0] be included? |
digits |
numeric; number of digits to display in output. |
choices |
numeric; vector indicating which eigenfunctions to return. |
The asymmetric eigenvector map (AEM) is a recently proposed method for describing orthongonal spatial functions for use in multivariate ordination. AEMs are asymmetric because they apply a directionality to the spatial dependencies modelled by the eigenfunctions. Asymmetric temporal eigenfunctions (ATEs) implement the AEM idea to model patterns of temporal dependence; i.e. a single spatial dimension.
Gavin L. Simpson
tp <- seq_len(10) tefs <- ate(tp) tefs.I <- moranI(tefs) plot(tefs.I)
tp <- seq_len(10) tefs <- ate(tp) tefs.I <- moranI(tefs) plot(tefs.I)
Simple extractor function to access temporal eigenfunctions from various objects. Currently methods for class(es) '"ate"', '"pctn"', and '"tef"' are provided.
eigenfuns(x, ...) ## S3 method for class 'ate' eigenfuns(x, take = NULL, ...) ## S3 method for class 'pctn' eigenfuns(x, take = NULL, ...) ## S3 method for class 'tef' eigenfuns(x, take = NULL, ...)
eigenfuns(x, ...) ## S3 method for class 'ate' eigenfuns(x, take = NULL, ...) ## S3 method for class 'pctn' eigenfuns(x, take = NULL, ...) ## S3 method for class 'tef' eigenfuns(x, take = NULL, ...)
x |
the object from which to extract temporal eigenfunctions |
... |
additional arguments passed to methods |
take |
numeric; which eigenfunctions should be returned |
A data frame with one column per eigenfunction
Gavin L. Simpson
Creates an asymmetric link matrix from provided time points.
makeLinks(tp, link0 = TRUE, dimnames = TRUE)
makeLinks(tp, link0 = TRUE, dimnames = TRUE)
tp |
numeric vector of sorted time points |
link0 |
logical; should the link from t[0] be included? |
dimnames |
logical; should dimnames be attached to the link matrix? |
binary matrix of links between time points. The object is
a square asymmetric matrix with length(tp)
rows and columns.
Rows represent the tp
time points, and columns are the
network links between timepoints.
Gavin L. Simpson
makeWeights
for a matching weight matrix.
tp <- seq_len(10) makeLinks(tp)
tp <- seq_len(10) makeLinks(tp)
A diagonal matrix of weights based on the inverse of time duration between time points.
makeWeightMat(tp, FUN = NULL, link0 = TRUE, dimnames = TRUE, ...)
makeWeightMat(tp, FUN = NULL, link0 = TRUE, dimnames = TRUE, ...)
tp |
numeric vector of sorted time points |
FUN |
a function to apply |
link0 |
logical; should the link from t[0] be included? |
dimnames |
logical; should dimnames by attached to the matrix? |
... |
optional arguments passed to |
a diagonal matrix of weights with dimensions length(tp) - 1
Gavin L. Simpson
tp <- seq_len(10) makeWeightMat(tp)
tp <- seq_len(10) makeWeightMat(tp)
Build a temporal weighting matrix
makeWeights(tp, FUN = NULL, link0 = TRUE, dimnames = TRUE, ...)
makeWeights(tp, FUN = NULL, link0 = TRUE, dimnames = TRUE, ...)
tp |
numeric vector of sorted time points |
FUN |
a function to apply |
link0 |
logical; should the link from t[0] be included? |
dimnames |
logical; should dimnames by attached to the matrix? |
... |
optional arguments passed to |
a square, symmetric matrix of weights.
Gavin L. Simpson
makeLinks
for a matching link matrix
tp <- seq_len(10) makeWeights(tp)
tp <- seq_len(10) makeWeights(tp)
A vector of weights based on the inverse of time duration between time points.
makeWeightVec(tp, FUN = NULL, link0 = TRUE, names = TRUE, ...)
makeWeightVec(tp, FUN = NULL, link0 = TRUE, names = TRUE, ...)
tp |
numeric vector of sorted time points |
FUN |
a function to apply |
link0 |
logical; should the link from t[0] be included? |
names |
logical; should names by attached to the vector? |
... |
optional arguments passed to |
a matrix of weights of length length(tp) - 1
Gavin L. Simpson
tp <- seq_len(10) makeWeightVec(tp)
tp <- seq_len(10) makeWeightVec(tp)
Calculate Moran's I for tempoeral eigenfunctions and assess significant of Moran's I values via a parametric test that assumes asymptotic normality or a permutation test.
moranI(x, ...) ## S3 method for class 'ate' moranI(x, permute = FALSE, alternative = c("two.sided", "greater", "less"), nperm = 999, ...)
moranI(x, ...) ## S3 method for class 'ate' moranI(x, permute = FALSE, alternative = c("two.sided", "greater", "less"), nperm = 999, ...)
x |
an R object of class |
... |
additional arguments passed to methods. |
permute |
logical; test |
alternative |
character; the type of test to perform. The default is |
nperm |
numeric; number of permutations to perform in permutation test if requested. |
Numeric vector of Moran's I statistics
Gavin L. Simpson
Computes the classic PCNM by the principal coordinate analysis of a truncated distance matrix, but for a one-dimensional process.
pctn(x, ...) ## Default S3 method: pctn(x, threshold, distfun = dist, ...) ## S3 method for class 'pctn' print(x, digits = 3, ...) ## S3 method for class 'pctn' scores(x, choices, ...) ## S3 method for class 'pctn' eigenvals(x, ...)
pctn(x, ...) ## Default S3 method: pctn(x, threshold, distfun = dist, ...) ## S3 method for class 'pctn' print(x, digits = 3, ...) ## S3 method for class 'pctn' scores(x, choices, ...) ## S3 method for class 'pctn' eigenvals(x, ...)
x |
an R object. For |
... |
additional arguments passed to other methods or on to
|
threshold |
numeric; threshold beyond which the temporal
separation of smaples is considered equal. The default if no value
is supplied is to find the largest temporal separation between any
two points. Separations greater than the threshold are given a
notional separation of 4 times |
distfun |
function or character string naming a function that
will be used to compute the temporal seperation between samples.
Defaults to |
digits |
numeric; number of digits to display in output. |
choices |
numeric; vector indicating which eigenfunctions to return. |
The default distance coefficient used to compute
temporal separation is the Euclidean distance. If you want to use
a different coefficient, you can supply a suitable function to
argument distfun
. This should be a function that returns an
object of class "dist"
or a square symmetric matrix that can
be coerced to one. Arguments can be passed to distfun
via
....
Gavin L. Simpson
tp <- seq_len(50) mod <- pctn(tp) mod
tp <- seq_len(50) mod <- pctn(tp) mod
A multi-panel layout showing the calculated tempoeral eigenfunctions.
## S3 method for class 'ate' plot(x, pages = 1, ylim, ylab = nams, xlab = "", ask = FALSE, ...)
## S3 method for class 'ate' plot(x, pages = 1, ylim, ylab = nams, xlab = "", ask = FALSE, ...)
x |
an object of class |
pages |
numeric; the number of pages over which to spread the plots of the individual eigenfunction |
ylim |
numeric vector of limits for the y-axis |
xlab , ylab
|
x and y-axis labels |
ask |
logical; should plotting be paused between pages? |
... |
additional arguments passed to |
A plot on the currently active device
Gavin L. Simpson
ate
for creating ATE objects
tp <- seq_len(50) mod <- ate(tp) plot(mod, pages = 2)
tp <- seq_len(50) mod <- ate(tp) plot(mod, pages = 2)
A plot of Moran's I versus time.
## S3 method for class 'moranI' plot(x, alpha = 0.05, type = "b", xlab = "Eigenfunctions", ylab = "Moran's I", pch = 21, bg = "red", col = "black", ...)
## S3 method for class 'moranI' plot(x, alpha = 0.05, type = "b", xlab = "Eigenfunctions", ylab = "Moran's I", pch = 21, bg = "red", col = "black", ...)
x |
an object of class |
alpha |
numeric; level of significance |
type |
character; the type of plotting to use. See
|
xlab |
the label for the x-axis of the plot. |
ylab |
the label for the y-axis of the plot. |
pch |
the plotting character to use |
bg |
fill colour of points |
col |
border colour of points |
... |
additional arguments passed to |
A plot on the current device
Gavin L. Simpson
A multi-panel layout showing the calculated tempoeral eigenfunctions.
## S3 method for class 'pctn' plot(x, pages = 1, ylim, ylab = nams, xlab = "", ask = FALSE, ...)
## S3 method for class 'pctn' plot(x, pages = 1, ylim, ylab = nams, xlab = "", ask = FALSE, ...)
x |
an object of class |
pages |
numeric; the number of pages over which to spread the plots of the individual eigenfunctions |
ylim |
numeric vector of limits for the y-axis |
xlab , ylab
|
x and y-axis labels |
ask |
logical; should plotting be paused between pages? |
... |
additional arguments passed to |
A plot on the currently active device
Gavin L. Simpson
pctn
for creating PCTN objects
tp <- seq_len(50) mod <- pctn(tp) plot(mod, pages = 2)
tp <- seq_len(50) mod <- pctn(tp) plot(mod, pages = 2)
A plot of against
compositional dissimilarity.
## S3 method for class 'timelagAnalysis' plot(x, ...)
## S3 method for class 'timelagAnalysis' plot(x, ...)
x |
an object of class |
... |
additional arguments passed to |
TODO - smoothers etc.
Invisibly returns its input x
.
Gavin L. Simpson
## load analogue for Abernethy data set & distance() if (require("analogue")) { ## Load Abernethy Forest data set data("abernethy", package = "analogue") ## Load Abernethy Forest data set ## Remove the Depth and Age variables abernethy2 <- abernethy[, -(37:38)] ## time lag analysis dij <- as.dist(distance(abernethy2, method = "chord")) tla <- timelag(dij) plot(tla, pch = 19) }
## load analogue for Abernethy data set & distance() if (require("analogue")) { ## Load Abernethy Forest data set data("abernethy", package = "analogue") ## Load Abernethy Forest data set ## Remove the Depth and Age variables abernethy2 <- abernethy[, -(37:38)] ## time lag analysis dij <- as.dist(distance(abernethy2, method = "chord")) tla <- timelag(dij) plot(tla, pch = 19) }
Fits an ordination using temporal eigenfunctions as constraints.
tef(x, ...) ## Default S3 method: tef(x, index, method = c("ate", "aem", "pctn", "pcnm"), ordination = c("rda"), ...)
tef(x, ...) ## Default S3 method: tef(x, index, method = c("ate", "aem", "pctn", "pcnm"), ordination = c("rda"), ...)
x |
community data matrix or data frame |
... |
additional arguments passed to other methods. Arguments are also passed to the function generating the temporal eigenfunctions and the constrained ordination function. |
index |
numeric; the time ordering of the samples from which temporal eigenfunctions will be computed |
method |
character; which method to use to create the temporal eigenfunctions |
ordination |
character; the name of the constrained ordination
function, from the vegan package to use. Only |
TODO
An object of class "tef"
, a list with the following
components:
the fitted constrained ordination.
the computed set of temporal eigenfunctions.
Gavin L. Simpson
Time lag analysis for a multivariate data set
timelag(x, ...) ## S3 method for class 'dist' timelag(x, ...)
timelag(x, ...) ## S3 method for class 'dist' timelag(x, ...)
x |
an R object. Only objects of class |
... |
additional arguments passed to other methods. |
Time lag analysis involves computing the compositional
dissimilarity between samples at lag 1, at lag 2, etc, then the
least squares slope between
and dissimilarity.
Returns an object of class "timelagAnalysis"
, a list
with components
data frame; unpacked set of lags (Lag
) and
compositional dissimilarities (Distance
).
Gavin L. Simpson
## load analogue for Abernethy data set & distance() if (require("analogue")) { ## Load Abernethy Forest data set data("abernethy", package = "analogue") ## Load Abernethy Forest data set ## Remove the Depth and Age variables abernethy2 <- abernethy[, -(37:38)] ## time lag analysis dij <- as.dist(distance(abernethy2, method = "chord")) tla <- timelag(dij) head(tla[[1]]) }
## load analogue for Abernethy data set & distance() if (require("analogue")) { ## Load Abernethy Forest data set data("abernethy", package = "analogue") ## Load Abernethy Forest data set ## Remove the Depth and Age variables abernethy2 <- abernethy[, -(37:38)] ## time lag analysis dij <- as.dist(distance(abernethy2, method = "chord")) tla <- timelag(dij) head(tla[[1]]) }