moveEZ - pronounced move easy

An R package for animated biplots.

Ganey R & Nienkemper-Swanepoel J (2025). moveEZ: Animated Biplots.moveEZ, R package version 1.1.1, https://CRAN.R-project.org/package=moveEZ.
 

Install from Github

GitHub

library(devtools)
install_github("MuViSU/moveEZ")

Background

  • Consider a dataset \({\bf{X}}\) comprising of \(n\) observations and \(p\) continuous variables, along with an additional variable representing “time”.

  • A natural approach is to construct separate biplots for each level of the time variable, enabling the user to explore how samples and variable relationships evolve across time.

  • However, when the time variable includes many levels, this quickly results in an overwhelming number of biplots.

  • The goal of moveEZ is to address this challenge by animating a single biplot across the levels of the time variable, allowing for dynamic visualisation of temporal or sequential changes in the data.

Biplots

  • Singular Value Decomposition
X
n × p
= U
n × p
D
p × p
V′
p × p
  • Representing samples
Z
n × p
= X
n × p
V′
p × p
  • Representing variables
V
p × p

Climate Data

  • Period: 1950 to 2020 (10 year increments)
  • Regions: IPCC regions map
  • IPCC: Intergovernmental Panel on Climate Change
  • Aggregated monthly measurements:
    1. Accumulated precipitation (AccPrec)
    2. Daily evaporation (DailyEva)
    3. Mean temperature (Temp)
    4. Soil moisture (SoilMois)
    5. Wind speed (Wind)
    6. Standardised precipitation index 6-month (SPI6)
Iturbide et al. 2020. An update of IPCC climate reference regions for subcontinental analysis of climate model data: definition and aggregated datasets. Earth System Science Data 12(4):2959-2970.

Source: https://sites.ualberta.ca/~ahamann/data/climateaf.html

Climate Data

PCA biplot

biplotEZ - pronounced biplot easy

library(biplotEZ)
bp <- biplot(Africa_climate, scaled = TRUE) |> 
  PCA(group.aes = Africa_climate$Region) |> 
  samples(opacity = 0.8, 
          col = scales::hue_pal()(10)) |> 
  axes(col="black") |> 
  plot()

Lubbe S, le Roux N, Nienkemper-Swanepoel J, Ganey R, Buys R, Adams Z, Manefeldt P (2025). biplotEZ: EZ-to-Use Biplots. R package version 2.3, https://github.com/MuViSU/biplotEZ.

Fixed Variable Frame

A biplot is first constructed using the full dataset \({\bf{X}}\), and the animation is achieved by slicing the observations according to the “time” variable. In this approach, the variable axes remain fixed and only the sample points are animated over time.

Samples
Z
Variables
V

moveplot()

Using the previously created PCA biplot object bp, the moveplot() function enables animation of the sample points over time. This function is piped with several key arguments:

  • time.var: Specifies the name of the variable in the dataset that represents the temporal or sequential dimension. In this case, the variable “Year” relates to the time variable.

  • group.var: Indicates a grouping variable used for colour-coding. In this case, the variable “Region” relates to the group variable.

  • hulls: A logical argument that determines whether to display individual sample points or to draw convex hulls around each group.

  • scale.var: A numerical value to scale the vectors.

move: A logical argument that controls whether the biplot is animated. If set to TRUE, the sample points are animated across time. If set to FALSE, the function returns a faceted plot showing a static biplot for each time level.
shadow: A logical argument that controls whether samples of previous time points are still displayed as time moves forward (burn-in of previous states). Only works when move = TRUE and hulls = FALSE.

moveplot()

bp |> moveplot(time.var = "Year", group.var = "Region", hulls = FALSE, move = FALSE)
# Object of class biplot, based on 960 samples and 9 variables.
# 6 numeric variables.
# 3 categorical variables.

moveplot(): Insider tip!

overall_time <- Africa_climate |> 
  mutate("Overall" = as.factor(rep("Overall",
  nrow(Africa_climate))))

bp_overall <- biplot(overall_time, scaled = TRUE) |> 
  PCA(group.aes = overall_time$Region)

bp_overall |> moveplot(time.var = "Overall", 
  group.var = "Region", hulls = FALSE, move = FALSE)
# Object of class biplot, based on 960 samples and 10 variables.
# 6 numeric variables.
# 4 categorical variables.

moveplot(): shifting perspective

bp |> moveplot(time.var = "Region", group.var = "Region", hulls = FALSE, move = FALSE)
# Object of class biplot, based on 960 samples and 9 variables.
# 6 numeric variables.
# 3 categorical variables.

moveplot()

bp |> moveplot(time.var = "Year", group.var = "Region", hulls = TRUE, move = TRUE)

moveplot()

bp |> moveplot(time.var = "Year", group.var = "Region", hulls = FALSE, move = TRUE, shadow = TRUE)

Dynamic Frame

  • Separate biplots for each time slice of the data.
  • Extends the animation to both the sample points and the variable axes.
  • Fully dynamic animation to reflect temporal changes in the underlying data structure.


Samples
Variables
X1
Z1
V1
X2
Z2
V2

X8
Z8
V8

2 options in moveEZ

bp |> moveplot2(time.var = "Year", group.var = "Region", align.time = "1950", reflect = "x")

bp |> moveplot3(time.var = "Year", group.var = "Region", target = NULL)

evaluation()

In conjunction with moveplot3(), five measures of comparison can be calculated to measure the difference between the target display and the display representing every other time point.

  • Procrustes Statistic (PS)
  • Congruence Coefficient (CC)
  • Absolute Mean Bias (AMB)
  • Mean Bias (MB)
  • Root Mean Squared Bias (RMSB)

This can be extracted as tables or line graphs.

Quantifying the change

# 
# 
#         Target vs. 1950
# -----  ----------------
# PS               0.2112
# CC               0.9556
# AMB              0.4976
# MB               0.0000
# RMSB             0.6549
# 
#         Target vs. 1960
# -----  ----------------
# PS               0.1738
# CC               0.9559
# AMB              1.6285
# MB               0.0000
# RMSB             2.3374
# 
# 
#         Target vs. 1970
# -----  ----------------
# PS               0.2047
# CC               0.9521
# AMB              1.6469
# MB               0.0000
# RMSB             2.3450
# 
#         Target vs. 1980
# -----  ----------------
# PS               0.1570
# CC               0.9604
# AMB              1.5816
# MB               0.0000
# RMSB             2.3185
# 
# 
#         Target vs. 1990
# -----  ----------------
# PS               0.1698
# CC               0.9603
# AMB              1.6250
# MB               0.0000
# RMSB             2.3322
# 
#         Target vs. 2000
# -----  ----------------
# PS               0.2472
# CC               0.9451
# AMB              1.6976
# MB               0.0000
# RMSB             2.3489
# 
# 
#         Target vs. 2010
# -----  ----------------
# PS               0.1618
# CC               0.9635
# AMB              1.6034
# MB               0.0000
# RMSB             2.3178
# 
#         Target vs. 2020
# -----  ----------------
# PS               0.1277
# CC               0.9712
# AMB              1.5778
# MB               0.0000
# RMSB             2.2826
results$bias.plot

results$fit.plot

More information

Package website

Acknowledgements

We acknowledge the support and contributions of:

  • Dianne Cook - Monash University, Melbourne (Australia).

    • NGA(MaSS) - funding for this collaboration and visit
  • Tom Mock - slide inspiration