Learn R Programming

squat

The goal of squat is to provide extensions of common statistical methods for the analysis of unit quaternion time series. Available statistical methods for QTS samples are currently:

  • random generation according to the Gaussian functional model via rnorm_qts(),
  • scale(),
  • mean(),
  • median(),
  • distance matrix computation via dist() including the possibility of separating amplitude and phase variability,
  • tangent principal component analysis via prcomp(),
  • k-means with optional alignment via kmeans().

Installation

You can install the official version from CRAN via:

install.packages("squat")

or you can opt to install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("LMJL-Alea/squat")

Example

library(squat)

First, let us visualize the sample of QTS from the vespa64 dataset included in the package. The package provides two ways of doing this: either via a static plot or via an animated one (which uses gganimate behind the scenes and will prompt you to install it in case you have not already).

Here is the static version:

plot(vespa64$igp)

You can also use ggplot2::autoplot() instead of plot() to save the resulting ggplot object for further customization.

Here is the animated version:

p <- ggplot2::autoplot(vespa64$igp, with_animation = TRUE)
gganimate::anim_save("man/figures/README-animated-plot.gif", p)

You can compute the geometric mean of the sample and append it to the sample for visualization:

m <- mean(vespa64$igp)
sample_and_mean <- append(vespa64$igp, m)
plot(sample_and_mean, highlighted = c(rep(FALSE, 64), TRUE))

You can compute the pairwise distance matrix (based on the DTW for now):

D <- dist(
  vespa64$igp,
  is_domain_interval = TRUE,
  transformation = "srvf",
  metric = "l2",
  warping_class = "bpd"
)
C <- exp(-D / (sqrt(2) * sd(D)))
C <- (C - min(C)) / diff(range(C))
C <- C |> 
  as.matrix() |> 
  corrr::as_cordf()
corrr::network_plot(C)
#> Warning: ggrepel: 1 unlabeled data points (too many overlaps). Consider
#> increasing max.overlaps

You can perform tangent principal component analysis and visualize it:

tpca <- prcomp(vespa64$igp)
#> ℹ The maximum number of principal component is 63.
plot(tpca, what = "PC1")
#> The `original_space` boolean argument is not specified. Defaulting to TRUE.
plot(tpca, what = "scores")
#> The `plane` length-2 integer vector argument is not specified. Defaulting to
#> 1:2.
screeplot(tpca)

You can finally perform a k-means clustering and visualize it:

km <- kmeans(
  vespa64$igp,
  n_clusters = 2,
  is_domain_interval = TRUE,
  transformation = "srvf",
  warping_class = "bpd"
)
plot(km)

Copy Link

Version

Install

install.packages('squat')

Monthly Downloads

294

Version

0.5.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Aymeric Stamm

Last Published

January 15th, 2026

Functions in squat (0.5.0)

moving_average

QTS Moving Average
-.qts

Operator - for qts Objects
log

QTS Logarithm
hemispherize

QTS Hemispherization
hclust

QTS Hierarchical Agglomerative Clustering
kmeans

QTS K-Means Alignment Algorithm
inverse_qts

Inverse Operator for qts Objects
exp

QTS Exponential
median.qts_sample

QTS Geometric Median
mean.qts_sample

QTS Geometric Mean
+.qts

Operator + for qts Objects
prcomp.qts_sample

PCA for QTS Sample
plot.qtsclust

Plot for qtsclust objects
plot.prcomp_qts

Plot for prcomp_qts objects
predict.prcomp_qts

Predict QTS from PCA decomposition
normalize

QTS Normalization
plot.qts_sample

Plot for qts_sample objects
qts2aamts

QTS Transformation to Angular Acceleration Magnitude Time Series
qts

QTS Class
plot.qts

Plot for qts objects
qts2avvts

QTS Transformation to Angular Velocity Vector Time Series
qts2aavts

QTS Transformation to Angular Acceleration Vector Time Series
qts2aats

QTS Transformation to Angle-Axis Time Series
qts2ats

QTS Transformation To Angle Time Series
qts2sqts

QTS Transformation to Smoothed Quaternion Time Series
qts2rpyts

QTS Transformation to Roll-Pitch-Yaw Time Series
qts2nts

QTS Transformation To Norm Time Series
qts2avmts

QTS Transformation to Angular Velocity Magnitude Time Series
qts2dts

QTS Transformation To Distance Time Series
qts_sample

QTS Sample Class
squat-package

squat: Statistics for Quaternion Temporal Data
vespa

The VESPA dataset
smooth

QTS Smoothing via SLERP Interpolation
resample

QTS Resampling
scale

QTS Sample Centering and Standardization
straighten

QTS Straightening
vespa64

The VESPA64 dataset
reorient

QTS Reorientation
*.qts

Operator * for qts Objects
rnorm_qts

QTS Random Sampling
differentiate

QTS Differentiation
dbscan

QTS Nearest-Neighbor Clustering
centring

QTS Centering and Standardization
autoplot.prcomp_qts

Plot for prcomp_qts objects
DTW

Dynamic Time Warping for Quaternion Time Series
autoplot.qts_sample

Plot for qts_sample objects
dist

QTS Distance Matrix Computation
append

QTS Sample Concatenation
autoplot.qtsclust

Plot for qtsclust objects
autoplot.qts

Plot for qts objects