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.

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()

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 are constructed for each time slice of the data. Both the sample points and variable axes evolve over time, resulting in a fully dynamic animation that reflects temporal changes in the underlying data structure.


Samples
Variables
X1
Z1
V1
X2
Z2
V2

X8
Z8
V8

moveplot2()

  • The moveplot2() function extends the animation to both the sample points and the variable axes.

  • Unlike moveplot(), which keeps the variable axes fixed, moveplot2() constructs a separate biplot for each time slice, allowing both components to evolve over time.

  • The function shares the same arguments as moveplot(), with the move argument determining whether the animation is shown or presented as static facets for samples and variables. Setting move = TRUE produces an animated biplot in which both the samples and variables transition across time.

moveplot2()

Additional enhancements include reflections to align the biplots if needed.

Available options include:

  • "x" – Reflect about the x-axis

  • "y" – Reflect about the y-axis

  • "xy" – Reflect about both axes

Both align.time and reflect can be vectors when alignment is needed at multiple time points with each entry in reflect corresponding to a time point in align.time.

moveplot2()

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

moveplot2()

Here, the biplot is aligned at the 1950 time point by reflection about the x-axis.

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

Dynamic Frame: configurative matching

  • As before, separate biplots are constructed for each time slice of the data.

  • Now, the biplots are aligned according to a specific target:

    • Default: the average of the separate biplot coordinates is calculated and used as a target.

    • Option: specify a target (e.g. a specific year)

  • Generalised orthogonal Procrustes Analysis (GPA) is used to transform each biplot to the target:

    • translation, scaling, rotation and reflection
  • Results in an aligned animation to expose subtle temporal changes that occur over time.

GPA methodology

  • Image 1: \({\bf{A}}\) is the target visualisation
  • Image 2: \({\bf{B}}\) is the testee visualisation, figures are already centred (translation not required)
  • Image 3: The coordinates of \({\bf{B}}\) are reflected
  • Image 4: The coordinates of \({\bf{B}}\) are rotated and scaled
Borg, I. & Groenen, P. 2005. Modern Multidimensional Scaling. 2nd ed. United States of America: Springer. (Page 433)

moveplot3()

This function shares the same arguments as moveplot() and moveplot2(), with the addition of the target argument:

  • target = NULL - use the average of available biplots
  • target = Africa_climate_target - use of a specific target dataset

To illustrate the use of a fixed target, consider the year 1989 from the Africa_climate data set, which consists of the same variables and number of observations:

moveplot3()

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

moveplot3()

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

Quantifying the movement

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.

results <- bp |> moveplot3(time.var = "Year", group.var = "Region", hulls = TRUE, move = FALSE, 
                target = Africa_climate_target) |> evaluation()

Table of evaluation measures

# 
# 
#         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

moveplot3()

results$bias.plot

moveplot3()

results$fit.plot

Statistical Analysis of Emissions and Performance of a Wood-Fuelled Stove with Integrated Oven Using Local Hardwoods

  • Prof. RLJ Coetzer

    • Centre of Excellence in Carbon based Fuels, School of Chemical and Minerals Engineering. Focus Area for Pure and Applied Analytics, North-West University (NWU). MuViSU.
  • Prof. HWJP Neomagus

    • Centre of Excellence in Carbon based Fuels, School of Chemical and Minerals Engineering, NWU.
  • Dr R Ganey (Wits and MuViSU)

  • Dr J Nienkemper-Swanepoel (SU and MuViSU)

Rationale

  • Wood is a preferred energy source in South African homes.
  • Household air pollution (HAP) holds a major risk.
  • This study investigates the emissions and cooking efficiency of a novel stove FLAMINGo Stove.

Measurements

Measurements were performed every 10 seconds with a total experimental time of approximately 90 minutes. The following paramaters were measured directly:

  • Mass of the stove and fuel.

  • Dry gas fractions of 5 gases (\(NO\), \(SO_2\), \(CO\), \(CO_2\) and \(O_2\)) diluted and undiluted.

  • Various temperatures in the oven and chimney.

  • Pot temperatures.

  • Particulate matter (PM) concentration.

Factors in the full factorial design (\(4 \times 2 \times 3\)):

  • 4 different wood species: Sickle Bush (SB), Mopane (M), Leadwood (LW), Black Wattle (BW)

  • Oven in use or not.

  • Power phase: low, medium, high.

Objectives

  • Understanding the process through targeted visualisation.
  • Correlation of emission factors.
  • Effect of the different wood species.
  • Effect of the oven component.
  • Correlation of emission concentrations with the stove temperatures.

PCA biplot of emission factors

# Object of class biplot, based on 72 samples and 10 variables.
# 5 numeric variables.
# 5 categorical variables.

Effect of the oven on emission factors

# Object of class biplot, based on 72 samples and 10 variables.
# 5 numeric variables.
# 5 categorical variables.

Change in emission factors over the phase: fixed variable frame

# Object of class biplot, based on 72 samples and 10 variables.
# 5 numeric variables.
# 5 categorical variables.

Change in emission factors over the phase: dynamic variable frame

# Object of class biplot, based on 72 samples and 10 variables.
# 5 numeric variables.
# 5 categorical variables.

Emission concentration levels

# Object of class biplot, based on 1944 samples and 22 variables.
# 17 numeric variables.
# 5 categorical variables.

Emission concentration levels per phase

Emission concentration levels over time

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