https://github.com/smac-group/wv

:alarm_clock: This R package provides the tools to perform standard and robust wavelet variance analysis for time series (signal processing). Among others, aside from computing the wavelet variance and cross-covariance (classic and robust), the package provides inference tools (e.g. confidence intervals) and plotting tools allowing to perform some visual analysis and assess the properties of the underlying time series.

https://github.com/smac-group/wv

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    6 of 20 committers (30.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.9%) to scientific vocabulary

Keywords

signal-processing time-series wavelet-variance

Keywords from Contributors

rcpp rcpparmadillo timeseries-data
Last synced: 5 months ago · JSON representation

Repository

:alarm_clock: This R package provides the tools to perform standard and robust wavelet variance analysis for time series (signal processing). Among others, aside from computing the wavelet variance and cross-covariance (classic and robust), the package provides inference tools (e.g. confidence intervals) and plotting tools allowing to perform some visual analysis and assess the properties of the underlying time series.

Basic Info
Statistics
  • Stars: 17
  • Watchers: 8
  • Forks: 10
  • Open Issues: 13
  • Releases: 0
Topics
signal-processing time-series wavelet-variance
Created almost 9 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog

README.md

example
workflow Licence minimal R
version CRAN CRAN RStudio mirror
downloads CRAN RStudio mirror
downloads

wv Overview

This repository is dedicated to the Wavelet Variance (wv) R package where different tools to perform wavelet variance analysis are provided (both standard and robust analysis). Below are instructions and examples on how to install and make use of the wv package.

Currently the only implemented wavelet filter in the package is the Haar wavelet filter.

Install Instructions

The wv package is available on both CRAN and GitHub. The CRAN version is considered stable while the GitHub version is subject to modifications/updates which may lead to installation problems or broken functions. You can install the stable version of the wv package with:

r install.packages("wv")

For users who are interested in having the latest developments, the GitHub version is ideal although more dependencies are required to run a stable version of the package. Most importantly, users must have a (C++) compiler installed on their machine that is compatible with R (e.g. Clang). Once you’ve made sure that you have a compatible C++ compiler installed on your computer, run the following code in an R session and you will be ready to use the devlopment version of wv.

``` r

Install dependencies

install.packages(c("devtools"))

Install/Update the package from GitHub

devtools::install_github("SMAC-Group/wv")

Install the package with Vignettes/User Guides

devtools::installgithub("SMAC-Group/wv", buildvignettes = TRUE) ```

Wavelet Variance Analysis

Below are some examples of how to make use of some of the main functions in the wv package. Firstly, we highlight the functions that perform the wavelet decomposition of a time series (both the discrete and maximum-overlap discrete wavelet transforms) based on which the following functions can compute the wavelet variance and its corresponding confidence intervals for inference. These are particularly useful, for example, when comparing the wavelet variance of different time series in order to understand if they share common properties or not.

Discrete Wavelet Transform (DWT)

The DWT performs a wavelet decomposition by applying the wavelet filter to non-overlapping windows of the time series. Below is an example of how to perform this decomposition on a simulated Gaussian random walk process.

``` r

Load packages

library(wv) library(simts)

>

> Attaching package: 'simts'

> The following object is masked from 'package:wv':

>

> unitConversion

Set seed for reproducibility

set.seed(999)

Simulate a Gaussian random walk

n = 10^3 model = RW(gamma2 = 1) Xt = gen_gts(n = n, model = model)

Plot the simulated random walk

plot(Xt) ```

<!-- -->

Based on the above code, we have simulated a random walk with null expectation unit innovation variance. The functions to compute the DWT, access its output and plot the related wavelet coefficients can be found below.

``` r

DWT

Xt.dwt = dwt(Xt)

> Warning in dwt(Xt): The data has been truncated so that it is divisible by

> nlevels (e.g. 2^*)

Print the Wavelet Coefficients

summary(Xt.dwt)

>

> Results of DWT using haar filter with 8 levels:

> Displaying only the first 6 coefficients...

> Level 1 Wavelet Coefficients

> -0.9281198 0.1909687 -0.4002392 -0.8957566 -0.7926733 0.09473632 ...

> Level 2 Wavelet Coefficients

> 0.2739394 -2.795066 0.8319477 0.3625764 -0.08550498 0.108777 ...

> Level 3 Wavelet Coefficients

> -2.384147 2.388987 -2.733086 -1.928826 -2.133592 -2.809311 ...

> Level 4 Wavelet Coefficients

> -6.282995 -5.729953 -7.616116 1.635971 1.2219 4.605007 ...

> Level 5 Wavelet Coefficients

> -10.03819 -6.631445 -0.6948675 -19.01644 12.1667 -5.350667 ...

> Level 6 Wavelet Coefficients

> -23.08426 -18.32217 18.40802 -8.680854 -4.335243 6.224648 ...

> Level 7 Wavelet Coefficients

> -34.68146 -7.485961 -5.448519 -30.51181 ...

> Level 8 Wavelet Coefficients

> -50.81154 1.13322 ...

Plot of Discrete Wavelet Coefficients

plot(Xt.dwt) ```

Discrete Wavelet Transform (DWT) for scales 1 to 4 for a simulated Gaussian white noise.

Discrete Wavelet Transform (DWT) for scales 1 to 4 for a simulated Gaussian white noise.

Maximum Overlap Discrete Wavelet Transformation (MODWT)

Compared to the DWT, the MODWT applies the wavelet filter to overlapping windows of the time series (more specifically it slides the filter by one observation at a time). As for the DWT, the functions to perform the MODWT are below.

``` r

MODWT

Xt.modwt = modwt(Xt)

Summary of Maximum Overlap Discrete Wavelet Coefficients

summary(Xt.modwt)

>

> Results of MODWT using haar filter with 9 levels:

> Displaying only the first 6 coefficients...

> Level 1 Wavelet Coefficients

> -0.6562798 0.397592 0.1350352 -0.1386532 -0.2830119 -0.9393291 ...

> Level 2 Wavelet Coefficients

> 0.1369697 0.2645046 -0.2126415 -0.822003 -1.397533 -1.344998 ...

> Level 3 Wavelet Coefficients

> -0.8429231 -1.362249 -2.044266 -1.991537 -1.571604 -0.827054 ...

> Level 4 Wavelet Coefficients

> -1.570749 -1.175945 -0.7167598 -0.3172241 -0.04720348 0.01135659 ...

> Level 5 Wavelet Coefficients

> -1.774519 -1.731545 -1.702113 -1.711879 -1.649612 -1.530804 ...

> Level 6 Wavelet Coefficients

> -2.885532 -2.821419 -2.829503 -2.839451 -2.783538 -2.726905 ...

> Level 7 Wavelet Coefficients

> -3.065437 -3.069304 -3.063743 -3.03344 -2.997907 -2.955661 ...

> Level 8 Wavelet Coefficients

> -3.175721 -3.114701 -3.064177 -3.0097 -2.956361 -2.910441 ...

> Level 9 Wavelet Coefficients

> -6.967706 -6.925613 -6.884283 -6.838645 -6.79024 -6.735489 ...

Plot of Maximum Overlap Discrete Wavelet Coefficients

plot(Xt.modwt, index = "all") ```

Maximum Overlap Discrete Wavelet Transform  (MODWT) for scales 1 to 9 for a simulated Gaussian white noise.

Maximum Overlap Discrete Wavelet Transform (MODWT) for scales 1 to 9 for a simulated Gaussian white noise.

Wavelet Variance

If the interest of the user lies solely in the wavelet variance (issued from either DWT or MODWT), then the package provides functions that directly compute this quantity and deliver the tools necessary to analyse it (confidence intervals and plots). Below is a code that simulates a white noise and a random walk process and directly plots their respective wavelet variances in a log-log plot applying the plot() function to the package function wvar().

``` r

Set seed for reproducibility

set.seed(999)

Simulate Gaussian White noise

n = 10^4 Xt = gen_gts(n = n, model = WN(sigma2 = 1))

Simulate Gaussian Random walk

Yt = gen_gts(n = n, model = RW(gamma2 = 1))

Plot WV

par(mfrow = c(1,2), mar = c(4,5,1,1)) plot(wvar(Xt), main = "White noise") plot(wvar(Yt), main = "Random walk", legend_position = NULL) ```

Wavelet variance of two simulated processes, i.e white noise (left panel) and random walk (right panel).

Wavelet variance of two simulated processes, i.e white noise (left panel) and random walk (right panel).

As indicated in the legends, the light shaded blue area represents the 95% confidence intervals for each scale of estimated wavelet variance. However, there could be many practical settings where the time series can suffer from some “contamination” (e.g. outliers) which can seriously bias the standard estimator of wavelet variance. The code below randomly replaces one percent of the observations from the above simulated random walk with observations from a white noise process with larger variance.

``` r

Add contamination

gamma = 0.01 Yt2 = Yt Yt2[sample(1:n,round(gamman))] = rnorm(round(gamman),0,5) par(mfrow = c(1,2), mar = c(4,5,1,1)) robusteda(Yt, main = "RW without contamination") robusteda(Yt2, legend_position = NULL, main = "RW with contamination") ```

It can be seen how the classic and robust wavelet variance estimates agree when there is no contamination (left plot) but they classic estimates are heavily biased (especially at the first more informative scales) when the random walk has only 1% contamination.

When dealing with different time series, it is possible to compare their respective wavelet variances to understand if they have similar behaviour/properties. An example is given below where four different first-order autoregressive processes (with different values of the autoregressive parameters) are simulated and succesively their wavelet variance is computed.

``` r

Simulate AR processes

n = 10^5 Xt = gengts(n = n, model = AR1(phi = 0.10, sigma2 = 1)) Yt = gengts(n = n, model = AR1(phi = 0.35, sigma2 = 1)) Zt = gengts(n = n, model = AR1(phi = 0.79, sigma2 = 1)) Wt = gengts(n = n, model = AR1(phi = 0.95, sigma2 = 1))

Compute WV

wvXt = wvar(Xt) wvYt = wvar(Yt) wvZt = wvar(Zt) wvWt = wvar(Wt)

Plot results

comparewvar(wvXt, wvYt, wvZt, wv_Wt) ```

As seen above, the function compare_wvar() allows to plot different outputs of the wvar() function and it can be seen how the four time series deliver different wavelet variances (as the autoregressive parameter approaches zero, the shape of the wavelet variance plot approaches the behaviour of the wavelet variance of a white noise process).

Wavelet Variance on IMU Data

In the package, we also add some datasets which are the wavelet variance computed based on real IMU data. Currently the package includes datasets adis_wv, imar_wv, kvh1750_wv, ln200_wv and navchip_av. We can plot these wavelet variance simply with the plot function. As an example:

r data("kvh1750_wv") plot(kvh1750_wv)

User Guides

Various guides ship with package or are available on https://smac-group.com/ to provide insight into how to use the different methods. At the present time, the following vignettes are available:

  1. Process to Haar Wavelet Variance (Online)

Owner

  • Name: Statistical Methods, Applications & Computing Group
  • Login: SMAC-Group
  • Kind: organization
  • Email: contact@smac-group.com

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 425
  • Total Committers: 20
  • Avg Commits per committer: 21.25
  • Development Distribution Score (DDS): 0.492
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Justin Lee j****3@i****u 216
stephaneguerrier s****e@p****u 35
Yuming Zhang y****6@i****u 32
Nate Claussen n****2@i****u 29
Stéphane Guerrier s****r@S****l 13
Stéphane Guerrier s****r@s****e 13
Lionel Voirol l****l@h****m 12
Stéphane Guerrier s****r@S****e 11
Yuming-Zhang y****5@g****m 11
Nathanael Claussen n****l@N****l 10
Roberto Molinari r****i@h****t 9
jjlee13 j****3@a****l 8
Nathanael N****l@N****l 7
Haotian Xu h****1@i****u 6
Duke Zhang d****e@D****l 5
Justin j****n@s****l 4
Nathanael N****l@w****u 1
Stephane g****s@C****l 1
lorenagarzoni l****i@h****m 1
GAECHTER TOYA Stefan s****r@h****m 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 15
  • Total pull requests: 2
  • Average time to close issues: 7 months
  • Average time to close pull requests: 5 days
  • Total issue authors: 7
  • Total pull request authors: 1
  • Average comments per issue: 0.4
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • stephaneguerrier (7)
  • munsheet (2)
  • stefangachter (2)
  • pmodv (1)
  • lionelvoirol (1)
  • robertomolinari (1)
  • Yuming-Zhang (1)
Pull Request Authors
  • stefangachter (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 339 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: wv

Wavelet Variance

  • Versions: 3
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 339 Last month
Rankings
Forks count: 6.8%
Stargazers count: 13.7%
Dependent packages count: 18.1%
Average: 21.1%
Dependent repos count: 24.0%
Downloads: 42.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • Rcpp * imports
  • coda * imports
  • grDevices * imports
  • graphics * imports
  • methods * imports
  • simts * imports
  • stats * imports
  • utils * imports
  • knitr * suggests
  • rmarkdown * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite