{"id":43167826,"url":"https://github.com/ouroboro/timehive","last_synced_at":"2026-02-01T02:11:49.170Z","repository":{"id":298275810,"uuid":"858726800","full_name":"Ouroboro/TimeHiVE","owner":"Ouroboro","description":"Hierarchical moving-window statistical analysis for time series.","archived":false,"fork":false,"pushed_at":"2025-10-15T09:27:10.000Z","size":192867,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-15T23:19:38.853Z","etag":null,"topics":["correlation-analysis","kendall-knight","mann-kendall","moving-average","moving-window","pearson-correlation","statistics","time-series","trend-analysis"],"latest_commit_sha":null,"homepage":"https://ouroboro.github.io/TimeHiVE/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ouroboro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-17T12:34:30.000Z","updated_at":"2025-09-05T12:24:27.000Z","dependencies_parsed_at":"2025-06-19T11:19:59.554Z","dependency_job_id":"5475d201-59c4-4a8f-9002-ecfda8db6f3a","html_url":"https://github.com/Ouroboro/TimeHiVE","commit_stats":null,"previous_names":["ouroboro/envdatashow","ouroboro/timehive"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Ouroboro/TimeHiVE","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ouroboro%2FTimeHiVE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ouroboro%2FTimeHiVE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ouroboro%2FTimeHiVE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ouroboro%2FTimeHiVE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ouroboro","download_url":"https://codeload.github.com/Ouroboro/TimeHiVE/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ouroboro%2FTimeHiVE/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28964810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T01:25:30.373Z","status":"online","status_checked_at":"2026-02-01T02:00:08.102Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["correlation-analysis","kendall-knight","mann-kendall","moving-average","moving-window","pearson-correlation","statistics","time-series","trend-analysis"],"created_at":"2026-02-01T02:11:48.446Z","updated_at":"2026-02-01T02:11:49.159Z","avatar_url":"https://github.com/Ouroboro.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TimeHiVE: Hierarchical Moving-Window Time Series Analysis Toolkit\n\n\u003c!-- badges: start --\u003e\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![DOI: 10.5281/zenodo.15697261](https://img.shields.io/badge/doi-10.5281/zenodo.15697261-yellow.svg)](https://doi.org/10.5281/zenodo.15697261)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nTimeHiVE provides efficient R functions for hierarchical moving-window analysis of coupled time series data. The toolkit implements:\n\n- Parallel computation of Pearson and Mann-Kendall correlations\n- Optimized O(n log n) implementations of statistical tests\n- Customizable visualization of time-dependent relationships\n- Statistical significance testing with adjustable thresholds\n\nThe 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.\n\n![Original Time Series](man/figures/Fig1.png)\n*Figure 1: Different Moving Average vs Original Syntetic Time Series. Color scale on y-axis is meant only to match colors in Fig. 2*\n\n![TimeHiVE Moving Average](man/figures/Fig2.png)\n*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.*\n\n![Original Coupled Series](man/figures/Fig3.png)\n*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 + 2*sin(t/2) - t/20 - rand(-2/3, 2/3)` and `TS2 = 15 + 2*sin(t/2) + t/7 - rand(-2/3, 2/3)`. The sine component creates short-term positive correlation, while the `t/n` terms drive long-term negative correlation.*\n\n![Original Time Series](man/figures/Fig4.png)\n*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.*\n\nFIRST ROW: Pearson’s correlation coefficient (Top Left) and relative p-values (Top Right).\nSECOND 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.\n\n## Installation\n\nYou can install the development version from GitHub with:\n\n```r\n# install.packages(\"remotes\")\nremotes::install_github(\"Ouroboro/TimeHiVE\")\n```\n\n## Usage\n\n### Basic Example\n```r\nlibrary(TimeHiVE)\n\n# Generate example data\nset.seed(123)\nseries1 \u003c- sin(seq(0, 4*pi, length.out = 200)) + rnorm(200, sd = 0.2)\nseries2 \u003c- cos(seq(0, 4*pi, length.out = 200)) + rnorm(200, sd = 0.3)\n\n# Perform analysis\nresults \u003c- TH_coupled(\n  series1 = series1,\n  series2 = series2,\n  m = 2,\n  s = 6,\n  alpha = 0.05,\n  mode = \"both\"\n)\n\n# Visualize results\nTH_plotc(results, mask = TRUE, mode = \"both\")\n```\n\n### Advanced Usage\n\nFor 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.\n\n```\nresults2 \u003c- TH_coupled(series1, series2)\n\nFig5 \u003c- \"Fig5.png\"\nFig6 \u003c- \"Fig6.png\"\np \u003c- TH_plotc(results2, output_file = Fig5)\np \u003c- TH_plotc(results2, output_file = Fig6, mask = TRUE)\n```\n\n![Unmasked](man/figures/Fig5.png)\n*Output for Fig. 5 unmasked.*\n\n![Masked](man/figures/Fig6.png)\n*Output for Fig. 6 masked.*\n\nIf 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.\n\n```\n### START Customized Functions ###\n\nharmean_fun \u003c- function(series) {\n  series \u003c- series[!is.na(series)]\n  n \u003c- length(series)\n  sol \u003c- n / sum(1/series, na.rm = TRUE)\n  return(sol)\n}\n\nmean_fun \u003c- function(x) mean(x)\n\ndiffmean_fun \u003c- function(series) {\n  series \u003c- series[!is.na(series)]\n  x \u003c- harmean_fun(series)\n  y \u003c- mean_fun(series)\n  sol \u003c- x-y\n  return(sol)\n}\n\nskew_fun \u003c- function(series) {\n  series \u003c- series[!is.na(series)]\n  n \u003c- length(series)\n  avg \u003c- mean(series)\n  sd_camp \u003c- sd(series)\n  sol \u003c- sum((series - avg)^3 / (sd_camp^3)) / n\n  return(sol)\n}\n\n### END Customized Functions ###\n\nresults \u003c- TH_tweak(\n  harmean_fun,\n  mean_fun,\n  diffmean_fun,\n  skew_fun,\n  series = list(data),\n  param = 0.05\n)\n\n### START Customized Color Palette ###\n\nskew = {\n  neg \u003c- colorRampPalette(c(\"green4\", \"green\"))(33)\n  pos \u003c- colorRampPalette(c(\"magenta\", \"magenta4\"))(33)\n  c(neg, \"white\", pos)\n}\n\n### END Customized Color Palette ###\n\nFig7 \u003c- \"Fig7.png\"\np \u003c- TH_plott(results, output_file = Fig7, \n              colorscales = list(\n                \"avg\",\n                \"avg\",\n                c(\"magenta\", \"purple\", \"blue\", \"cyan\", \"white\"),\n                skew),\n              colorlimits = list(\n                c(0, 35),\n                c(0, 35),\n                NULL,\n                NULL))\n```\n\n![Single Series Tweak](man/figures/Fig7.png)\n*Output for Fig. 7 single series tweak.*\n\n```\n### START Customized Functions ###\n\npearson_fun \u003c- function(x, y) cor.test(x, y, method = \"pearson\")$estimate\n\ndiffmax_fun \u003c- function(serie1, serie2, na.rm = TRUE) {\n  max1 \u003c- sum(serie1, na.rm = na.rm)\n  max2 \u003c- sum(serie2, na.rm = na.rm)\n  sol \u003c- (max1-max2)\n  return(sol)\n}\n\nsqrmean_fun \u003c- function(serie1, serie2, na.rm = TRUE) {\n  x \u003c- sum(serie1, na.rm = na.rm)\n  y \u003c- sum(serie2, na.rm = na.rm)\n  sol \u003c- sqrt(sqrt((x*y)^4))\n  return(sol)\n}\n\n### END Customized Functions ###\n\nresults \u003c- TH_tweak(\n  pearson_fun,\n  diffmax_fun,\n  sqrmean_fun,\n  series = list(sdata, sdata2),\n  param = 0.05\n)\n\nFig8 \u003c- \"Fig8.png\"\np \u003c- TH_plott(results, output_file = Fig8, \ncolorscales = list(c(\"blue\", \"white\", \"red\"),\n                   c(\"green\", \"yellow\", \"purple\"),\n                   \"avg\"))\n\n```\n\n![Coupled Series Tweak](man/figures/Fig8.png)\n*Output for Fig. 8 coupled series tweak.*\n\n\n### Main Functions\n\n- `TH_single()`: Perform hierarchical moving-window analysis for single series\n- `TH_coupled()`: Perform hierarchical moving-window analysis for coupled series\n- `TH_tweak()`: Perform customized hierarchical moving-window analysis for coupled or single series\n- `TH_plots()`: Visualize analysis results from `TH_single()`\n- `TH_plotc()`: Visualize analysis results from `TH_coupled()`\n- `TH_plott()`: Visualize analysis results from `TH_tweak()`, no masking.\n- `TH_MK_Trend()`: Mann-Kendall trend test\n- `TH_MK_Corr()`: Mann-Kendall correlation test\n\n\n## Documentation\n\nFor detailed documentation see:\n\n```r\n?TH_single\n?TH_coupled\n?TH_tweak\n?TH_plots\n?TH_plotc\n?TH_plott\n?TH_MK_Trend\n?TH_MK_Corr\n```\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/your-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin feature/your-feature`)\n5. Open a Pull Request\n\n## License\n\nThis package is licensed under the GNU General Public License v3.0 (GPL-3.0). See the [LICENSE](LICENSE) file for details.\n\n## Contact\n\nFor questions or issues, please contact:\n\nVladimiro Andrea Boselli  \nEmail: boselli.v@irea.cnr.it  \nGitHub: [@Ouroboro](https://github.com/Ouroboro)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fouroboro%2Ftimehive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fouroboro%2Ftimehive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fouroboro%2Ftimehive/lists"}