Type: | Package |
Title: | Wavelet Variance |
Version: | 0.1.2 |
Date: | 2023-08-29 |
LazyData: | true |
Maintainer: | Stéphane Guerrier <stef.guerrier@gmail.com> |
Description: | Provides a series of tools to compute and plot quantities related to classical and robust wavelet variance for time series and regular lattices. More details can be found, for example, in Serroukh, A., Walden, A.T., & Percival, D.B. (2000) <doi:10.2307/2669537> and Guerrier, S. & Molinari, R. (2016) <doi:10.48550/arXiv.1607.05858>. |
Depends: | R (≥ 3.5.0) |
License: | AGPL-3 |
Imports: | Rcpp, simts, utils, grDevices, coda, methods, graphics, stats |
LinkingTo: | Rcpp, RcppArmadillo |
RoxygenNote: | 7.2.3 |
Encoding: | UTF-8 |
Suggests: | knitr, rmarkdown |
URL: | https://github.com/SMAC-Group/wv |
BugReports: | https://github.com/SMAC-Group/wv/issues |
NeedsCompilation: | yes |
Packaged: | 2023-08-30 08:10:40 UTC; lionel |
Author: | Stéphane Guerrier [aut, cre], James Balamuta [aut], Justin Lee [aut], Roberto Molinari [aut], Yuming Zhang [aut], Mucyo Karemera [aut], Nathanael Claussen [ctb], Haotian Xu [ctb], Lionel Voirol [ctb] |
Repository: | CRAN |
Date/Publication: | 2023-08-31 04:40:02 UTC |
wv
Description
Provides a series of tools to compute and plot quantities related to classical and robust wavelet variance for time series and regular lattices. More details can be found, for example, in Serroukh, A., Walden, A.T., & Percival, D.B. (2000) <doi:10.2307/2669537> and Guerrier, S. & Molinari, R. (2016) <arXiv:1607.05858>.
Author(s)
Maintainer: Stéphane Guerrier stef.guerrier@gmail.com
Authors:
James Balamuta
Justin Lee
Roberto Molinari
Yuming Zhang
Mucyo Karemera
Other contributors:
Nathanael Claussen [contributor]
Haotian Xu [contributor]
Lionel Voirol [contributor]
See Also
Useful links:
Auto-Covariance and Correlation Functions
Description
The acf function computes the estimated autocovariance or autocorrelation for both univariate and multivariate cases.
Usage
.acf(x, lagmax = 0L, cor = TRUE, demean = TRUE)
Arguments
x |
A |
lagmax |
A |
cor |
A |
demean |
A |
Auto-Covariance and Correlation Functions
Description
The ACF function computes the estimated autocovariance or autocorrelation for both univariate and multivariate cases.
Usage
ACF(x, lagmax = 0, cor = TRUE, demean = TRUE)
Arguments
x |
A |
lagmax |
A |
cor |
A |
demean |
A |
Details
lagmax
default is 10*log10(N/m)
where N
is the number of
observations and m
is the number of series being compared. If
lagmax
supplied is greater than the number of observations, then one
less than the total will be taken.
Value
An array
of dimensions N \times S \times S
.
Author(s)
Yunxiang Zhang
Examples
# Get Autocorrelation
m = ACF(datasets::AirPassengers)
# Get Autocovariance and do not remove trend from signal
m = ACF(datasets::AirPassengers, cor = FALSE, demean = FALSE)
Compute Theoretical ACF for an ARMA Process
Description
Compute the theoretical autocorrelation function for an ARMA process.
Usage
ARMAacf_cpp(ar,ma,lag_max)
Arguments
ar |
A |
ma |
A |
lag_max |
A |
Details
This is an implementaiton of the ARMAacf function in R. It is approximately 40x times faster. The benchmark was done on iMac Late 2013 using vecLib as the BLAS.
Value
x A matrix
listing values from 1...nx in one column and 1...1, 2...2,....,n...n, in the other
Author(s)
James J Balamuta
Converting an ARMA Process to an Infinite MA Process
Description
Takes an ARMA function and converts it to an infinite MA process.
Usage
ARMAtoMA_cpp(ar, ma, lag_max)
Arguments
ar |
A |
ma |
A |
lag_max |
A |
Details
This function is a port of the base stats package's ARMAtoMA. There is no significant speed difference between the two.
Value
A column vector
containing coefficients
Author(s)
James J Balamuta
Helper Function for ARMA to WV Approximation
Description
Indicates where the minimum ARMAacf value is and returns that as an index.
Usage
acf_sum(ar, ma, last_tau, alpha = 0.99)
Arguments
ar |
A |
ma |
A |
last_tau |
An |
alpha |
A |
Value
A vec
containing the wavelet variance of the ARMA process.
See Also
Wavelet variance of IMU Data from an ADIS 16405 sensor
Description
This data set contains wavelet variance of gyroscope and accelerometer data from an ADIS 16405 sensor.
Usage
adis_wv
Format
A list of the following elements:
"sensor": Name of the sensor.
"freq": The frequency at which the error signal is measured.
"n": Sample size of the data.
"type": The types of sensors considered in the data.
"axis": The axes of sensors considered in the data.
"wvar": A list containing the computed wavelet variance based on the data.
Source
The IMU data comes from Department of Geomatics Engineering, University of Calgary.
AR(1) process to WV
Description
This function computes the Haar WV of an AR(1) process
Usage
ar1_to_wv(phi, sigma2, tau)
Arguments
phi |
A |
sigma2 |
A |
tau |
A |
Details
This function is significantly faster than its generalized counter part
arma_to_wv
.
Value
A vec
containing the wavelet variance of the AR(1) process.
Process Haar Wavelet Variance Formula
The Autoregressive Order 1
(AR(1
)) process has a Haar Wavelet Variance given by:
\frac{{2{\sigma ^2}\left( {4{\phi ^{\frac{{{\tau _j}}}{2} + 1}} - {\phi ^{{\tau _j} + 1}} - \frac{1}{2}{\phi ^2}{\tau _j} + \frac{{{\tau _j}}}{2} - 3\phi } \right)}}{{{{\left( {1 - \phi } \right)}^2}\left( {1 - {\phi ^2}} \right)\tau _j^2}}
See Also
ARMA(1,1) to WV
Description
This function computes the WV (haar) of an Autoregressive Order 1 - Moving Average Order 1 (ARMA(1,1)) process.
Usage
arma11_to_wv(phi, theta, sigma2, tau)
Arguments
phi |
A |
theta |
A |
sigma2 |
A |
tau |
A |
Details
This function is significantly faster than its generalized counter part
arma_to_wv
Value
A vec
containing the wavelet variance of the ARMA(1,1) process.
Process Haar Wavelet Variance Formula
The Autoregressive Order 1
and Moving Average Order 1
(ARMA(1
,1
)) process has a Haar Wavelet Variance given by:
\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = - \frac{{2{\sigma ^2}\left( { - \frac{1}{2}{{(\theta + 1)}^2}\left( {{\phi ^2} - 1} \right){\tau _j} - (\theta + \phi )(\theta \phi + 1)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right)} \right)}}{{{{(\phi - 1)}^3}(\phi + 1)\tau _j^2}}
See Also
ARMA process to WV
Description
This function computes the Haar Wavelet Variance of an ARMA process
Usage
arma_to_wv(ar, ma, sigma2, tau)
Arguments
ar |
A |
ma |
A |
sigma2 |
A |
tau |
A |
Details
The function is a generic implementation that requires a stationary theoretical autocorrelation function (ACF)
and the ability to transform an ARMA(p
,q
) process into an MA(\infty
) (e.g. infinite MA process).
Value
A vec
containing the wavelet variance of the ARMA process.
Process Haar Wavelet Variance Formula
The Autoregressive Order p
and Moving Average Order q
(ARMA(p
,q
)) process has a Haar Wavelet Variance given by:
\frac{{{\tau _j}\left[ {1 - \rho \left( {\frac{{{\tau _j}}}{2}} \right)} \right] + 2\sum\limits_{i = 1}^{\frac{{{\tau _j}}}{2} - 1} {i\left[ {2\rho \left( {\frac{{{\tau _j}}}{2} - i} \right) - \rho \left( i \right) - \rho \left( {{\tau _j} - i} \right)} \right]} }}{{\tau _j^2}}\sigma _X^2
where \sigma _X^2
is given by the variance of the ARMA process.
Furthermore, this assumes that stationarity has been achieved as it directly
See Also
ARMAtoMA_cpp
, ARMAacf_cpp
, and arma11_to_wv
ARMA process to WV Approximation
Description
This function computes the (haar) WV of an ARMA process
Usage
arma_to_wv_app(ar, ma, sigma2, tau, alpha = 0.9999)
Arguments
ar |
A |
ma |
A |
sigma2 |
A |
tau |
A |
alpha |
A |
Details
This function provides an approximation to the arma_to_wv
as computation times
were previously a concern. However, this is no longer the case and, thus, this has been left
in for the curious soul to discover...
Value
A vec
containing the wavelet variance of the ARMA process.
Process Haar Wavelet Variance Formula
The Autoregressive Order p
and Moving Average Order q
(ARMA(p
,q
)) process has a Haar Wavelet Variance given by:
\frac{{{\tau _j}\left[ {1 - \rho \left( {\frac{{{\tau _j}}}{2}} \right)} \right] + 2\sum\limits_{i = 1}^{\frac{{{\tau _j}}}{2} - 1} {i\left[ {2\rho \left( {\frac{{{\tau _j}}}{2} - i} \right) - \rho \left( i \right) - \rho \left( {{\tau _j} - i} \right)} \right]} }}{{\tau _j^2}}\sigma _X^2
where \sigma _X^2
is given by the variance of the ARMA process.
Furthermore, this assumes that stationarity has been achieved as it directly
Haar Wavelet Derivation Information
For more information, please see: blog post on SMAC group website.
See Also
ARMAtoMA_cpp
, ARMAacf_cpp
, acf_sum
and arma_to_wv
Calculate Theoretical Allan Variance for Stationary First-Order Autoregressive (AR1) Process
Description
This function allows us to calculate the theoretical allan variance for stationary first-order autoregressive (AR1) process.
Usage
av_ar1(n, phi, sigma2)
Arguments
n |
An |
phi |
A |
sigma2 |
A |
Value
A double
indicating the theoretical allan variance for AR1 process.
Note
This function is based on the calculation of the theoretical allan variance for stationary AR1 process raised in "Allan Variance of Time Series Models for Measurement Data" by Nien Fan Zhang.) This calculation is fundamental and necessary for the study in "A Study of the Allan Variance for Constant-Mean Non-Stationary Processes" by Xu et al. (IEEE Signal Processing Letters, 2017).
Author(s)
Yuming Zhang
Examples
av1 = av_ar1(n = 5, phi = 0.9, sigma2 = 1)
av2 = av_ar1(n = 8, phi = 0.5, sigma2 = 2)
Calculate Theoretical Allan Variance for Stationary White Noise Process
Description
This function allows us to calculate the theoretical allan variance for stationary white noise process.
Usage
av_wn(sigma2, n)
Arguments
sigma2 |
A |
n |
An |
Value
A double
indicating the theoretical allan variance for the white noise
process.
Note
This function is based on the calculation of the theoretical allan variance for stationary white noise process raised in "Allan Variance of Time Series Models for Measurement Data" by Nien Fan Zhang. This calculation is fundamental and necessary for the study in "A Study of the Allan Variance for Constant-Mean Non-Stationary Processes" by Xu et al. (IEEE Signal Processing Letters, 2017).
Author(s)
Yuming Zhang
Examples
av1 = av_wn(sigma2 = 1, n = 5)
av2 = av_wn(sigma2 = 2, n = 8)
Computes the MO/DWT wavelet variance for multiple processes
Description
Calculates the MO/DWT wavelet variance
Usage
batch_modwt_wvar_cpp(
signal,
nlevels,
robust,
eff,
alpha,
ci_type,
strWavelet,
decomp
)
Arguments
signal |
A |
robust |
A |
eff |
A |
alpha |
A |
ci_type |
A |
strWavelet |
A |
decomp |
A |
Details
This function processes the decomposition of multiple signals quickly
Value
A field<mat>
with the structure:
"variance"Wavelet Variance
"low"Lower CI
"high"Upper CI
Time Series Convolution Filters
Description
Applies a convolution filter to a univariate time series.
Usage
cfilter(x, filter, sides, circular)
Arguments
x |
A |
filter |
A |
sides |
An |
circular |
A |
Details
This is a port of the cfilter function harnessed by the filter function in stats. It is about 5-7 times faster than R's base function. The benchmark was done on iMac Late 2013 using vecLib as the BLAS.
Value
A column vec
that contains the results of the filtering process.
Author(s)
James J Balamuta
Generate eta3 confidence interval
Description
Computes the eta3 CI
Usage
ci_eta3(y, dims, alpha_ov_2)
Arguments
y |
A |
dims |
A |
alpha_ov_2 |
A |
Value
A matrix
with the structure:
Column 1Wavelet Variance
Column 2Chi-squared Lower Bounds
Column 3Chi-squared Upper Bounds
Generate eta3 robust confidence interval
Description
Computes the eta3 robust CI
Usage
ci_eta3_robust(wv_robust, wv_ci_class, alpha_ov_2, eff)
Arguments
wv_robust |
A |
wv_ci_class |
A |
alpha_ov_2 |
A |
eff |
A |
Details
Within this function we are scaling the classical
Value
A matrix
with the structure:
Column 1Robust Wavelet Variance
Column 2Chi-squared Lower Bounds
Column 3Chi-squared Upper Bounds
Generate a Confidence interval for a Univariate Time Series
Description
Computes an estimate of the multiscale variance and a chi-squared confidence interval
Usage
ci_wave_variance(
signal_modwt_bw,
wv,
type = "eta3",
alpha_ov_2 = 0.025,
robust = FALSE,
eff = 0.6
)
Arguments
signal_modwt_bw |
A |
wv |
A |
type |
A |
alpha_ov_2 |
A |
robust |
A |
eff |
A |
Details
This function can be expanded to allow for other confidence interval calculations.
Value
A matrix
with the structure:
Column 1Wavelet Variance
Column 2Chi-squared Lower Bounds
Column 3Chi-squared Upper Bounds
Comparison Between Multiple Wavelet Variances
Description
Displays plots of multiple wavelet variances of different time series accounting for CI values.
Usage
compare_wvar(
...,
split = FALSE,
add_legend = TRUE,
units = NULL,
xlab = NULL,
ylab = NULL,
main = NULL,
col_wv = NULL,
col_ci = NULL,
nb_ticks_x = NULL,
nb_ticks_y = NULL,
legend_position = NULL,
ci_wv = NULL,
point_cex = NULL,
point_pch = NULL,
names = NULL,
cex_labels = 0.8,
x_range = NULL,
y_range = NULL
)
Arguments
... |
One or more time series objects. |
split |
A |
add_legend |
A |
units |
A |
xlab |
A |
ylab |
A |
main |
A |
col_wv |
A |
col_ci |
A |
nb_ticks_x |
An |
nb_ticks_y |
An |
legend_position |
A |
ci_wv |
A |
point_cex |
A |
point_pch |
A |
names |
A |
cex_labels |
A |
x_range |
A |
y_range |
A |
Author(s)
Stephane Guerrier and Justin Lee
Examples
set.seed(999)
n = 10^4
Xt = arima.sim(n = n, list(ar = 0.10))
Yt = arima.sim(n = n, list(ar = 0.35))
Zt = arima.sim(n = n, list(ar = 0.70))
Wt = arima.sim(n = n, list(ar = 0.95))
wv_Xt = wvar(Xt)
wv_Yt = wvar(Yt)
wv_Zt = wvar(Zt)
wv_Wt = wvar(Wt)
compare_wvar(wv_Xt, wv_Yt, wv_Zt, wv_Wt)
Combined Plot Comparison Between Multiple Wavelet Variances
Description
This is a helper function for the compare_var()
function.
This method accepts the same set of arguments as compare_wvar
and returns a single plot
that compares multiple wavelet variances of different time series accounting for CI values.
Usage
compare_wvar_no_split(graph_details)
Arguments
graph_details |
List of inputs |
Author(s)
Stephane Guerrier, Justin Lee, and Nathanael Claussen
Multi-Plot Comparison Between Multiple Wavelet Variances
Description
This is a helper function for the compare_var()
function.
This method accepts the same set of arguments as compare_wvar
and returns a comparision
of multiple wavelet variances of different time series accounting for CI values as a set of different plots.
Usage
compare_wvar_split(graph_details)
Arguments
graph_details |
List of inputs |
Author(s)
Stephane Guerrier, Justin Lee, and Nathanael Claussen
Create a wvar
object
Description
Structures elements into a wvar
object
Usage
create_wvar(
obj,
decomp,
filter,
robust,
eff,
alpha,
scales,
unit,
mean_diff,
N,
ranged,
J
)
Arguments
obj |
A |
decomp |
A |
filter |
A |
robust |
A |
eff |
A |
alpha |
A |
scales |
A |
unit |
A |
mean_diff |
A |
N |
A |
ranged |
A |
J |
A |
Value
A list
with the structure:
"variance": Wavelet variance
"ci_low": Lower CI
"ci_high": Upper CI
"robust": Robust active
"eff": Efficiency level for robust calculation
"alpha": p value used for CI
"unit": String representation of the unit
"mean_diff": Empirical mean of the first difference
"N": Length of the time series
"ranged": Scaled range of the data, i.e. (max(x) - min(x))/length(x)
"J": Number of scales
Each Models Process Decomposed to WV
Description
This function computes each process to WV (haar) in a given model.
Usage
decomp_theoretical_wv(theta, desc, objdesc, tau)
Arguments
theta |
A |
desc |
A |
objdesc |
A |
tau |
A |
Value
A mat
containing the wavelet variance of each process in the model
Decomposed WV to Single WV
Description
This function computes the combined processes to WV (haar) in a given model.
Usage
decomp_to_theo_wv(decomp)
Arguments
decomp |
A |
Value
A vec
containing the wavelet variance of the process for the overall model
Discrete Fourier Transformation for Autocovariance Function
Description
Calculates the autovariance function (ACF) using Discrete Fourier Transformation.
Usage
dft_acf(x)
Arguments
x |
A |
Details
This implementation is 2x as slow as Rs. Two issues: 1. memory resize and 2. unoptimized fft algorithm in arma. Consider piping back into R and rewrapping the object. (Decrease of about 10 microseconds.)
Value
A vec
containing the ACF.
Lagged Differences in Armadillo
Description
Returns the ith difference of a time series of rth lag.
Usage
diff_cpp(x, lag, differences)
Arguments
x |
A |
lag |
A |
differences |
A |
Value
A vector
containing the differenced time series.
Author(s)
James J Balamuta
Drift to WV
Description
This function compute the WV (haar) of a Drift process
Usage
dr_to_wv(omega, tau)
Arguments
omega |
A |
tau |
A |
Value
A vec
containing the wavelet variance of the drift.
Process Haar Wavelet Variance Formula
The Drift (DR) process has a Haar Wavelet Variance given by:
\nu _j^2\left( {{\omega }} \right) = \frac{{\tau _j^2{\omega ^2}}}{{16}}
Discrete Wavelet Transform
Description
Calculation of the coefficients for the discrete wavelet transformation
Usage
dwt(x, nlevels = floor(log2(length(x))), filter = "haar")
Arguments
x |
A |
nlevels |
A |
filter |
A |
Details
Performs a level J
decomposition of the time series using the pyramid algorithm.
The default J
is determined by floor\left(log_2 \left(length\left(x\right)\right)\right)
Value
A field<vec>
that contains the wavelet coefficients for each decomposition level
Author(s)
James Balamuta, Justin Lee and Stephane Guerrier
Examples
set.seed(999)
x = rnorm(2^8)
ret = dwt(x)
summary(ret)
plot(ret)
Discrete Wavelet Transform
Description
Calculation of the coefficients for the discrete wavelet transformation.
Usage
dwt_cpp(x, filter_name, nlevels)
Arguments
x |
A |
filter_name |
A |
nlevels |
An |
Details
Performs a level J decomposition of the time series using the pyramid algorithm
Value
y A field<vec>
that contains the wavelet coefficients for each decomposition level
Author(s)
James Balamuta and Justin Lee
Wavelet variance of IMU Data from IMAR Gyroscopes
Description
This data set contains wavelet variance of IMAR gyroscopes data.
Usage
imar_wv
Format
A list of the following elements:
"sensor": Name of the sensor.
"freq": The frequency at which the error signal is measured.
"n": Sample size of the data.
"type": The types of sensors considered in the data.
"axis": The axes of sensors considered in the data.
"wvar": A list containing the computed wavelet variance based on the data.
Source
The IMU data comes from Geodetic Engineering Laboratory (TOPO) and Swiss Federal Institute of Technology Lausanne (EPFL).
Discrete Intergral: Inverse Difference
Description
Takes the inverse difference (e.g. goes from diff() result back to previous vector)
Usage
intgr_vec(x, xi, lag)
diff_inv_values(x, lag, d, xi)
diff_inv(x, lag, d)
Arguments
x |
A |
xi |
A |
lag |
An |
d |
An |
Wavelet variance of IMU Data from a KVH1750 IMU sensor
Description
This data set contains wavelet variance of gyroscope and accelerometer data from an KVH1750 sensor.
Usage
kvh1750_wv
Format
A list of the following elements:
"sensor": Name of the sensor.
"freq": The frequency at which the error signal is measured.
"n": Sample size of the data.
"type": The types of sensors considered in the data.
"axis": The axes of sensors considered in the data.
"wvar": A list containing the computed wavelet variance based on the data.
Source
The IMU data comes from Department of Geomatics Engineering, University of Calgary.
Wavelet variance of IMU Data from a LN200 sensor
Description
This data set contains wavelet variance of LN200 gyroscope and accelerometer data.
Usage
ln200_wv
Format
A list of the following elements:
"sensor": Name of the sensor.
"freq": The frequency at which the error signal is measured.
"n": Sample size of the data.
"type": The types of sensors considered in the data.
"axis": The axes of sensors considered in the data.
"wvar": A list containing the computed wavelet variance based on the data.
Source
The IMU data comes from Geodetic Engineering Laboratory (TOPO) and Swiss Federal Institute of Technology Lausanne (EPFL).
Moving Average Order 1 (MA(1)) to WV
Description
This function computes the WV (haar) of a Moving Average order 1 (MA1) process.
Usage
ma1_to_wv(theta, sigma2, tau)
Arguments
theta |
A |
sigma2 |
A |
tau |
A |
Details
This function is significantly faster than its generalized counter part
arma_to_wv
.
Value
A vec
containing the wavelet variance of the MA(1) process.
Process Haar Wavelet Variance Formula
The Moving Average Order 1
(MA(1
)) process has a Haar Wavelet Variance given by:
\nu _j^2\left( {\theta ,{\sigma ^2}} \right) = \frac{{\left( {{{\left( {\theta + 1} \right)}^2}{\tau _j} - 6\theta } \right){\sigma ^2}}}{{\tau _j^2}}
See Also
Mean of the First Difference of the Data
Description
The mean of the first difference of the data
Usage
mean_diff(x)
Arguments
x |
A |
Value
A double
that contains the mean of the first difference of the data.
Maximum Overlap Discrete Wavelet Transform
Description
Calculates the coefficients for the discrete wavelet transformation
Usage
modwt(x, nlevels = floor(log2(length(x) - 1)), filter = "haar")
Arguments
x |
A |
nlevels |
A |
filter |
A |
Details
Performs a level J
decomposition of the time series using the pyramid algorithm.
The default J
is determined by floor\left(log_2 \left(length\left(x\right)\right)\right)
Value
A field<vec>
that contains the wavelet coefficients for each decomposition level
Author(s)
James Balamuta, Justin Lee and Stephane Guerrier
Examples
set.seed(999)
x = rnorm(100)
ret = modwt(x)
summary(ret)
plot(ret)
Maximum Overlap Discrete Wavelet Transform
Description
Calculation of the coefficients for the discrete wavelet transformation
Usage
modwt_cpp(x, filter_name, nlevels)
Arguments
x |
A |
filter_name |
A |
nlevels |
An |
Details
Performs a level J decomposition of the time series using the pyramid algorithm. Use this implementation to supply custom parameters instead of modwt(x), which serves as a wrapper function.
Value
y A field<vec>
that contains the wavelet coefficients for each decomposition level
Author(s)
James Balamuta and Justin Lee
Computes the (MODWT) wavelet variance
Description
Calculates the (MODWT) wavelet variance
Usage
modwt_wvar_cpp(
signal,
nlevels,
robust,
eff,
alpha,
ci_type,
strWavelet,
decomp
)
Arguments
signal |
A |
robust |
A |
eff |
A |
alpha |
A |
ci_type |
A |
strWavelet |
A |
decomp |
A |
Details
This function powers the wvar object. It is also extendable...
Value
A mat
with the structure:
"variance"Wavelet Variance
"low"Lower CI
"high"Upper CI
Wavelet variance of IMU Data from a navchip sensor
Description
This data set contains wavelet variance of gyroscope and accelerometer data from a navchip sensor.
Usage
navchip_wv
Format
A list of the following elements:
"sensor": Name of the sensor.
"freq": The frequency at which the error signal is measured.
"n": Sample size of the data.
"type": The types of sensors considered in the data.
"axis": The axes of sensors considered in the data.
"wvar": A list containing the computed wavelet variance based on the data.
Source
The IMU data of the navchip sensor comes from Geodetic Engineering Laboratory (TOPO) and Swiss Federal Institute of Technology Lausanne (EPFL).
Replicate a Vector of Elements n
times
Description
This function takes a vector and replicates all of the data n
times
Usage
num_rep(x, n)
Arguments
x |
A |
n |
An |
Value
A vec
with repeated elements of the initial supplied vector.
Auto-Covariance and Correlation Functions
Description
The acf function computes the estimated autocovariance or autocorrelation for both univariate and multivariate cases.
Usage
## S3 method for class 'auto_corr'
plot(x, show.ci = TRUE, alpha = 0.05, main = NULL, ...)
Arguments
x |
An |
show.ci |
A |
... |
Additional parameters |
ci |
A |
Value
An array
of dimensions N \times S \times S
.
Author(s)
Yunxiang Zhang
Examples
# Calculate the Autocorrelation
m = ACF(datasets::AirPassengers)
# Plot with 95% CI
plot(m)
# Plot with 90% CI
plot(m, ci = 0.90)
# Plot without 95% CI
plot(m, show.ci = FALSE)
Plot Discrete Wavelet Transform
Description
Plots results of the dwt list in which additional parameters can be specified
Usage
## S3 method for class 'dwt'
plot(x, index = NULL, couleur = NULL, ...)
Arguments
x |
A |
index |
A |
couleur |
A |
... |
additional arguments affecting the plot produced. |
Author(s)
Justin Lee and Stephane Guerrier
Examples
# Simulate a Gaussian white noise
n = 10^3
Xt = rnorm(n)
# dwt
Yt = dwt(Xt)
# Graph examples
plot(Yt)
plot(Yt, index = c(1,4,5,6,8,2))
plot(Yt, index = c(1,4,5,6), couleur = "blue")
plot(Yt, index = c(1,4,5,6), couleur = rep(c("blue","yellow"),2))
Plot Wavelet Variance based on IMU Data
Description
Displays a plot of wavelet variance accounting for CI values and supplied efficiency.
Usage
## S3 method for class 'imu_wvar'
plot(
x,
xlab = NULL,
ylab = NULL,
main = NULL,
col_wv = NULL,
col_ci = NULL,
nb_ticks_x = NULL,
nb_ticks_y = NULL,
ci_wv = NULL,
point_cex = NULL,
point_pch = NULL,
...
)
Arguments
x |
A |
xlab |
A |
ylab |
A |
main |
A |
col_wv |
A |
col_ci |
A |
nb_ticks_x |
An |
nb_ticks_y |
An |
ci_wv |
A |
point_cex |
A |
point_pch |
A |
... |
Additional arguments affecting the plot. |
Value
Plot of wavelet variance and confidence interval for each scale.
Author(s)
Stephane Guerrier and Yuming Zhang
Examples
data("kvh1750_wv")
plot(kvh1750_wv)
Plot Maximum Overlap Discrete Wavelet Transform
Description
Plots results of the modwt list in which additional parameters can be specified
Usage
## S3 method for class 'modwt'
plot(x, index = NULL, couleur = NULL, ...)
Arguments
x |
A |
index |
A |
couleur |
A |
... |
additional arguments affecting the plot produced. |
Author(s)
Justin Lee and Stephane Guerrier
Examples
# Simulate a Gaussian white noise
n = 10^3
Xt = rnorm(n)
# MODWT
Yt = modwt(Xt)
# Graph examples
plot(Yt)
plot(Yt, index = c(1,4,5,6,8,2))
plot(Yt, index = c(1,4,5,6), couleur = "blue")
plot(Yt, index = c(1,4,5,6), couleur = rep(c("blue","yellow"),2))
Plot Cross Covariance Pair
Description
Plots results of the a wccv_pair list in which additional parameters can be specified
Usage
## S3 method for class 'wccv_pair'
plot(
x,
theo.wccv = NULL,
main = NULL,
xlab = NULL,
ylab = NULL,
units = NULL,
col_wccv = NULL,
col_ci = NULL,
nb_ticks_x = NULL,
nb_ticks_y = NULL,
...
)
Author(s)
Justin Lee, Haotian Xu, and Stephane Guerrier
Examples
n = 10^5
Xt = cumsum(rnorm(n, 0, 0.01))
Wt = Xt + rnorm(n)
Yt = Xt + rnorm(n)
wcov = wccv_pair(Wt, Yt)
plot(wcov)
Plot Wavelet Variance
Description
Displays a plot of wavelet variance accounting for CI values and supplied efficiency.
Usage
## S3 method for class 'wvar'
plot(
x,
units = NULL,
xlab = NULL,
ylab = NULL,
main = NULL,
col_wv = NULL,
col_ci = NULL,
nb_ticks_x = NULL,
nb_ticks_y = NULL,
legend_position = NULL,
ci_wv = NULL,
point_cex = NULL,
point_pch = NULL,
...
)
Arguments
x |
A |
units |
A |
xlab |
A |
ylab |
A |
main |
A |
col_wv |
A |
col_ci |
A |
nb_ticks_x |
An |
nb_ticks_y |
An |
legend_position |
A |
ci_wv |
A |
point_cex |
A |
point_pch |
A |
... |
Additional arguments affecting the plot. |
Value
Plot of wavelet variance and confidence interval for each scale.
Author(s)
Stephane Guerrier, Nathanael Claussen, and Justin Lee
Examples
set.seed(999)
n = 10^4
Xt = rnorm(n)
wv = wvar(Xt)
plot(wv)
plot(wv, main = "Simulated white noise", xlab = "Scales")
plot(wv, units = "sec", legend_position = "topright")
plot(wv, col_wv = "darkred", col_ci = "pink")
Print Discrete Wavelet Transform
Description
Prints the results of the modwt list
Usage
## S3 method for class 'dwt'
print(x, ...)
Arguments
x |
A |
... |
further arguments passed to or from other methods. |
Value
Prints the dwt decomposition
Author(s)
James Balamuta and Nathanael Claussen
Examples
set.seed(999)
x = rnorm(2^8)
print(dwt(x))
Print Maximum Overlap Discrete Wavelet Transform
Description
Prints the results of the modwt list
Usage
## S3 method for class 'modwt'
print(x, ...)
Arguments
x |
A |
... |
further arguments passed to or from other methods. |
Value
Prints the modwt decomposition
Author(s)
James Balamuta and Nathanael Claussen
Examples
set.seed(999)
x = rnorm(100)
print(modwt(x))
Print Wavelet Variances
Description
Displays the summary table of wavelet variance.
Usage
## S3 method for class 'wvar'
print(x, ...)
Arguments
x |
A |
... |
Further arguments passed to or from other methods. |
Value
Summary table
Author(s)
James Balamuta
Examples
set.seed(999)
x = rnorm(100)
out = wvar(x)
print( out )
Quantisation Noise (QN) to WV
Description
This function compute the Haar WV of a Quantisation Noise (QN) process
Usage
qn_to_wv(q2, tau)
Arguments
q2 |
A |
tau |
A |
Value
A vec
containing the wavelet variance of the QN.
Process Haar Wavelet Variance Formula
The Quantization Noise (QN) process has a Haar Wavelet Variance given by:
\nu _j^2\left( {{Q^2}} \right) = \frac{{6{Q^2}}}{{\tau _j^2}}
Find Quantiles
Description
Attempts to find quantiles
Usage
quantile_cpp(x, probs)
Arguments
x |
A |
probs |
A |
Value
A vector
containing the quantiles
Author(s)
James J Balamuta
Time Series Recursive Filters
Description
Applies a recursive filter to a univariate time series.
Usage
rfilter(x, filter, init)
Arguments
x |
A |
filter |
A |
init |
A |
Details
Note: The length of 'init' must be equal to the length of 'filter'. This is a port of the rfilter function harnessed by the filter function in stats. It is about 6-7 times faster than R's base function. The benchmark was done on iMac Late 2013 using vecLib as the BLAS.
Value
x A column vector
with its contents reversed.
Author(s)
James J Balamuta
Comparison between classical and robust Wavelet Variances
Description
Displays a plot of the wavelet variances (classical and robust) for a given time series accounting for CI values.
Usage
robust_eda(
x,
eff = 0.6,
units = NULL,
xlab = NULL,
ylab = NULL,
main = NULL,
col_wv = NULL,
col_ci = NULL,
nb_ticks_x = NULL,
nb_ticks_y = NULL,
legend_position = NULL,
...
)
Arguments
x |
A time series objects. |
eff |
An |
units |
A |
xlab |
A |
ylab |
A |
main |
A |
col_wv |
A |
col_ci |
A |
nb_ticks_x |
An |
nb_ticks_y |
An |
legend_position |
A |
... |
Additional arguments affecting the plot. |
Value
Plot of wavelet variance and confidence interval for each scale.
Author(s)
Stephane Guerrier, Nathanael Claussen, and Justin Lee
Examples
set.seed(999)
n = 10^4
Xt = rnorm(n)
wv = wvar(Xt)
plot(wv)
plot(wv, main = "Simulated white noise", xlab = "Scales")
plot(wv, units = "sec", legend_position = "topright")
plot(wv, col_wv = "darkred", col_ci = "pink")
Random Walk to WV
Description
This function compute the WV (haar) of a Random Walk process
Usage
rw_to_wv(gamma2, tau)
Arguments
gamma2 |
A |
tau |
A |
Value
A vec
containing the wavelet variance of the random walk.
Process Haar Wavelet Variance Formula
The Random Walk (RW) process has a Haar Wavelet Variance given by:
\nu _j^2\left( {{\gamma ^2}} \right) = \frac{{\left( {\tau _j^2 + 2} \right){\gamma ^2}}}{{12{\tau _j}}}
Calculates Length of Seasonal Padding
Description
Computes the total phi and total theta vector length.
Usage
sarma_calculate_spadding(np, nq, nsp, nsq, ns)
Arguments
np |
An |
nq |
An |
nsp |
An |
nsq |
An |
Value
A vec
with rows:
- p
Number of phi parameters
- q
Number of theta parameters
See Also
Determine parameter expansion based upon objdesc
Description
Calculates the necessary vec space needed to pad the vectors for seasonal terms.
Usage
sarma_components(objdesc)
Arguments
objdesc |
A |
Value
A vec
with the structure:
- np
Number of Non-Seasonal AR Terms
- nq
Number of Non-Seasonal MA Terms
- nsp
Number of Seasonal AR Terms
- nsq
Number of Seasonal MA Terms
- ns
Number of Seasons (e.g. 12 is year)
- p
Total number of phi terms
- q
Total number of theta terms
Expand Parameters for an SARMA object
Description
Creates an expanded PHI and THETA vector for use in other objects.
Usage
sarma_expand(params, objdesc)
Arguments
params |
A |
objdesc |
A |
Details
The objdesc
is assumed to have the structure of:
AR(p)
MA(q)
SAR(P)
SMA(Q)
Seasons
Value
A field<vec>
of size two as follows:
AR values
THETA values
(Internal) Expand the SARMA Parameters
Description
(Internal) Expand the SARMA Parameters
Usage
sarma_expand_unguided(params, np, nq, nsp, nsq, ns, p, q)
Arguments
params |
A |
np |
An |
nq |
An |
nsp |
An |
nsq |
An |
p |
An |
q |
An |
Value
A field<vec>
that contains the expansion.
Create the ts.model obj.desc given split values
Description
Computes the total phi and total theta vector length.
Usage
sarma_objdesc(ar, ma, sar, sma, s, i, si)
Arguments
ar |
A |
ma |
A |
sar |
A |
sma |
A |
s |
An |
i |
An |
si |
An |
Value
A vec
with rows:
- np
Number of Non-Seasonal AR Terms
- nq
Number of Non-Seasonal MA Terms
- nsp
Number of Seasonal AR Terms
- nsq
Number of Seasonal MA Terms
- nsigma
Number of Variances (always 1)
- s
Season Value
- i
Number of non-seasonal differences
- si
Number of Seasonal Differences
Efficient way to merge items together
Description
Efficient way to merge items together
Usage
sarma_params_construct(ar, ma, sar, sma)
Computes the MODWT scales
Description
Calculates the MODWT scales
Usage
scales_cpp(nb_level)
Arguments
nb_level |
A |
Details
Used in wvar object.
Value
A vec
that contains 2^1, ... , 2^J
Generate a sequence of values
Description
Creates a vector containing a sequence of values starting at the initial point and going to the terminal point.
Usage
seq_cpp(a, b)
Arguments
a |
An |
b |
An |
Value
A vector
containing values moving from a to b. There are no restrictions on A's range.
Author(s)
James J Balamuta
Generate a sequence of values based on supplied number
Description
Creates a vector containing a sequence of values starting at 1 and going to the terminal point.
Usage
seq_len_cpp(n)
Arguments
n |
An |
Value
A vector
containing values moving from 1 to n.
Author(s)
James J Balamuta
Haar filter for a spatial case
Description
Haar filter for a spatial case
Usage
sp_hfilter(jscale)
Arguments
jscale |
An |
Compute the Spatial Wavelet Coefficients
Description
Compute the Spatial Wavelet Coefficients
Usage
sp_modwt_cpp(X, J1, J2)
Arguments
X |
is a matrix with row, col orientation |
J1 , J2 |
is the levels of decomposition along the rows, columns |
Details
By default this function will return the wavelet coefficient in addition to the wavelet
Value
A list
of vectors
containing the wavelet coefficients.
Summary Discrete Wavelet Transform
Description
Prints DWT object in a concise format
Usage
## S3 method for class 'dwt'
summary(object, ...)
Arguments
object |
A |
... |
additional arguments affecting the summary produced. |
Value
Prints the dwt matrix decomposition
Author(s)
Nathanael Claussen and Justin Lee
Examples
set.seed(999)
x = rnorm(2^8)
summary(dwt(x))
Summary Maximum Overlap Discrete Wavelet Transform
Description
Prints MODWT object in a concise format
Usage
## S3 method for class 'modwt'
summary(object, ...)
Arguments
object |
A |
... |
additional arguments affecting the summary produced. |
Value
Prints the modwt matrix decomposition
Author(s)
Nathanael Claussen and Justin Lee
Examples
set.seed(999)
x = rnorm(100)
summary(modwt(x))
Summary of Wavelet Variances
Description
Displays the summary table of wavelet variance accounting for CI values and supplied efficiency.
Usage
## S3 method for class 'wvar'
summary(object, ...)
Arguments
object |
A |
... |
Additional arguments affecting the summary produced. |
Value
Summary table and other properties of the object.
Author(s)
James Balamuta
Examples
set.seed(999)
x = rnorm(100)
ret = wvar(x)
summary(ret)
Model Process to WV
Description
This function computes the summation of all Processes to WV (haar) in a given model
Usage
theoretical_wv(theta, desc, objdesc, tau)
Arguments
theta |
A |
desc |
A |
objdesc |
A |
tau |
A |
Value
A vec
containing the wavelet variance of the model.
Convert Unit of Time Series Data
Description
Manipulate the units of time to different ones
Usage
unitConversion(x, from.unit, to.unit)
Arguments
x |
A |
from.unit |
A |
to.unit |
A |
Details
The supported units are "ns"(nanosecond), "ms"(millisecond), "sec", "min", "hour", "day", "month", and "year".
Make sure from.unit
and to.unit
are not NULL
before it is passed to this function.
Value
A list
with the following structure:
"x": Data
"converted": A
boolean
indicating whether conversion is made
Examples
x = seq(60, 3600, 60)
unitConversion(x, 'sec', 'min')
y = 1:10
unitConversion(y, 'hour', 'sec')
Generate a Wave Variance for a Univariate Time Series
Description
Computes an estimate of the wave variance
Usage
wave_variance(signal_modwt_bw, robust = FALSE, eff = 0.6)
Arguments
signal_modwt_bw |
A |
robust |
A |
eff |
A |
Value
A vec
that contains the wave variance.
Cross Covariance of Matrix
Description
Calculates the Cross-covariance between multiple wavelet transfomations (dwt or modwt)
Usage
wccv(x, decomp = "modwt", filter = "haar", nlevels = NULL)
Arguments
x |
A |
decomp |
A |
filter |
A |
nlevels |
An |
Details
If nlevels
is not specified, it is set to \left\lfloor {{{\log }_2}\left( {length\left( x \right)} \right)} \right\rfloor
Value
Returns a matrix
of lists
of all the possible pair cross-covariance, variance of each wavelet cross-covariance and its 95
Author(s)
Justin Lee
Mapping to log10 scale
Description
Map x to the value in log10 scale
Usage
wccv_get_y(x, tick_y_min, tick_y_step)
Arguments
x |
A |
tick_y_min |
A |
tick_y_step |
An |
Details
tick_y_min
is usually chosen as floor(min(log10(abs(x))))
Value
A field<vec>
that contains values in log10 scale.
Author(s)
James Balamuta and Justin Lee
Examples
x = 2^(-1:-9)
y.min = floor(min(log10(abs(x))))
y.step = 2
wccv_get_y(x, y.min, y.step)
Cross Covariance of a TS Pair
Description
Calculates the Cross-covariance between two wavelet transfomations (dwt or modwt)
Usage
wccv_pair(x, y, decomp = "modwt", filter = "haar", nlevels = NULL)
Arguments
x |
A |
y |
A |
decomp |
A |
filter |
A |
nlevels |
An |
Details
If nlevels
is not specified, it is set to \left\lfloor {{{\log }_2}\left( {length\left( x \right)} \right)} \right\rfloor
Value
Returns a list
of a matrix
containing cross-covariance, variance of each wavelet cross-covariance and its 95
Author(s)
Justin Lee
Gaussian White Noise to WV
Description
This function compute the Haar WV of a Gaussian White Noise process
Usage
wn_to_wv(sigma2, tau)
Arguments
sigma2 |
A |
tau |
A |
Value
A vec
containing the wavelet variance of the white noise.
Process Haar Wavelet Variance Formula
The Gaussian White Noise (WN) process has a Haar Wavelet Variance given by:
\nu _j^2\left( {{\sigma ^2}} \right) = \frac{{{\sigma ^2}}}{{\tau _j^2}}
Wavelet Variance
Description
Calculates the (MO)DWT wavelet variance
Usage
wvar(x, ...)
## S3 method for class 'lts'
wvar(
x,
decomp = "modwt",
filter = "haar",
nlevels = NULL,
alpha = 0.05,
robust = FALSE,
eff = 0.6,
to.unit = NULL,
...
)
## S3 method for class 'gts'
wvar(
x,
decomp = "modwt",
filter = "haar",
nlevels = NULL,
alpha = 0.05,
robust = FALSE,
eff = 0.6,
to.unit = NULL,
...
)
## S3 method for class 'ts'
wvar(
x,
decomp = "modwt",
filter = "haar",
nlevels = NULL,
alpha = 0.05,
robust = FALSE,
eff = 0.6,
to.unit = NULL,
...
)
## S3 method for class 'imu'
wvar(
x,
decomp = "modwt",
filter = "haar",
nlevels = NULL,
alpha = 0.05,
robust = FALSE,
eff = 0.6,
to.unit = NULL,
...
)
## Default S3 method:
wvar(
x,
decomp = "modwt",
filter = "haar",
nlevels = NULL,
alpha = 0.05,
robust = FALSE,
eff = 0.6,
freq = 1,
from.unit = NULL,
to.unit = NULL,
...
)
Arguments
x |
A |
... |
Further arguments passed to or from other methods. |
decomp |
A |
filter |
A |
nlevels |
An |
alpha |
A |
robust |
A |
eff |
A |
to.unit |
A |
freq |
A |
from.unit |
A |
Details
The default value of nlevels
will be set to \left\lfloor {{{\log }_2}\left( {length\left( x \right)} \right)} \right\rfloor
, unless otherwise specified.
Value
A list
with the structure:
"variance": Wavelet Variance
"ci_low": Lower CI
"ci_high": Upper CI
"robust": Robust active
"eff": Efficiency level for Robust calculation
"alpha": p value used for CI
"unit": String representation of the unit
Author(s)
James Balamuta, Justin Lee and Stephane Guerrier
Examples
set.seed(999)
x = rnorm(100)
# Default
wvar(x)
# Robust
wvar(x, robust = TRUE, eff=0.3)
# Classical
wvar(x, robust = FALSE, eff=0.3)
# 90% Confidence Interval
wvar(x, alpha = 0.10)
Computes the (MODWT) wavelet variance
Description
Calculates the (MODWT) wavelet variance
Usage
wvar_cpp(signal_modwt_bw, robust, eff, alpha, ci_type)
Arguments
signal_modwt_bw |
A |
robust |
A |
eff |
A |
alpha |
A |
ci_type |
A |
Details
This function does the heavy lifting with the signal_modwt_bw
Value
A mat
with the structure:
"variance"Wavelet Variance
"low"Lower CI
"high"Upper CI