timehive
Hierarchical moving-window statistical analysis for time series.
Science Score: 57.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.0%) to scientific vocabulary
Keywords
Repository
Hierarchical moving-window statistical analysis for time series.
Basic Info
- Host: GitHub
- Owner: Ouroboro
- License: gpl-3.0
- Language: R
- Default Branch: main
- Homepage: https://ouroboro.github.io/TimeHiVE/
- Size: 184 MB
Statistics
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 1
Topics
Metadata Files
README.md
TimeHiVE: Hierarchical Moving-Window Time Series Analysis Toolkit
Overview
TimeHiVE provides efficient R functions for hierarchical moving-window analysis of coupled time series data. The toolkit implements:
- Parallel computation of Pearson and Mann-Kendall correlations
- Optimized O(n log n) implementations of statistical tests
- Customizable visualization of time-dependent relationships
- Statistical significance testing with adjustable thresholds
The software package here proposed allows to perform analyses on time series avoiding the arbitrary choice of the time window and allowing to appreciate the whole spectrum of possible results offered by this kind of statistical tools.
Figure 1: Different Moving Average vs Original Syntetic Time Series. Color scale on y-axis is meant only to match colors in Fig. 2
Figure 2: Representation of all the possible moving averages for the Original Syntetic Time Series, moving averages analyses represented in Fig. 1 are highlighted with comments on the results.
Figure 3: Representation of two Time Series positively correlated for short periods but negatively correlated for long periods. The series are built as: `TS1 = 40 + 2sin(t/2) - t/20 - rand(-2/3, 2/3)andTS2 = 15 + 2sin(t/2) + t/7 - rand(-2/3, 2/3). The sine component creates short-term positive correlation, while thet/n` terms drive long-term negative correlation.
Figure 4: Here we show the Moving Correlation Analysis for the coupled Time Series represented in Fig. 4, the first row shows the results for Pearson’s correlation coefficient (Top Left) and relative p-values (Top Right), the second row shows the same analysis with MK’s correlation coefficients (Bottom Left) and relative p-values (Bottom Right). The inversion of the correlation between short and long period of analysis is quite clear.
FIRST ROW: Pearson’s correlation coefficient (Top Left) and relative p-values (Top Right). SECOND ROW: same analysis with MK’s correlation coefficientes (Bottom Left) and relative p-values (Bottom Right). The inversion of the correlation between short and long period of analysis is quite clear.
Installation
You can install the development version from GitHub with:
```r
install.packages("remotes")
remotes::install_github("Ouroboro/TimeHiVE") ```
Usage
Basic Example
```r library(TimeHiVE)
Generate example data
set.seed(123) series1 <- sin(seq(0, 4pi, length.out = 200)) + rnorm(200, sd = 0.2) series2 <- cos(seq(0, 4pi, length.out = 200)) + rnorm(200, sd = 0.3)
Perform analysis
results <- TH_coupled( series1 = series1, series2 = series2, m = 2, s = 6, alpha = 0.05, mode = "both" )
Visualize results
TH_plotc(results, mask = TRUE, mode = "both") ```
Advanced Usage
For functions TH_plots and TH_plotc, you can use significance values to mask the output of statistical tests depending on the value you chose previously.
``` results2 <- TH_coupled(series1, series2)
Fig5 <- "Fig5.png" Fig6 <- "Fig6.png" p <- THplotc(results2, outputfile = Fig5) p <- THplotc(results2, outputfile = Fig6, mask = TRUE) ```
Output for Fig. 5 unmasked.
Output for Fig. 6 masked.
If the moving-window statistical analyses proposed by the previous functions are not sufficient, functions TH_tweak() and TH_plott() allow you to use custom functions and possibly customize the color scales and tile intervals during the display phase. An exhaustive example follows shortly.
```
START Customized Functions
harmean_fun <- function(series) { series <- series[!is.na(series)] n <- length(series) sol <- n / sum(1/series, na.rm = TRUE) return(sol) }
mean_fun <- function(x) mean(x)
diffmeanfun <- function(series) { series <- series[!is.na(series)] x <- harmeanfun(series) y <- mean_fun(series) sol <- x-y return(sol) }
skewfun <- function(series) { series <- series[!is.na(series)] n <- length(series) avg <- mean(series) sdcamp <- sd(series) sol <- sum((series - avg)^3 / (sd_camp^3)) / n return(sol) }
END Customized Functions
results <- THtweak( harmeanfun, meanfun, diffmeanfun, skew_fun, series = list(data), param = 0.05 )
START Customized Color Palette
skew = { neg <- colorRampPalette(c("green4", "green"))(33) pos <- colorRampPalette(c("magenta", "magenta4"))(33) c(neg, "white", pos) }
END Customized Color Palette
Fig7 <- "Fig7.png" p <- THplott(results, outputfile = Fig7, colorscales = list( "avg", "avg", c("magenta", "purple", "blue", "cyan", "white"), skew), colorlimits = list( c(0, 35), c(0, 35), NULL, NULL)) ```
Output for Fig. 7 single series tweak.
```
START Customized Functions
pearson_fun <- function(x, y) cor.test(x, y, method = "pearson")$estimate
diffmax_fun <- function(serie1, serie2, na.rm = TRUE) { max1 <- sum(serie1, na.rm = na.rm) max2 <- sum(serie2, na.rm = na.rm) sol <- (max1-max2) return(sol) }
sqrmean_fun <- function(serie1, serie2, na.rm = TRUE) { x <- sum(serie1, na.rm = na.rm) y <- sum(serie2, na.rm = na.rm) sol <- sqrt(sqrt((x*y)^4)) return(sol) }
END Customized Functions
results <- THtweak( pearsonfun, diffmaxfun, sqrmeanfun, series = list(sdata, sdata2), param = 0.05 )
Fig8 <- "Fig8.png" p <- THplott(results, outputfile = Fig8, colorscales = list(c("blue", "white", "red"), c("green", "yellow", "purple"), "avg"))
```
Output for Fig. 8 coupled series tweak.
Main Functions
TH_single(): Perform hierarchical moving-window analysis for single seriesTH_coupled(): Perform hierarchical moving-window analysis for coupled seriesTH_tweak(): Perform customized hierarchical moving-window analysis for coupled or single seriesTH_plots(): Visualize analysis results fromTH_single()TH_plotc(): Visualize analysis results fromTH_coupled()TH_plott(): Visualize analysis results fromTH_tweak(), no masking.TH_MK_Trend(): Mann-Kendall trend testTH_MK_Corr(): Mann-Kendall correlation test
Documentation
For detailed documentation see:
r
?TH_single
?TH_coupled
?TH_tweak
?TH_plots
?TH_plotc
?TH_plott
?TH_MK_Trend
?TH_MK_Corr
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
License
This package is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.
Contact
For questions or issues, please contact:
Vladimiro Andrea Boselli
Email: boselli.v@irea.cnr.it
GitHub: @Ouroboro
Owner
- Login: Ouroboro
- Kind: user
- Company: CNR-IREA
- Repositories: 1
- Profile: https://github.com/Ouroboro
Anticolonial Programmer
Citation (CITATION.cff)
# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
cff-version: 1.2.0
message: 'To cite package "TimeHiVE" in publications use:'
type: software
title: 'TimeHiVE: Time-series Hierarchical Visual Explorer'
version: 0.1.0
abstract: Hierarchical moving-window statistical analysis for time series. A collection
of utilities for moving averages, trends, and correlations analysis of time-series,
including efficient implementations of statistical tests and visualization tools.
authors:
- family-names: Boselli
given-names: Vladimiro Andrea
email: boselli.v@irea.cnr.it
orcid: https://orcid.org/0000-0003-2985-6358
- family-names: Tagliolato Acquaviva d'Aragona
given-names: Paolo
email: tagliolato.p@cnr.it
orcid: https://orcid.org/0000-0002-0261-313X
- family-names: Oggioni
given-names: Alessandro
email: oggioni.a@irea.cnr.it
orcid: https://orcid.org/0000-0002-7997-219X
preferred-citation:
type: generic
title: Time-series Hierarchical Visual Explorer
authors:
- family-names: Boselli
given-names: Vladimiro Andrea
email: boselli.v@irea.cnr.it
orcid: https://orcid.org/0000-0003-2985-6358
- family-names: Tagliolato
given-names: Paolo
- family-names: Oggioni
given-names: Alessandro
email: oggioni.a@irea.cnr.it
orcid: https://orcid.org/0000-0002-7997-219X
year: '2025'
notes: R package version v0.1.0
repository-code: https://github.com/Ouroboro/TimeHiVE
url: https://github.com/Ouroboro/TimeHiVE
contact:
- family-names: Boselli
given-names: Vladimiro Andrea
email: boselli.v@irea.cnr.it
orcid: https://orcid.org/0000-0003-2985-6358
keywords:
- correlation-analysis
- kendall-knight
- mann-kendall
- moving-average
- moving-window
- pearson-correlation
- statistics
- time-series
- trend-analysis
references:
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
url: https://www.R-project.org/
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2025'
version: '>= 3.5.0'
- type: software
title: ggplot2
abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
notes: Imports
url: https://ggplot2.tidyverse.org
repository: https://CRAN.R-project.org/package=ggplot2
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Chang
given-names: Winston
orcid: https://orcid.org/0000-0002-1576-2126
- family-names: Henry
given-names: Lionel
- family-names: Pedersen
given-names: Thomas Lin
email: thomas.pedersen@posit.co
orcid: https://orcid.org/0000-0002-5147-4711
- family-names: Takahashi
given-names: Kohske
- family-names: Wilke
given-names: Claus
orcid: https://orcid.org/0000-0002-7470-9261
- family-names: Woo
given-names: Kara
orcid: https://orcid.org/0000-0002-5125-4188
- family-names: Yutani
given-names: Hiroaki
orcid: https://orcid.org/0000-0002-3385-7233
- family-names: Dunnington
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
- family-names: Brand
given-names: Teun
name-particle: van den
orcid: https://orcid.org/0000-0002-9335-7468
year: '2025'
doi: 10.32614/CRAN.package.ggplot2
- type: software
title: gridExtra
abstract: 'gridExtra: Miscellaneous Functions for "Grid" Graphics'
notes: Imports
repository: https://CRAN.R-project.org/package=gridExtra
authors:
- family-names: Auguie
given-names: Baptiste
email: baptiste.auguie@gmail.com
year: '2025'
doi: 10.32614/CRAN.package.gridExtra
- type: software
title: parallel
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2025'
- type: software
title: stats
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2025'
- type: software
title: lubridate
abstract: 'lubridate: Make Dealing with Dates a Little Easier'
notes: Imports
url: https://lubridate.tidyverse.org
repository: https://CRAN.R-project.org/package=lubridate
authors:
- family-names: Spinu
given-names: Vitalie
email: spinuvit@gmail.com
- family-names: Grolemund
given-names: Garrett
- family-names: Wickham
given-names: Hadley
year: '2025'
doi: 10.32614/CRAN.package.lubridate
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
url: https://testthat.r-lib.org
repository: https://CRAN.R-project.org/package=testthat
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2025'
doi: 10.32614/CRAN.package.testthat
version: '>= 3.0.0'
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "TimeHiVE",
"description": "Hierarchical moving-window statistical analysis for time series. A collection of utilities for moving averages, trends, and correlations analysis of time-series, including efficient implementations of statistical tests and visualization tools.",
"name": "TimeHiVE: Time-series Hierarchical Visual Explorer",
"codeRepository": "https://github.com/Ouroboro/EnvDataShow",
"issueTracker": "https://github.com/Ouroboro/EnvDataShow/issues",
"license": "`use_gpl3_license()`",
"version": "0.1.0",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.1.2 (2021-11-01)",
"author": [
{
"@type": "Person",
"givenName": "Vladimiro Andrea",
"familyName": "Boselli",
"email": "boselli.v@irea.cnr.it",
"@id": "https://orcid.org/0000-0003-2985-6358"
},
{
"@type": "Person",
"givenName": "Paolo",
"familyName": "Tagliolato Acquaviva d'Aragona",
"email": "tagliolato.p@cnr.it",
"@id": "https://orcid.org/0000-0002-0261-313X"
},
{
"@type": "Person",
"givenName": "Alessandro",
"familyName": "Oggioni",
"email": "oggioni.a@irea.cnr.it",
"@id": "https://orcid.org/0000-0002-7997-219X"
}
],
"copyrightHolder": [
{
"@type": "Person",
"givenName": "Vladimiro Andrea",
"familyName": "Boselli",
"email": "boselli.v@irea.cnr.it",
"@id": "https://orcid.org/0000-0003-2985-6358"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Vladimiro Andrea",
"familyName": "Boselli",
"email": "boselli.v@irea.cnr.it",
"@id": "https://orcid.org/0000-0003-2985-6358"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.5.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "ggplot2",
"name": "ggplot2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "gridExtra",
"name": "gridExtra",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=gridExtra"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "parallel",
"name": "parallel"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "stats",
"name": "stats"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "lubridate",
"name": "lubridate",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lubridate"
},
"SystemRequirements": null
},
"fileSize": "2777.004KB",
"citation": [
{
"@type": "CreativeWork",
"datePublished": "2025",
"author": [
{
"@type": "Person",
"givenName": [
"Vladimiro",
"Andrea"
],
"familyName": "Boselli"
},
{
"@type": "Person",
"givenName": "Paolo",
"familyName": "Tagliolato"
},
{
"@type": "Person",
"givenName": "Alessandro",
"familyName": "Oggioni"
}
],
"name": "Time-series Hierarchical Visual Explorer",
"description": "R package version v0.1.0"
}
]
}
GitHub Events
Total
- Release event: 1
- Delete event: 1
- Push event: 10
- Create event: 2
Last Year
- Release event: 1
- Delete event: 1
- Push event: 10
- Create event: 2
Dependencies
- R >= 3.5.0 depends
- ggplot2 * imports
- gridExtra * imports
- lubridate * imports
- parallel * imports
- stats * imports
- testthat >= 3.0.0 suggests