TSrepr is R package for fast time series representations and dimensionality reduction computations. Z-score normalisation, min-max normalisation, forecasting accuracy measures and other useful functions implemented in C++ (Rcpp) and R.
You can install TSrepr directly from CRAN:
install.packages("TSrepr")
Or development version from GitHub with:
# install.packages("devtools")
# devtools::install_github("PetoLau/TSrepr")
install.packages("TSrepr", repos = c('https://petolau.r-universe.dev', 'https://cloud.r-project.org'))
All type of time series representations methods are implemented, and these are so far:
repr_paa)repr_dwt)repr_dft)repr_dct)repr_sma)repr_pip)repr_sax)repr_pla)repr_seas_profile)repr_lm, repr_gam)repr_exp)repr_feaclip, clipping)repr_featrend, trending)repr_feacliptrend)Additional useful functions are implemented as:
repr_windowing) - applies above mentioned
representations to every window of a time seriesrepr_matrix) - applies above mentioned
representations to every row of a matrix of time seriesrepr_list) - applies above mentioned
representations to every member of a list of time series with
different lengthsnorm_z), min-max
(norm_min_max), arctan (norm_atan), Box-Cox (norm_boxcox),
Yeo-Johnson (norm_yj)norm_z_list), min-max (norm_min_max_list)norm_z_params), min-max (norm_min_max_params)denorm_z), min-max
(denorm_min_max), arctan (denorm_atan), Box-Cox
(denorm_boxcox), Yeo-Johnson (denorm_yj)library(TSrepr)
library(ggplot2)
data_ts <- as.numeric(elec_load[5,]) # electricity load consumption data
# Comparison of PAA and PLA
# Dimensionality of the time series will be reduced 8 times
data_paa <- repr_paa(data_ts, q = 12, func = mean)
data_pla <- repr_pla(data_ts, times = 55, return = "both") # returns both extracted places and values
data_plot <- data.frame(value = c(data_ts, data_paa, data_pla$points),
time = c(1:length(data_ts), seq(6, length(data_ts), by = 12),
data_pla$places),
type = factor(c(rep("Original", length(data_ts)),
rep(c("PAA", "PLA"), each = 56))))
ggplot(data_plot, aes(time, value, color = type, size = type)) +
geom_line(alpha = 0.8) +
scale_size_manual(values = c(0.6, 0.8, 0.8)) +
theme_bw()

Cite the package as: