Title: | Statistics for Quaternion Temporal Data |
---|---|
Description: | An implementation of statistical tools for the analysis of rotation-valued time series and functional data. It relies on pre-existing quaternion data structure provided by the 'Eigen' 'C++' library. |
Authors: | Lise Bellanger [aut], Pierre Drouin [aut], Aymeric Stamm [aut, cre] , Benjamin Martineau [ctb] |
Maintainer: | Aymeric Stamm <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.0 |
Built: | 2024-11-06 06:41:54 UTC |
Source: | CRAN |
-
for qts
ObjectsThis function implements the pointwise subtraction between two quaternion time series.
## S3 method for class 'qts' x - rhs
## S3 method for class 'qts' x - rhs
x |
An object of class |
rhs |
Either an object of class |
An object of class qts
storing the subtraction of the two
inputs.
vespa64$igp[[1]] - vespa64$igp[[2]]
vespa64$igp[[1]] - vespa64$igp[[2]]
*
for qts
ObjectsThis function implements the pointwise quaternion Hamilton multiplication between two quaternion time series.
## S3 method for class 'qts' x * rhs
## S3 method for class 'qts' x * rhs
x |
An object of class |
rhs |
Either an object of class |
An object of class qts
storing the multiplication of the two
inputs.
vespa64$igp[[1]] * vespa64$igp[[2]]
vespa64$igp[[1]] * vespa64$igp[[2]]
+
for qts
ObjectsThis function implements the pointwise addition between two quaternion time series.
## S3 method for class 'qts' x + rhs
## S3 method for class 'qts' x + rhs
x |
An object of class |
rhs |
Either an object of class |
An object of class qts
storing the addition of the two inputs.
vespa64$igp[[1]] + vespa64$igp[[2]]
vespa64$igp[[1]] + vespa64$igp[[2]]
QTS Sample Concatenation
append(x, ...) ## Default S3 method: append(x, values, after = length(x), ...) ## S3 method for class 'qts_sample' append(x, y, ...)
append(x, ...) ## Default S3 method: append(x, values, after = length(x), ...) ## S3 method for class 'qts_sample' append(x, y, ...)
x |
Either a numeric vector or an object of class |
... |
Extra arguments to be passed on to next methods. |
values |
to be included in the modified vector. |
after |
a subscript, after which the values are to be appended. |
y |
Either a numeric vector or an object of class |
If x
is a numeric vector, the output is a numeric vector containing
the values in x
with the elements of values
appended after the
specified element of x
. If x
is of class qts_sample
, the output is
another object of class qts_sample
containing the elements in x
and
the ones in y
appended after the last element of x
.
append(vespa64$igp, vespa64$igp[1]) append(vespa64$igp, vespa64$igp[[1]])
append(vespa64$igp, vespa64$igp[1]) append(vespa64$igp, vespa64$igp[[1]])
prcomp_qts
objectsThis function creates a visualization of the results of the PCA applied on a sample of QTS and returns the corresponding ggplot2::ggplot object which enable further customization of the plot.
## S3 method for class 'prcomp_qts' autoplot(object, what = "PC1", ...)
## S3 method for class 'prcomp_qts' autoplot(object, what = "PC1", ...)
object |
An object of class |
what |
A string specifying what kind of visualization the user wants to
perform. Choices are words starting with |
... |
If |
A ggplot2::ggplot object.
df <- as_qts_sample(vespa64$igp[1:16]) res_pca <- prcomp(df) # Plot the data points in a PC plane # And color points according to a categorical variable p <- ggplot2::autoplot(res_pca, what = "scores") p + ggplot2::geom_point(ggplot2::aes(color = vespa64$V[1:16]))
df <- as_qts_sample(vespa64$igp[1:16]) res_pca <- prcomp(df) # Plot the data points in a PC plane # And color points according to a categorical variable p <- ggplot2::autoplot(res_pca, what = "scores") p + ggplot2::geom_point(ggplot2::aes(color = vespa64$V[1:16]))
qts
objectsThis function creates a visualization of a QTS and returns the corresponding ggplot2::ggplot object which enable further customization of the plot.
## S3 method for class 'qts' autoplot(object, highlighted_points = NULL, ...)
## S3 method for class 'qts' autoplot(object, highlighted_points = NULL, ...)
object |
An object of class qts. |
highlighted_points |
An integer vector specifying point indices to be
highlighted. Defaults to |
... |
Further arguments to be passed on to next methods. |
A ggplot2::ggplot object.
ggplot2::autoplot(vespa64$igp[[1]])
ggplot2::autoplot(vespa64$igp[[1]])
qts_sample
objectsThis function creates a visualization of a sample of QTS and returns the corresponding ggplot2::ggplot object which enable further customization of the plot.
## S3 method for class 'qts_sample' autoplot( object, memberships = NULL, highlighted = NULL, with_animation = FALSE, ... )
## S3 method for class 'qts_sample' autoplot( object, memberships = NULL, highlighted = NULL, with_animation = FALSE, ... )
object |
An object of class |
memberships |
A vector coercible as factor specifying a group membership
for each QTS in the sample. Defaults to |
highlighted |
A boolean vector specifying whether each QTS in the sample
should be hightlighted. Defaults to |
with_animation |
A boolean value specifying whether to create a an
animated plot or a static ggplot2::ggplot object. Defaults to |
... |
Further arguments to be passed to methods. |
A ggplot2::ggplot object.
ggplot2::autoplot(vespa64$igp)
ggplot2::autoplot(vespa64$igp)
qtsclust
objectsThis function creates a visualization of the clustering results obtained on a sample of QTS and returns the corresponding ggplot2::ggplot object which enable further customization of the plot.
## S3 method for class 'qtsclust' autoplot(object, ...)
## S3 method for class 'qtsclust' autoplot(object, ...)
object |
An object of class |
... |
Further arguments to be passed to other methods. |
A ggplot2::ggplot object.
out <- kmeans(vespa64$igp[1:10], n_clusters = 2) ggplot2::autoplot(out)
out <- kmeans(vespa64$igp[1:10], n_clusters = 2) ggplot2::autoplot(out)
This function operates a centering of the QTS around the geometric mean of its quaternions. This is effectively achieved by left-multiplying each quaternion by the inverse of their geometric mean.
centring(x, standardize = FALSE, keep_summary_stats = FALSE)
centring(x, standardize = FALSE, keep_summary_stats = FALSE)
x |
An object of class |
standardize |
A boolean specifying whether to standardize the QTS in
addition to centering it. Defaults to |
keep_summary_stats |
A boolean specifying whether the mean and standard
deviation used for standardizing the data should be stored in the output
object. Defaults to |
If keep_summary_stats = FALSE
, an object of class qts
in which
quaternions have been centered (and possibly standardized) around their
geometric mean. If keep_summary_stats = TRUE
, a list with three
components:
qts
: an object of class qts
in which quaternions have been centered
(and possibly standardized) around their geometric mean;
mean
: a numeric vector with the quaternion Fréchet mean;
sd
: a numeric value with the quaternion Fréchet standard deviation.
centring(vespa64$igp[[1]])
centring(vespa64$igp[[1]])
This function massages the input quaternion time series to apply DBSCAN clustering on them, with the possibility of separating amplitude and phase variability and of choosing the source of variability through which clusters should be searched.
dbscan(x, ...) ## Default S3 method: dbscan(x, eps, minPts = 5, weights = NULL, borderPoints = TRUE, ...) ## S3 method for class 'qts_sample' dbscan( x, warping_class = c("affine", "dilation", "none", "shift", "srsf"), centroid_type = "mean", metric = c("l2", "pearson"), cluster_on_phase = FALSE, use_fence = FALSE, ... )
dbscan(x, ...) ## Default S3 method: dbscan(x, eps, minPts = 5, weights = NULL, borderPoints = TRUE, ...) ## S3 method for class 'qts_sample' dbscan( x, warping_class = c("affine", "dilation", "none", "shift", "srsf"), centroid_type = "mean", metric = c("l2", "pearson"), cluster_on_phase = FALSE, use_fence = FALSE, ... )
x |
Either a numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns) or an object of class qts_sample. |
... |
additional arguments are passed on to the fixed-radius nearest
neighbor search algorithm. See |
eps |
size (radius) of the epsilon neighborhood. Can be omitted if
|
minPts |
number of minimum points required in the eps neighborhood for core points (including the point itself). |
weights |
numeric; weights for the data points. Only needed to perform weighted clustering. |
borderPoints |
logical; should border points be assigned to clusters.
The default is |
warping_class |
A string specifying the warping class Choices are
|
centroid_type |
A string specifying the type of centroid to compute.
Choices are |
metric |
A character string specifying the distance measure to be used.
This must be one of |
cluster_on_phase |
A boolean specifying whether clustering should be
based on phase variation or amplitude variation. Defaults to |
use_fence |
A boolean specifying whether the fence algorithm should be
used to robustify the algorithm against outliers. Defaults to |
An object of class stats::kmeans
or stats::hclust
or
dbscan_fast
if the input x
is NOT of class qts_sample
. Otherwise,
an object of class qtsclust
which is effectively a list with four
components:
qts_aligned
: An object of class qts_sample
storing the sample of
aligned QTS;
qts_centers
: A list of objects of class qts
representing the centers
of the clusters;
best_clustering
: An object of class fdacluster::caps
storing the
results of the best k-mean alignment result among all initialization that
were tried.
call_name
: A string storing the name of the function that was used to
produce the clustering structure;
call_args
: A list containing the exact arguments that were passed to
the function call_name
that produced this output.
out <- dbscan(vespa64$igp[1:10]) plot(out)
out <- dbscan(vespa64$igp[1:10]) plot(out)
This function computes the first derivative of quaternion time series with respect to time.
differentiate(x) ## S3 method for class 'qts' differentiate(x) ## S3 method for class 'qts_sample' differentiate(x)
differentiate(x) ## S3 method for class 'qts' differentiate(x) ## S3 method for class 'qts_sample' differentiate(x)
x |
An object of class qts or qts_sample. |
An object of the same class as the input argument x
in which
quaternions measure the rotation to be applied to transform attitude at
previous time point to attitude at current time point.
differentiate(vespa64$igp[[1]]) differentiate(vespa64$igp)
differentiate(vespa64$igp[[1]]) differentiate(vespa64$igp)
This function massages an input sample of quaternion time series to turn it into a pairwise distance matrix.
dist(x, metric, ...) ## Default S3 method: dist( x, metric = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"), diag = FALSE, upper = FALSE, p = 2, ... ) ## S3 method for class 'qts_sample' dist( x, metric = c("l2", "pearson", "dtw"), warping_class = c("affine", "dilation", "none", "shift", "srsf"), cluster_on_phase = FALSE, labels = NULL, ... )
dist(x, metric, ...) ## Default S3 method: dist( x, metric = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"), diag = FALSE, upper = FALSE, p = 2, ... ) ## S3 method for class 'qts_sample' dist( x, metric = c("l2", "pearson", "dtw"), warping_class = c("affine", "dilation", "none", "shift", "srsf"), cluster_on_phase = FALSE, labels = NULL, ... )
x |
A numeric matrix, data frame, stats::dist object or object of class qts_sample specifying the sample on which to compute the pairwise distance matrix. |
metric |
A character string specifying the distance measure to be used.
This must be one of |
... |
not used. |
diag |
logical value indicating whether the diagonal of the
distance matrix should be printed by |
upper |
logical value indicating whether the upper triangle of the
distance matrix should be printed by |
p |
The power of the Minkowski distance. |
warping_class |
A string specifying the warping class Choices are
|
cluster_on_phase |
A boolean specifying whether clustering should be
based on phase variation or amplitude variation. Defaults to |
labels |
A character vector specifying curve labels. Defaults to |
An object of class stats::dist.
D <- dist(vespa64$igp[1:5])
D <- dist(vespa64$igp[1:5])
This function evaluates the Dynamic Time Warping (DTW) distance between two quaternion time series (QTS).
DTW( qts1, qts2, resample = TRUE, disable_normalization = FALSE, distance_only = FALSE, step_pattern = dtw::symmetric2 )
DTW( qts1, qts2, resample = TRUE, disable_normalization = FALSE, distance_only = FALSE, step_pattern = dtw::symmetric2 )
qts1 |
An object of class qts. |
qts2 |
An object of class qts. |
resample |
A boolean specifying whether the QTS should be uniformly
resampled on their domain before computing distances. Defaults to |
disable_normalization |
A boolean specifying whether quaternion
normalization should be disabled. Defaults to |
distance_only |
A boolean specifying whether to only compute distance
(no backtrack, faster). Defaults to |
step_pattern |
A dtw::stepPattern specifying the local constraints on the warping path. Defaults to dtw::symmetric2 which uses symmetric and normalizable warping paths with no local slope constraints. See dtw::stepPattern for more information. |
If no evaluation grid is provided, the function assumes that the two input QTS are evaluated on the same grid.
An object of class dtw::dtw storing the dynamic time warping results.
DTW(vespa64$igp[[1]], vespa64$igp[[2]])
DTW(vespa64$igp[[1]], vespa64$igp[[2]])
This function computes the exponential of quaternion time series as the time series of the quaternion exponentials.
## S3 method for class 'qts' exp(x, ...) ## S3 method for class 'qts_sample' exp(x, ...)
## S3 method for class 'qts' exp(x, ...) ## S3 method for class 'qts_sample' exp(x, ...)
x |
An object of class qts or qts_sample. |
... |
Extra arguments to be passed on to next methods. |
An object of the same class as the input argument x
in which
quaternions have been replaced by their exponential.
x <- log(vespa64$igp[[1]]) exp(x) y <- log(vespa64$igp) exp(y)
x <- log(vespa64$igp[[1]]) exp(x) y <- log(vespa64$igp) exp(y)
This function massages the input quaternion time series to apply hierarchical agglomerative clustering on them, with the possibility of separating amplitude and phase variability and of choosing the source of variability through which clusters should be searched.
hclust(x, metric, linkage_criterion, ...) ## Default S3 method: hclust( x, metric = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"), linkage_criterion = c("complete", "average", "single", "ward.D2"), ... ) ## S3 method for class 'qts_sample' hclust( x, metric = c("l2", "pearson"), linkage_criterion = c("complete", "average", "single", "ward.D2"), n_clusters = 1L, warping_class = c("affine", "dilation", "none", "shift", "srsf"), centroid_type = "mean", cluster_on_phase = FALSE, ... )
hclust(x, metric, linkage_criterion, ...) ## Default S3 method: hclust( x, metric = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"), linkage_criterion = c("complete", "average", "single", "ward.D2"), ... ) ## S3 method for class 'qts_sample' hclust( x, metric = c("l2", "pearson"), linkage_criterion = c("complete", "average", "single", "ward.D2"), n_clusters = 1L, warping_class = c("affine", "dilation", "none", "shift", "srsf"), centroid_type = "mean", cluster_on_phase = FALSE, ... )
x |
Either a numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns) or an object of class qts_sample. |
metric |
A character string specifying the distance measure to be used.
This must be one of |
linkage_criterion |
A string specifying which linkage criterion should
be used to compute distances between sets of curves. Choices are
|
... |
Further graphical arguments. E.g., |
n_clusters |
An integer value specifying the number of clusters.
Defaults to |
warping_class |
A string specifying the warping class Choices are
|
centroid_type |
A string specifying the type of centroid to compute.
Choices are |
cluster_on_phase |
A boolean specifying whether clustering should be
based on phase variation or amplitude variation. Defaults to |
An object of class stats::kmeans
or stats::hclust
or
dbscan_fast
if the input x
is NOT of class qts_sample
. Otherwise,
an object of class qtsclust
which is effectively a list with four
components:
qts_aligned
: An object of class qts_sample
storing the sample of
aligned QTS;
qts_centers
: A list of objects of class qts
representing the centers
of the clusters;
best_clustering
: An object of class fdacluster::caps
storing the
results of the best k-mean alignment result among all initialization that
were tried.
call_name
: A string storing the name of the function that was used to
produce the clustering structure;
call_args
: A list containing the exact arguments that were passed to
the function call_name
that produced this output.
out <- hclust(vespa64$igp[1:10], n_clusters = 2) plot(out)
out <- hclust(vespa64$igp[1:10], n_clusters = 2) plot(out)
This function ensures that there are no discontinuities in QTS due to quaternion flips since two unit quaternions q and -q encode the same rotation.
hemispherize(x) ## S3 method for class 'qts' hemispherize(x) ## S3 method for class 'qts_sample' hemispherize(x)
hemispherize(x) ## S3 method for class 'qts' hemispherize(x) ## S3 method for class 'qts_sample' hemispherize(x)
x |
An object of class |
An object of the same class as the input argument x
with no
quaternion flip discontinuities.
hemispherize(vespa64$igp[[1]]) hemispherize(vespa64$igp)
hemispherize(vespa64$igp[[1]]) hemispherize(vespa64$igp)
qts
ObjectsThis function implements the pointwise inverse of a quaternion time series.
inverse_qts(x)
inverse_qts(x)
x |
An object of class |
An object of class qts
storing the inverse of x
.
inverse_qts(vespa64$igp[[1]])
inverse_qts(vespa64$igp[[1]])
This function massages the input quaternion time series to feed them into the k-means alignment algorithm for jointly clustering and aligning the input QTS.
kmeans(x, n_clusters, ...) ## Default S3 method: kmeans( x, n_clusters = 1, iter_max = 10, nstart = 1, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), trace = FALSE, ... ) ## S3 method for class 'qts_sample' kmeans( x, n_clusters = 1L, seeds = NULL, seeding_strategy = c("kmeans++", "exhaustive-kmeans++", "exhaustive", "hclust"), warping_class = c("affine", "dilation", "none", "shift", "srsf"), centroid_type = "mean", metric = c("l2", "pearson"), cluster_on_phase = FALSE, use_fence = FALSE, ... )
kmeans(x, n_clusters, ...) ## Default S3 method: kmeans( x, n_clusters = 1, iter_max = 10, nstart = 1, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"), trace = FALSE, ... ) ## S3 method for class 'qts_sample' kmeans( x, n_clusters = 1L, seeds = NULL, seeding_strategy = c("kmeans++", "exhaustive-kmeans++", "exhaustive", "hclust"), warping_class = c("affine", "dilation", "none", "shift", "srsf"), centroid_type = "mean", metric = c("l2", "pearson"), cluster_on_phase = FALSE, use_fence = FALSE, ... )
x |
Either a numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns) or an object of class qts_sample. |
n_clusters |
An integer value specifying the number of clusters to be look for. |
... |
not used. |
iter_max |
An integer value specifying the maximum number of iterations
for terminating the k-mean algorithm. Defaults to |
nstart |
if |
algorithm |
character: may be abbreviated. Note that
|
trace |
logical or integer number, currently only used in the
default method ( |
seeds |
An integer value or vector specifying the indices of the initial
centroids. If an integer vector, it is interpreted as the indices of the
intial centroids and should therefore be of length |
seeding_strategy |
A character string specifying the strategy for
choosing the initial centroids in case the argument |
warping_class |
A string specifying the warping class Choices are
|
centroid_type |
A string specifying the type of centroid to compute.
Choices are |
metric |
A string specifying the metric used to compare curves. Choices
are |
cluster_on_phase |
A boolean specifying whether clustering should be
based on phase variation or amplitude variation. Defaults to |
use_fence |
A boolean specifying whether the fence algorithm should be
used to robustify the algorithm against outliers. Defaults to |
An object of class stats::kmeans
or stats::hclust
or
dbscan_fast
if the input x
is NOT of class qts_sample
. Otherwise,
an object of class qtsclust
which is effectively a list with four
components:
qts_aligned
: An object of class qts_sample
storing the sample of
aligned QTS;
qts_centers
: A list of objects of class qts
representing the centers
of the clusters;
best_clustering
: An object of class fdacluster::caps
storing the
results of the best k-mean alignment result among all initialization that
were tried.
call_name
: A string storing the name of the function that was used to
produce the clustering structure;
call_args
: A list containing the exact arguments that were passed to
the function call_name
that produced this output.
out <- kmeans(vespa64$igp[1:10], n_clusters = 2)
out <- kmeans(vespa64$igp[1:10], n_clusters = 2)
This function computes the logarithm of quaternion time series as the time series of the quaternion logarithms.
## S3 method for class 'qts' log(x, ...) ## S3 method for class 'qts_sample' log(x, ...)
## S3 method for class 'qts' log(x, ...) ## S3 method for class 'qts_sample' log(x, ...)
x |
An object of class qts or qts_sample. |
... |
Extra arguments to be passed on to next methods. |
An object of the same class as the input argument x
in which
quaternions have been replaced by their logarithm.
log(vespa64$igp[[1]]) log(vespa64$igp)
log(vespa64$igp[[1]]) log(vespa64$igp)
This function computes the pointwise geometric mean of a QTS sample.
## S3 method for class 'qts_sample' mean(x, ...)
## S3 method for class 'qts_sample' mean(x, ...)
x |
An object of class |
... |
Further arguments passed to or from other methods. |
An object of class qts
in which quaternions are the
pointwise geometric mean of the input QTS sample.
mean(vespa64$igp)
mean(vespa64$igp)
This function computes the pointwise geometric median of a QTS sample.
## S3 method for class 'qts_sample' median(x, na.rm = FALSE, ...)
## S3 method for class 'qts_sample' median(x, na.rm = FALSE, ...)
x |
An object of class |
na.rm |
A logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
Further arguments passed to or from other methods. |
An object of class qts
in which quaternions are the
pointwise geometric median of the input QTS sample.
median(vespa64$igp)
median(vespa64$igp)
This function performs QTS smoothing via moving average.
moving_average(x, window_size = 0) ## S3 method for class 'qts' moving_average(x, window_size = 0) ## S3 method for class 'qts_sample' moving_average(x, window_size = 0)
moving_average(x, window_size = 0) ## S3 method for class 'qts' moving_average(x, window_size = 0) ## S3 method for class 'qts_sample' moving_average(x, window_size = 0)
x |
An object of class |
window_size |
An integer value specifying the size of the sliding window
used to compute the median value. Defaults to |
An object of the same class as the input argument x
storing the
smoothed QTS.
moving_average(vespa64$igp[[1]], window_size = 5) moving_average(vespa64$igp, window_size = 5)
moving_average(vespa64$igp[[1]], window_size = 5) moving_average(vespa64$igp, window_size = 5)
This function ensures that all quaternions in the time series are unit quaternions.
normalize(x) ## S3 method for class 'qts' normalize(x) ## S3 method for class 'qts_sample' normalize(x)
normalize(x) ## S3 method for class 'qts' normalize(x) ## S3 method for class 'qts_sample' normalize(x)
x |
An object of class qts or qts_sample. |
An object of the same class as the input argument x
in which
quaternions are unit quaternions.
normalize(vespa64$igp[[1]]) normalize(vespa64$igp)
normalize(vespa64$igp[[1]]) normalize(vespa64$igp)
prcomp_qts
objectsThis function creates a visualization of the results of the PCA applied on a sample of QTS without returning the plot data as an object.
## S3 method for class 'prcomp_qts' plot(x, what = "PC1", ...) ## S3 method for class 'prcomp_qts' screeplot(x, ...)
## S3 method for class 'prcomp_qts' plot(x, what = "PC1", ...) ## S3 method for class 'prcomp_qts' screeplot(x, ...)
x |
An object of class |
what |
A string specifying what kind of visualization the user wants to
perform. Choices are words starting with |
... |
If |
No return value, called for side effects.
df <- as_qts_sample(vespa64$igp[1:16]) res_pca <- prcomp(df) # You can plot the effect of a PC on the mean plot(res_pca, what = "PC1") # You can plot the data points in a PC plane plot(res_pca, what = "scores")
df <- as_qts_sample(vespa64$igp[1:16]) res_pca <- prcomp(df) # You can plot the effect of a PC on the mean plot(res_pca, what = "PC1") # You can plot the data points in a PC plane plot(res_pca, what = "scores")
qts
objectsThis function creates a visualization of a QTS without returning the plot data as an object.
## S3 method for class 'qts' plot(x, highlighted_points = NULL, ...)
## S3 method for class 'qts' plot(x, highlighted_points = NULL, ...)
x |
An object of class qts. |
highlighted_points |
An integer vector specifying point indices to be
highlighted. Defaults to |
... |
Further arguments to be passed on to next methods. |
No return value, called for side effects.
plot(vespa64$igp[[1]])
plot(vespa64$igp[[1]])
qts_sample
objectsThis function creates a visualization of a sample of QTS without returning the corresponding ggplot2::ggplot object
## S3 method for class 'qts_sample' plot(x, memberships = NULL, highlighted = NULL, with_animation = FALSE, ...)
## S3 method for class 'qts_sample' plot(x, memberships = NULL, highlighted = NULL, with_animation = FALSE, ...)
x |
An object of class |
memberships |
A vector coercible as factor specifying a group membership
for each QTS in the sample. Defaults to |
highlighted |
A boolean vector specifying whether each QTS in the sample
should be hightlighted. Defaults to |
with_animation |
A boolean value specifying whether to create a an
animated plot or a static ggplot2::ggplot object. Defaults to |
... |
Further arguments to be passed to methods. |
No return value, called for side effects.
plot(vespa64$igp)
plot(vespa64$igp)
qtsclust
objectsThis function creates a visualization of the clustering results obtained on a sample of QTS without returning the plot data as an object.
## S3 method for class 'qtsclust' plot(x, ...)
## S3 method for class 'qtsclust' plot(x, ...)
x |
An object of class |
... |
Further arguments to be passed to other methods. |
No return value, called for side effects.
out <- kmeans(vespa64$igp[1:10], n_clusters = 2) plot(out)
out <- kmeans(vespa64$igp[1:10], n_clusters = 2) plot(out)
This is the S3
specialization of the function stats::prcomp()
for QTS
samples.
## S3 method for class 'qts_sample' prcomp(x, M = 5, fit = FALSE, ...)
## S3 method for class 'qts_sample' prcomp(x, M = 5, fit = FALSE, ...)
x |
An object of class qts_sample. |
M |
An integer value specifying the number of principal component to
compute. Defaults to |
fit |
A boolean specifying whether the resulting |
... |
Arguments passed to or from other methods. |
The mean_qts
component of the resulting object is the QTS used for
centering. It it part of the prcomp_qts
object because it is needed to
reconstruct the sample from the retained PCs. The prcomp_qts
object also
contains the total variance of the sample and the percentage of variance
explained by each PC.
An object of class prcomp_qts
which is a list with the following
components:
tpca
: An object of class MFPCAfit
as produced by the function
MFPCA::MFPCA()
,
var_props
: A numeric vector storing the percentage of variance explained
by each PC,
total_variance
: A numeric value storing the total variance of the sample,
mean_qts
: An object of class qts containing the mean QTS (used for
centering the QTS sample before projecting it to the tangent space),
principal_qts
: A list of qtss containing the required principal
components.
res_pca <- prcomp(vespa64$igp[1:16])
res_pca <- prcomp(vespa64$igp[1:16])
This function predicts the QTS of a new sample from the PCA decomposition of a previous sample.
## S3 method for class 'prcomp_qts' predict(object, newdata, ...)
## S3 method for class 'prcomp_qts' predict(object, newdata, ...)
object |
An object of class |
newdata |
An object of class |
... |
Additional arguments. Not used here. |
An object of class qts_sample
containing the predicted QTS.
# Fit PCA model pr <- prcomp(vespa64$igp, M = 5) # Predict QTS new_qts <- predict(pr)
# Fit PCA model pr <- prcomp(vespa64$igp, M = 5) # Predict QTS new_qts <- predict(pr)
A collection of functions that implements the QTS class. It currently
provides the as_qts()
function for QTS coercion of tibble::tibble
s
and the is_qts()
function for checking if an object is a QTS.
as_qts(x) is_qts(x) ## S3 method for class 'qts' format(x, digits = 5, ...)
as_qts(x) is_qts(x) ## S3 method for class 'qts' format(x, digits = 5, ...)
x |
A |
digits |
An integer value specifying the number of digits to keep for
printing. Defaults to |
... |
Further arguments passed to or from other methods. |
A quaternion time series (QTS) is stored as a tibble::tibble
with 5
columns:
time
: A first column specifying the time points at which quaternions were
collected;
w
: A second column specifying the first coordinate of the collected
quaternions;
x
: A third column specifying the second coordinate of the collected
quaternions;
y
: A fourth column specifying the third coordinate of the collected
quaternions;
z
: A fifth column specifying the fourth coordinate of the collected
quaternions.
An object of class qts.
qts1 <- vespa64$igp[[1]] qts2 <- as_qts(qts1) is_qts(qts1) is_qts(qts2)
qts1 <- vespa64$igp[[1]] qts2 <- as_qts(qts1) is_qts(qts1) is_qts(qts2)
A collection of functions that implements the QTS sample class. It currently
provides the as_qts_sample()
function for QTS sample coercion of lists of
qts
objects, the is_qts_sample()
function for checking if an object
is a QTS sample and the subset operator.
as_qts_sample(x) is_qts_sample(x) ## S3 method for class 'qts_sample' x[i, simplify = FALSE]
as_qts_sample(x) is_qts_sample(x) ## S3 method for class 'qts_sample' x[i, simplify = FALSE]
x |
A list of |
i |
A valid expression to subset observations from a QTS sample. |
simplify |
A boolean value specifying whether the resulting subset
should be turned into a single QTS in case the subset is of size 1.
Defaults to |
A QTS sample is a collection of quaternion time series (QTS), each of which
is stored as a tibble::tibble
with 5 columns:
time
: A first column specifying the time points at which quaternions were
collected;
w
: A second column specifying the first coordinate of the collected
quaternions;
x
: A third column specifying the second coordinate of the collected
quaternions;
y
: A fourth column specifying the third coordinate of the collected
quaternions;
z
: A fifth column specifying the fourth coordinate of the collected
quaternions.
An object of class qts_sample
.
x <- vespa64$igp y <- as_qts_sample(x) is_qts_sample(x) is_qts_sample(y) x[1] x[1, simplify = TRUE]
x <- vespa64$igp y <- as_qts_sample(x) is_qts_sample(x) is_qts_sample(y) x[1] x[1, simplify = TRUE]
This function converts a quaternion time series into its angle-axis representation.
qts2aats(x)
qts2aats(x)
x |
An object of class qts. |
A time series stored as a tibble::tibble with columns time
,
angle
, ux
, uy
and uz
containing the angle-axis representation of
the input quaternions.
qts2aats(vespa64$igp[[1]])
qts2aats(vespa64$igp[[1]])
This function computes a univariate time series representing the angle between the first and other attitudes.
qts2ats(x, disable_normalization = FALSE)
qts2ats(x, disable_normalization = FALSE)
x |
An object of class qts. |
disable_normalization |
A boolean specifying whether quaternion
normalization should be disabled. Defaults to |
A time series stored as a tibble::tibble with columns time
and
angle
in which angle
measures the angle between the current rotation
and the first one.
qts2ats(vespa64$igp[[1]])
qts2ats(vespa64$igp[[1]])
This function projects a quaternion time series into the space of angular velocities.
qts2avts(x, body_frame = FALSE)
qts2avts(x, body_frame = FALSE)
x |
An object of class qts. |
body_frame |
A boolean specifying whether the fixed frame with respect
to which coordinates of the angular velocity should be computed is the body
frame or the global frame. Defaults to |
A time series stored as a tibble::tibble with columns time
, x
,
y
and z
containing the angular velocity at each time point.
qts2avts(vespa64$igp[[1]])
qts2avts(vespa64$igp[[1]])
This function computes a real-valued time series reporting the pointwise geodesic distance between the two input QTS at each time point.
qts2dts(x, y)
qts2dts(x, y)
x |
An object of class qts. |
y |
An object of class qts. |
The function currently expects that the two input QTS are evaluated on the same time grid.
A time series stored as a tibble::tibble with columns time
and
distance
in which distance
measures the angular distance between the
quaternions of both input QTS at a given time point.
qts2dts(vespa64$igp[[1]], vespa64$igp[[2]])
qts2dts(vespa64$igp[[1]], vespa64$igp[[2]])
This function computes a univariate time series representing the norm of the quaternions.
qts2nts(x, disable_normalization = FALSE)
qts2nts(x, disable_normalization = FALSE)
x |
An object of class qts. |
disable_normalization |
A boolean specifying whether quaternion
normalization should be disabled. Defaults to |
A time series stored as a tibble::tibble with columns time
and
norm
in which norm
measures the angular distance between the current
quaternion and the identity.
qts2nts(vespa64$igp[[1]])
qts2nts(vespa64$igp[[1]])
This function reorients the quaternions in a QTS for representing attitude with respect to the orientation of the sensor at the first time point.
reorient(x, disable_normalization = FALSE) ## S3 method for class 'qts' reorient(x, disable_normalization = FALSE) ## S3 method for class 'qts_sample' reorient(x, disable_normalization = FALSE)
reorient(x, disable_normalization = FALSE) ## S3 method for class 'qts' reorient(x, disable_normalization = FALSE) ## S3 method for class 'qts_sample' reorient(x, disable_normalization = FALSE)
x |
An object of class qts or qts_sample. |
disable_normalization |
A boolean specifying whether quaternion
normalization should be disabled. Defaults to |
An object of the same class as the input argument x
in which
quaternions measure attitude with respect to the orientation of the sensor
at the first time point.
reorient(vespa64$igp[[1]]) reorient(vespa64$igp)
reorient(vespa64$igp[[1]]) reorient(vespa64$igp)
This function performs uniform resampling using SLERP.
resample(x, tmin = NA, tmax = NA, nout = 0L, disable_normalization = FALSE) ## S3 method for class 'qts' resample(x, tmin = NA, tmax = NA, nout = 0L, disable_normalization = FALSE) ## S3 method for class 'qts_sample' resample(x, tmin = NA, tmax = NA, nout = 0L, disable_normalization = FALSE)
resample(x, tmin = NA, tmax = NA, nout = 0L, disable_normalization = FALSE) ## S3 method for class 'qts' resample(x, tmin = NA, tmax = NA, nout = 0L, disable_normalization = FALSE) ## S3 method for class 'qts_sample' resample(x, tmin = NA, tmax = NA, nout = 0L, disable_normalization = FALSE)
x |
An object of class qts or qts_sample. |
tmin |
A numeric value specifying the lower bound of the time interval
over which uniform resampling should take place. It must satisfy |
tmax |
A numeric value specifying the upper bound of the time interval
over which uniform resampling should take place. It must satisfy |
nout |
An integer specifying the size of the uniform grid for time
resampling. Defaults to |
disable_normalization |
A boolean specifying whether quaternion
normalization should be disabled. Defaults to |
An object of the same class as the input argument x
in which
quaternions are uniformly sampled in the range [tmin, tmax]
.
resample(vespa64$igp[[1]]) resample(vespa64$igp)
resample(vespa64$igp[[1]]) resample(vespa64$igp)
This function adds uncorrelated Gaussian noise to the logarithm QTS using an exponential covariance function.
rnorm_qts(n, mean_qts, alpha = 0.01, beta = 0.001)
rnorm_qts(n, mean_qts, alpha = 0.01, beta = 0.001)
n |
An integer specifying how many QTS should be generated. |
mean_qts |
An object of class |
alpha |
A positive scalar specifying the variance of each component of
the log-QTS. Defaults to |
beta |
A positive scalar specifying the exponential weight. Defaults to
|
See exp_cov_function
for details about the roles of
alpha
and beta
in the definition of the covariance operator.
A list of n
objects of class qts
with added noise as
specified by parameters alpha
and beta
.
rnorm_qts(1, vespa64$igp[[1]])
rnorm_qts(1, vespa64$igp[[1]])
QTS Sample Centering and Standardization
scale(x, center = TRUE, scale = TRUE, ...) ## Default S3 method: scale(x, center = TRUE, scale = TRUE, ...) ## S3 method for class 'qts_sample' scale( x, center = TRUE, scale = TRUE, by_row = FALSE, keep_summary_stats = FALSE, ... )
scale(x, center = TRUE, scale = TRUE, ...) ## Default S3 method: scale(x, center = TRUE, scale = TRUE, ...) ## S3 method for class 'qts_sample' scale( x, center = TRUE, scale = TRUE, by_row = FALSE, keep_summary_stats = FALSE, ... )
x |
An object coercible into a numeric matrix or an object of class
|
center |
A boolean specifying whether to center the sample. If set to
|
scale |
A boolean specifying whether to standardize the sample once it
has been centered. Defaults to |
... |
Extra arguments passed on to next methods. |
by_row |
A boolean specifying whether the QTS scaling should happen for
each data point ( |
keep_summary_stats |
A boolean specifying whether the mean and standard
deviation used for standardizing the data should be stored in the output
object. Defaults to |
A list of properly rescaled QTS stored as an object of class
qts_sample
when keep_summary_stats = FALSE
. Otherwise a list with
three components:
rescaled_sample
: a list of properly rescaled QTS stored as an object of
class qts_sample
;
mean
: a list of numeric vectors storing the corresponding quaternion
Fréchet means;
sd
: a numeric vector storing the corresponding quaternion Fréchet
standard deviations.
x <- scale(vespa64$igp) x[[1]]
x <- scale(vespa64$igp) x[[1]]
This function performs a smoothing of a QTS by SLERP interpolation.
smooth(x, ...) ## Default S3 method: smooth( x, kind = c("3RS3R", "3RSS", "3RSR", "3R", "3", "S"), twiceit = FALSE, endrule = c("Tukey", "copy"), do.ends = FALSE, ... ) ## S3 method for class 'qts' smooth(x, alpha = 0.5, ...) ## S3 method for class 'qts_sample' smooth(x, alpha = 0.5, ...)
smooth(x, ...) ## Default S3 method: smooth( x, kind = c("3RS3R", "3RSS", "3RSR", "3R", "3", "S"), twiceit = FALSE, endrule = c("Tukey", "copy"), do.ends = FALSE, ... ) ## S3 method for class 'qts' smooth(x, alpha = 0.5, ...) ## S3 method for class 'qts_sample' smooth(x, alpha = 0.5, ...)
x |
An object of class qts or qts_sample. |
... |
Extra arguments passed on to next methods. |
kind |
a character string indicating the kind of smoother required;
defaults to |
twiceit |
logical, indicating if the result should be ‘twiced’.
Twicing a smoother |
endrule |
a character string indicating the rule for smoothing at the
boundary. Either |
do.ends |
logical, indicating if the 3-splitting of ties should
also happen at the boundaries (ends). This is only used for
|
alpha |
A numeric value in |
An object of the same class as the input argument x
which is a
smooth version of the input QTS.
smooth(vespa64$igp[[1]]) smooth(vespa64$igp)
smooth(vespa64$igp[[1]]) smooth(vespa64$igp)
This function straightens QTS so that the last point equals the first point.
straighten(x) ## S3 method for class 'qts' straighten(x) ## S3 method for class 'qts_sample' straighten(x)
straighten(x) ## S3 method for class 'qts' straighten(x) ## S3 method for class 'qts_sample' straighten(x)
x |
An object of class qts or qts_sample. |
An object of the same class as the input argument x
storing the
straightened QTS.
straighten(vespa64$igp[[1]]) straighten(vespa64$igp)
straighten(vespa64$igp[[1]]) straighten(vespa64$igp)
A set of QTS representing individual gait patterns (IGPs) of individuals collected under a number of varying factors.
vespa
vespa
A tibble
with 320 rows and 7 columns:
V
: a categorical variable with two levels specifying the ID of the
Volunteer
;
E
: a categorical variable with two levels specifying the ID of the
Experimenter
;
S
: a categorical variable with four levels specifying the type of
Sensor
;
P
: a categorical variable with four levels specifying the Position
of
the sensor;
A
: a categorical variable with two levels specifying the ID of the
Acquisition
pathway;
R
: a categorical variable with 5 levels specifying the ID of the
Repetition
;
igp
: A 101x5 tibble
storing a QTS which
represents the IGP of the individual under a specific set of VESPA
conditions.
The IGP measures the hip rotation during a typical gait cycle. Each rotation is expressed with respect to the mean position of the sensor during the gait cycle. Each IGP is then straightened so that it is periodic with a last point matching the first one.
A set of QTS representing individual gait patterns (IGPs) of individuals collected under a number of varying factors.
vespa64
vespa64
A tibble
with 320 rows and 7 columns:
V
: a categorical variable with two levels specifying the ID of the
Volunteer
;
E
: a categorical variable with two levels specifying the ID of the
Experimenter
;
S
: a categorical variable with four levels specifying the type of
Sensor
;
P
: a categorical variable with four levels specifying the Position
of
the sensor;
A
: a categorical variable with two levels specifying the ID of the
Acquisition
pathway;
igp
: A 101x5 tibble
storing a QTS which
represents the IGP of the individual under a specific set of VESPA
conditions.
The IGP measures the hip rotation during a typical gait cycle. Each rotation is expressed with respect to the mean position of the sensor during the gait cycle. Each IGP is then straightened so that it is periodic with a last point matching the first one.
It is essentially a reduced version of the VESPA data set where IGPs have been averaged over the repetition for each set of conditions.