Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Time Series Analysis Tools
Version:0.2.3
LazyData:true
Maintainer:Stéphane Guerrier <stef.guerrier@gmail.com>
Description:A system contains easy-to-use tools as a support for time series analysis courses. In particular, it incorporates a technique called Generalized Method of Wavelet Moments (GMWM) as well as its robust implementation for fast and robust parameter estimation of time series models which is described, for example, in Guerrier et al. (2013) <doi:10.1080/01621459.2013.799920>. More details can also be found in the paper linked to via the URL below.
Depends:R (≥ 3.6.0)
License:AGPL-3 | file LICENSE
Imports:Rcpp, stats, utils, scales, grDevices, graphics, broom, dplyr,magrittr, methods, purrr, tidyr, robcor
LinkingTo:Rcpp, RcppArmadillo
RoxygenNote:7.3.3
Encoding:UTF-8
Suggests:knitr, rmarkdown
VignetteBuilder:knitr
URL:https://github.com/SMAC-Group/simts,https://arxiv.org/pdf/1607.04543.pdf
BugReports:https://github.com/SMAC-Group/simts/issues
NeedsCompilation:yes
Packaged:2025-10-08 13:03:30 UTC; lionel
Author:Stéphane Guerrier [aut, cre, cph], James Balamuta [aut, cph], Roberto Molinari [aut, cph], Justin Lee [aut], Lionel Voirol [aut], Yuming Zhang [aut], Wenchao Yang [ctb], Nathanael Claussen [ctb], Yunxiang Zhang [ctb], Christian Gunning [cph], Romain Francois [cph], Ross Ihaka [cph], R Core Team [cph]
Repository:CRAN
Date/Publication:2025-10-08 14:40:03 UTC

simts: Time Series Analysis Tools

Description

logo

A system contains easy-to-use tools as a support for time series analysis courses. In particular, it incorporates a technique called Generalized Method of Wavelet Moments (GMWM) as well as its robust implementation for fast and robust parameter estimation of time series models which is described, for example, in Guerrier et al. (2013)doi: 10.1080/01621459.2013.799920. More details can also be found in the paper linked to via the URL below.

logo

A system contains easy-to-use tools as a support for time series analysis courses. In particular, it incorporates a technique called Generalized Method of Wavelet Moments (GMWM) as well as its robust implementation for fast and robust parameter estimation of time series models which is described, for example, in Guerrier et al. (2013)doi: 10.1080/01621459.2013.799920. More details can also be found in the paper linked to via the URL below.

Details

The data sets in this package may change at a moments notice.

Author(s)

Maintainer: Stéphane Guerrierstef.guerrier@gmail.com [copyright holder]

Authors:

Other contributors:

James Balamutabalamut2@illinois.edu,Stephane Guerrierstef.guerrier@gmail.com,Roberto Molinariroberto.molinari@hotmail.it,Wenchao Yangwyang40@illinois.eduJustin Leemunsheet93@gmail.comYuming Zhangyuming.zhang@unige.ch

See Also

Useful links:

Useful links:


Multiple a ts.model by constant

Description

Sets up the necessary backend for creating multiple model objects.

Usage

## S3 method for class 'ts.model'x * y

Arguments

x

Anumeric value

y

Ats.model object

Value

An S3 object with called ts.model with the following structure:

process.desc

y desc replicated x times

theta

y theta replicated x times

plength

Number of Parameters

desc

y desc replicated x times

obj.desc

Depth of Parameters e.g. list(c(1,1),c(1,1))

starting

Guess Starting values? TRUE or FALSE (e.g. specified value)

Author(s)

James Balamuta and Stephane Guerrier

Examples

4*DR()+2*WN()DR()*4 + WN()*2AR1(phi=.3,sigma=.2)*3

Add ts.model objects together

Description

Sets up the necessary backend for combining ts.model objects.

Usage

## S3 method for class 'ts.model'x + y

Arguments

x

Ats.model object

y

Ats.model object

Value

An S3 object with called ts.model with the following structure:

process.desc

combined x, y desc

theta

combined x, y theta

plength

Number of Parameters

desc

Add process to queue e.g. c("AR1","WN")

obj.desc

Depth of Parameters e.g. list(1, c(1,1), c(length(ar),length(ma),1) )

starting

Guess Starting values? TRUE or FALSE (e.g. specified value)

Author(s)

James Balamuta

Examples

DR()+WN()AR1(phi=.3,sigma=.2)

Auto-Covariance and Correlation Functions

Description

The acf function computes the estimatedautocovariance or autocorrelation for both univariate and multivariate cases.

Usage

.acf(x, lagmax = 0L, cor = TRUE, demean = TRUE)

Arguments

x

Amatrix with dimensionsN \times S or N observations and S processes

lagmax

Ainteger

cor

Abool indicating whether the correlation (TRUE) or covariance (FALSE) should be computed.

demean

Abool indicating whether the data should be detrended(TRUE) or not (FALSE)


Akaike's Information Criterion

Description

This function calculates AIC, BIC or HQ for a fitsimts object. This function currentlyonly supports models estimated by the MLE.

Usage

## S3 method for class 'fitsimts'AIC(object, k = 2, ...)

Arguments

object

A fitsimts object.

k

The penalty per parameter to be used; the default k = 2 is the classical AIC.

...

Optionally more fitted model objects.

Value

AIC, BIC or HQ

Author(s)

Stéphane Guerrier

Examples

set.seed(1)n = 300Xt = gen_gts(n, AR(phi = c(0, 0, 0.8), sigma2 = 1))mod = estimate(AR(3), Xt)# AICAIC(mod)# BICAIC(mod, k = log(n))# HQAIC(mod, k = 2*log(log(n)))

Create an Autoregressive P [AR(P)] Process

Description

Sets up the necessary backend for the AR(P) process.

Usage

AR(phi = NULL, sigma2 = 1)

Arguments

phi

Avector with double values for the\phi of an AR(P) process (see Note for details).

sigma2

Adouble value for the variance,\sigma ^2, of an AR(P) process. (see Note for details).

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "AR-1","AR-2", ..., "AR-P", "SIGMA2"

theta

\phi_1,\phi_2, ...,\phi_p,\sigma^2

plength

Number of Parameters

desc

"AR"

print

String containing simplified model

obj.desc

Depth of Parameters e.g. list(p,1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

X_t = \sum_{j = 1}^p \phi_j X_{t-1} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

AR(1) # Slower version of AR1()AR(phi=.32, sigma=1.3) # Slower version of AR1()AR(2) # Equivalent to ARMA(2,0).

Definition of an Autoregressive Process of Order 1

Description

Definition of an Autoregressive Process of Order 1

Usage

AR1(phi = NULL, sigma2 = 1)

Arguments

phi

Adouble value for the parameter\phi (see Note for details).

sigma2

Adouble value for the variance parameter\sigma ^2 (see Note for details).

Value

An S3 object containing the specified ts.model with the following structure:

process.desc

Used in summary: "AR1","SIGMA2"

theta

Parameter vector including\phi,\sigma^2

plength

Number of parameters

print

String containing simplified model

desc

"AR1"

obj.desc

Depth of Parameters e.g. list(1,1)

starting

Find starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following AR(1) model:

X_t = \phi X_{t-1} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

AR1()AR1(phi=.32, sigma2 = 1.3)

Create an Autoregressive Integrated Moving Average (ARIMA) Process

Description

Sets up the necessary backend for the ARIMA process.

Usage

ARIMA(ar = 1, i = 0, ma = 1, sigma2 = 1)

Arguments

ar

Avector orinteger containing either the coefficients for\phi's or the process numberp for the Autoregressive (AR) term.

i

Aninteger containing the number of differences to be done.

ma

Avector orinteger containing either the coefficients for\theta's or the process numberq for the Moving Average (MA) term.

sigma2

Adouble value for the standard deviation,\sigma, of the ARIMA process.

Details

A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation like R.

Value

An S3 object with called ts.model with the following structure:

process.desc

AR*p,MA*q

theta

\sigma

plength

Number of parameters

print

String containing simplified model

obj.desc

y desc replicated x times

obj

Depth of parameters e.g. list(c(length(ar),length(ma),1) )

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

\Delta^i X_t = \sum_{j = 1}^p \phi_j \Delta^i X_{t-j} + \sum_{j = 1}^q \theta_j \varepsilon_{t-j} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

# Create an ARMA(1,2) processARIMA(ar=1,2)# Creates an ARMA(3,2) process with predefined coefficients.ARIMA(ar=c(0.23,.43, .59), ma=c(0.4,.3))# Creates an ARMA(3,2) process with predefined coefficients and standard deviationARIMA(ar=c(0.23,.43, .59), ma=c(0.4,.3), sigma2 = 1.5)

Create an Autoregressive Moving Average (ARMA) Process

Description

Sets up the necessary backend for the ARMA process.

Usage

ARMA(ar = 1, ma = 1, sigma2 = 1)

Arguments

ar

Avector orinteger containing either the coefficients for\phi's or the process numberp for the Autoregressive (AR) term.

ma

Avector orinteger containing either the coefficients for\theta's or the process numberq for the Moving Average (MA) term.

sigma2

Adouble value for the standard deviation,\sigma, of the ARMA process.

Details

A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation like R.

Value

An S3 object with called ts.model with the following structure:

process.desc

AR*p,MA*q

theta

\sigma

plength

Number of Parameters

print

String containing simplified model

obj.desc

y desc replicated x times

obj

Depth of Parameters e.g. list(c(length(ar),length(ma),1) )

starting

Guess Starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

X_t = \sum_{j = 1}^p \phi_j X_{t-j} + \sum_{j = 1}^q \theta_j \varepsilon_{t-j} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

# Create an ARMA(1,2) processARMA(ar=1,2)# Creates an ARMA(3,2) process with predefined coefficients.ARMA(ar=c(0.23,.43, .59), ma=c(0.4,.3))# Creates an ARMA(3,2) process with predefined coefficients and standard deviationARMA(ar=c(0.23,.43, .59), ma=c(0.4,.3), sigma2 = 1.5)

Definition of an ARMA(1,1)

Description

Definition of an ARMA(1,1)

Usage

ARMA11(phi = NULL, theta = NULL, sigma2 = 1)

Arguments

phi

Adouble containing the parameter\phi _1 (see Note for details).

theta

Adouble containing the parameter\theta _1 (see Note for details).

sigma2

Adouble value for the parameter\sigma^2 (see Note for details).

Details

A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation like R.

Value

An S3 object with called ts.model with the following structure:

process.desc

AR1,MA1,SIGMA2

theta

\phi,\theta,\sigma^2

plength

Number of Parameters: 3

print

String containing simplified model

obj.desc

Depth of Parameters e.g. list(c(1,1,1))

starting

Guess Starting values?TRUE orFALSE (e.g. specified value)

Note

We consider the following model:

X_t = \phi X_{t-1} + \theta_1 \varepsilon_{t-1} + \varepsilon_t,

where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

# Creates an ARMA(1,1) process with predefined coefficients.ARMA11(phi = .23, theta = .1, sigma2 = 1)# Creates an ARMA(1,1) process with values to be guessed on callibration.ARMA11()

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

Avector of length p containing AR coefficients

ma

Avector of length q containing MA coefficients

lag_max

Aunsigned integer indicating the maximum lag necessary

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 Amatrix listing values from 1...nx in one column and 1...1, 2...2,....,n...n, in the other

Author(s)

JJB


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

Acolumn vector of length p

ma

Acolumn vector of length q

lag_max

Aint of the largest MA(Inf) coefficient required.

Details

This function is a port of the base stats package's ARMAtoMA. There is no significant speed difference between the two.

Value

Acolumn vector containing coefficients

Author(s)

R Core Team and JJB


B Matrix

Description

B Matrix

Usage

B_matrix(A, at_omega)

Arguments

A

Amat containing the first derivatives of the process.

at_omega

Amat containing A^T * Omega

Value

Amat


Create an Drift (DR) Process

Description

Sets up the necessary backend for the DR process.

Usage

DR(omega = NULL)

Arguments

omega

Adouble value for the slope of a DR process (see Note for details).

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "DR"

theta

slope

print

String containing simplified model

plength

Number of parameters

obj.desc

y desc replicated x times

obj

Depth of parameters e.g. list(1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

Y_t = \omega t

Author(s)

James Balamuta

Examples

DR()DR(omega=3.4)

Analytic D matrix of Processes

Description

This function computes each process to WV (haar) in a given model.

Usage

D_matrix(theta, desc, objdesc, tau, omegadiff)

Arguments

theta

Avec containing the list of estimated parameters.

desc

Avector<string> containing a list of descriptors.

objdesc

Afield<vec> containing a list of object descriptors.

tau

Avec containing the scales e.g.2^{\tau}

omegadiff

Avec that contains the result of Omega * (wv_empir - wv_theo)

Details

Function returns the matrix effectively known as "D"

Value

Amatrix with the process derivatives going down the column

Author(s)

James Joseph Balamuta (JJB)


Definition of a Fractional Gaussian Noise (FGN) Process

Description

Definition of a Fractional Gaussian Noise (FGN) Process

Usage

FGN(sigma2 = 1, H = 0.9999)

Arguments

sigma2

Adouble.

H

Adouble.

Value

An S3 object containing the specified ts.model with the following structure:

process.desc

Used in summary: "SIGMA2","H"

theta

Parameter vector including\sigma^2,H

plength

Number of parameters

print

String containing simplified model

desc

"FGN"

obj.desc

Depth of Parameters e.g. list(1,1)

starting

Find starting values? TRUE or FALSE (e.g. specified value)

Author(s)

Lionel Voirol, Davide Cucci

Examples

FGN()FGN(sigma2 = 1, H = 0.9999)

Create a Gauss-Markov (GM) Process

Description

Sets up the necessary backend for the GM process.

Usage

GM(beta = NULL, sigma2_gm = 1)

Arguments

beta

Adouble value for the\beta of an GM process (see Note for details).

sigma2_gm

Adouble value for the variance,\sigma ^2_{gm}, of a GM process (see Note for details).

Details

When supplying values for\beta and\sigma ^2_{gm},these parameters should be of a GM process and NOT of an AR1. That is,do not supply AR1 parameters such as\phi,\sigma^2.

Internally, GM parameters are converted to AR1 using the 'freq' supplied when creating data objects (gts)or specifying a 'freq' parameter in simts or simts.imu.

The 'freq' of a data object takes precedence over the 'freq' set when modeling.

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "BETA","SIGMA2"

theta

\beta,\sigma ^2_{gm}

plength

Number of parameters

print

String containing simplified model

desc

"GM"

obj.desc

Depth of parameters e.g. list(1,1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

X_t = e^{(-\beta)} X_{t-1} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2(1-e^{2\beta}).

Author(s)

James Balamuta

Examples

GM()GM(beta=.32, sigma2_gm=1.3)

Definition of a Mean deterministic vector returned by the matrix by vector product of matrixX and vector\beta

Description

Definition of a Mean deterministic vector returned by the matrix by vector product of matrixX and vector\beta

Usage

M(X, beta)

Arguments

X

AMatrix with dimension n*p.

beta

Avector with dimension p*1

Value

An S3 object containing the specified ts.model with the following structure:

process.desc

Used in summary: "X","BETA"

theta

Matrix X, vector beta

plength

Number of parameters

print

String containing simplified model

desc

"M"

obj.desc

Depth of Parameters e.g. list(1,1)

starting

Find starting values? TRUE or FALSE (e.g. specified value)

Author(s)

Lionel Voirol, Davide Cucci

Examples

X = matrix(rnorm(15*5), nrow = 15, ncol = 5)beta=seq(5)M(X = X, beta = beta)

Create an Moving Average Q [MA(Q)] Process

Description

Sets up the necessary backend for the MA(Q) process.

Usage

MA(theta = NULL, sigma2 = 1)

Arguments

theta

Adouble value for the parameter\theta (see Note for details).

sigma2

Adouble value for the variance parameter\sigma ^2 (see Note for details).

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "MA-1","MA-2", ..., "MA-Q", "SIGMA2"

theta

\theta_1,\theta_2, ...,\theta_q,\sigma^2

plength

Number of parameters

desc

"MA"

print

String containing simplified model

obj.desc

Depth of parameters e.g. list(q,1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

X_t = \sum_{j = 1}^q \theta_j \varepsilon_{t-1} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

MA(1) # One thetaMA(2) # Two thetas!MA(theta=.32, sigma=1.3) # 1 theta with a specific value.MA(theta=c(.3,.5), sigma=.3) # 2 thetas with specific values.

Definition of an Moving Average Process of Order 1

Description

Definition of an Moving Average Process of Order 1

Usage

MA1(theta = NULL, sigma2 = 1)

Arguments

theta

Adouble value for the parameter\theta (see Note for details).

sigma2

Adouble value for the variance parameter\sigma ^2 (see Note for details).

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "MA1","SIGMA2"

theta

\theta,\sigma^2

plength

Number of parameters

print

String containing simplified model

desc

"MA1"

obj.desc

Depth of parameters e.g. list(1,1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

X_t = \theta \varepsilon_{t-1} + \varepsilon_t

, where\varepsilon_t is iid from a zero mean normal distribution with variance\sigma^2.

Author(s)

James Balamuta

Examples

MA1()MA1(theta = .32, sigma2 = 1.3)

Median Absolute Prediction Error

Description

This function calculates Median Absolute Prediction Error (MAPE), which assesses the prediction performance with respect to point forecasts of a given model. It is calculated based on one-step ahead prediction and reforecasting.

Usage

MAPE(model, Xt, start = 0.8, plot = TRUE)

Arguments

model

A time series model.

Xt

Avector of time series data.

start

Anumeric indicating the starting proportion of the datathat is used for prediction.

plot

Aboolean indicating whether a model accuracy plot basedon MAPE is returned or not.

Value

The MAPE calculated based on one-step ahead prediction and reforecastingis returned along with its standard deviation.

Author(s)

Stéphane Guerrier and Yuming Zhang


Definition of a Matérn Process

Description

Definition of a Matérn Process

Usage

MAT(sigma2 = 1, lambda = 0.35, alpha = 0.9)

Arguments

sigma2

Adouble.

lambda

Adouble.

alpha

Adouble.

Value

An S3 object containing the specified ts.model with the following structure:

process.desc

Used in summary: "SIGMA2","LAMBDA""ALPHA"

theta

Parameter vector including\sigma^2,\lambda,\alpha

plength

Number of parameters

print

String containing simplified model

desc

"MAT"

obj.desc

Depth of Parameters e.g. list(1,1,1)

starting

Find starting values? TRUE or FALSE (e.g. specified value)

Author(s)

Lionel Voirol, Davide Cucci

Examples

MAT()MAT(sigma2 = 1, lambda = 0.35, alpha = 0.9)

Ma function.

Description

Ma function.

Usage

Ma_cpp(x, alpha)

Arguments

x

Adouble.

alpha

Adouble.


Ma vectorized function.

Description

Ma vectorized function.

Usage

Ma_cpp_vec(x, alpha)

Arguments

x

ANumericVector.


Absolute Value or Modulus of a Complex Number.

Description

Computes the value of the Modulus.

Usage

Mod_cpp(x)

Arguments

x

Acx_vec.

Details

Consider a complex number defined as:z = x + i y with realx andy,The modulus is defined as:r = Mod(z) = \sqrt{(x^2 + y^2)}

Value

Avec containing the modulus for each element.


Definition of a Power Law Process

Description

Definition of a Power Law Process

Usage

PLP(sigma2 = 1, d = 0.4)

Arguments

sigma2

Adouble.

d

Adouble.

Value

An S3 object containing the specified ts.model with the following structure:

process.desc

Used in summary: "SIGMA2","d"

theta

Parameter vector including\sigma^2,d

plength

Number of parameters

print

String containing simplified model

desc

"PLP"

obj.desc

Depth of Parameters e.g. list(1,1)

starting

Find starting values? TRUE or FALSE (e.g. specified value)

Author(s)

Lionel Voirol, Davide Cucci

Examples

PLP()PLP(sigma2 = 1, d = 0.4)

Create an Quantisation Noise (QN) Process

Description

Sets up the necessary backend for the QN process.

Usage

QN(q2 = NULL)

Arguments

q2

Adouble value for theQ^2 of a QN process.

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "QN"

theta

Q^2

plength

Number of parameters

print

String containing simplified model

desc

y desc replicated x times

obj.desc

Depth of parameters e.g. list(1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Author(s)

James Balamuta

Examples

QN()QN(q2=3.4)

Create an Random Walk (RW) Process

Description

Sets up the necessary backend for the RW process.

Usage

RW(gamma2 = NULL)

Arguments

gamma2

Adouble value for the variance\gamma ^2

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "RW"

theta

\sigma

plength

Number of parameters

print

String containing simplified model

desc

y desc replicated x times

obj.desc

Depth of parameters e.g. list(1)

starting

Guess starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following model:

Y_t = \sum\nolimits_{t=0}^{T} \gamma_0*Z_t

whereZ_t is iid and follows a standard normal distribution.

Author(s)

James Balamuta

Examples

RW()RW(gamma2=3.4)

Function to Compute Direction Random Walk Moves

Description

The RW2dimension function computes direction random walk moves.

Usage

RW2dimension(steps = 100, probs = c(0.25, 0.5, 0.75))

Arguments

steps

Aninteger that counts the number of steps of the random walk.

probs

Avector ofdouble that specifies the probabilities to choose each direction.

Author(s)

Stéphane Guerrier

Examples

RW2dimension(steps = 50, probs = c(0.2, 0.5, 0.6))

Hook into R's ARIMA function

Description

Uses R's ARIMA function to obtain CSS values for starting condition

Usage

Rcpp_ARIMA(data, params)

Arguments

data

Avec of data.

params

Avec of the ARMA parameters

Value

Avec containing the CSS of the ARMA parameters.


Create a Seasonal Autoregressive Integrated Moving Average (SARIMA) Process

Description

Sets up the necessary backend for the SARIMA process.

Usage

SARIMA(ar = 1, i = 0, ma = 1, sar = 1, si = 0, sma = 1, s = 12, sigma2 = 1)

Arguments

ar

Avector orinteger containing either the coefficients for\phi's or the process numberp for the Autoregressive (AR) term.

i

Aninteger containing the number of differences to be done.

ma

Avector orinteger containing either the coefficients for\theta's or the process numberq for the Moving Average (MA) term.

sar

Avector orinteger containing either the coefficients for\Phi's or the process numberP for the Seasonal Autoregressive (SAR) term.

si

Aninteger containing the number of seasonal differences to be done.

sma

Avector orinteger containing either the coefficients for\Theta's or the process numberQ for the Seasonal Moving Average (SMA) term.

s

Aninteger containing the seasonality.

sigma2

Adouble value for the standard deviation,\sigma, of the SARMA process.

Details

A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation unlike R.

Value

An S3 object with called ts.model with the following structure:

process.desc

AR*p,MA*q,SAR*P,SMA*Q

theta

\sigma

plength

Number of parameters

desc

Type of model

desc.simple

Type of model (after simplification)

print

String containing simplified model

obj.desc

y desc replicated x times

obj

Depth of Parameters e.g. list(c(length(ar), length(ma), length(sar), length(sma), 1, i, si) )

starting

Guess Starting values? TRUE or FALSE (e.g. specified value)

Author(s)

James Balamuta

Examples

# Create an SARIMA(1,1,2)x(1,0,1) processSARIMA(ar = 1, i = 1, ma = 2, sar = 1, si = 0, sma =1)# Creates an SARMA(1,0,1)x(1,1,1) process with predefined coefficients.SARIMA(ar=0.23, i = 0, ma=0.4, sar = .3,  sma = .3)

Create a Seasonal Autoregressive Moving Average (SARMA) Process

Description

Sets up the necessary backend for the SARMA process.

Usage

SARMA(ar = 1, ma = 1, sar = 1, sma = 1, s = 12, sigma2 = 1)

Arguments

ar

Avector orinteger containing either the coefficients for\phi's or the process numberp for the Autoregressive (AR) term.

ma

Avector orinteger containing either the coefficients for\theta's or the process numberq for the Moving Average (MA) term.

sar

Avector orinteger containing either the coefficients for\Phi's or the process numberP for the Seasonal Autoregressive (SAR) term.

sma

Avector orinteger containing either the coefficients for\Theta's or the process numberQ for the Seasonal Moving Average (SMA) term.

s

Ainteger indicating the seasonal value of the data.

sigma2

Adouble value for the standard deviation,\sigma, of the SARMA process.

Details

A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation unlike R.

Value

An S3 object with called ts.model with the following structure:

process.desc

AR*p,MA*q,SAR*P,SMA*Q

theta

\sigma

plength

Number of Parameters

print

String containing simplified model

obj.desc

y desc replicated x times

obj

Depth of Parameters e.g. list(c(length(ar), length(ma), length(sar), length(sma), 1) )

starting

Guess Starting values? TRUE or FALSE (e.g. specified value)

Author(s)

James Balamuta

Examples

# Create an SARMA(1,2)x(1,1) processSARMA(ar = 1, ma = 2,sar = 1, sma =1)# Creates an SARMA(1,1)x(1,1) process with predefined coefficients.SARMA(ar=0.23, ma=0.4, sar = .3, sma = .3)

Definition of a Sinusoidal (SIN) Process

Description

Definition of a Sinusoidal (SIN) Process

Usage

SIN(alpha2 = 9e-04, beta = 0.06, U = NULL)

Arguments

alpha2

Adouble value for the squared amplitude parameter\alpha^2 (see Note for details).

beta

Adouble value for the angular frequency parameter\beta (see Note for details).

U

Adouble value for the phase parameterU (see Note for details).

Value

An S3 object containing the specified ts.model with the following structure:

process.desc

Used in summary: "ALPHA2","BETA"

theta

Parameter vector including\alpha^2,\beta

plength

Number of parameters

print

String containing simplified model

desc

"SIN"

obj.desc

Depth of Parameters e.g. list(1,1)

starting

Find starting values? TRUE or FALSE (e.g. specified value)

Note

We consider the following sinusoidal process :

X_t = \alpha \sin(\beta t + U)

, whereU \sim \mathcal{U}(0, 2\pi)and\beta \in (0, \frac{\pi}{2})

Author(s)

Lionel Voirol

Examples

SIN()SIN(alpha2 = .5, beta = .05)

Create an White Noise (WN) Process

Description

Sets up the necessary backend for the WN process.

Usage

WN(sigma2 = NULL)

Arguments

sigma2

Adouble value for the variance,\sigma ^2, of a WN process.

Value

An S3 object with called ts.model with the following structure:

process.desc

Used in summary: "WN"

theta

\sigma

plength

Number of Parameters

print

String containing simplified model

desc

y desc replicated x times

obj.desc

Depth of Parameters e.g. list(1)

starting

Guess Starting values? TRUE or FALSE (e.g. specified value)

Note

In this process,Y_t is iid from a zero mean normal distribution with variance\sigma^2

Author(s)

James Balamuta

Examples

WN()WN(sigma2=3.4)

Subset an IMU Object

Description

Enables the IMU object to be subsettable. That is, you can load all the data in and then select certain properties.

Usage

## S3 method for class 'imu'x[i, j, drop = FALSE]

Arguments

x

Aimu object

i

Ainteger vector that specifies the rows to subset. If blank, all rows are selected.

j

Ainteger vector that specifies the columns to subset. Special rules apply see details.

drop

Aboolean indicating whether the structure should be preserved or simplified.

Details

When using the subset operator, note that all the Gyroscopes are placed at the front of object and, then, the Accelerometers are placed.

Value

Animu object class.

Examples

## Not run: if(!require("imudata")){install_imudata()library("imudata")}data(imu6)# Create an IMU Object that is full. ex = imu(imu6, gyros = 1:3, accels = 4:6, axis = c('X', 'Y', 'Z', 'X', 'Y', 'Z'), freq = 100)# Create an IMU object that has only gyros. ex.gyro = ex[,1:3]ex.gyro2 = ex[,c("Gyro. X","Gyro. Y","Gyro. Z")]# Create an IMU object that has only accels. ex.accel = ex[,4:6]ex.accel2 = ex[,c("Accel. X","Accel. Y","Accel. Z")]# Create an IMU object with both gyros and accels on axis X and Yex.b = ex[,c(1,2,4,5)]ex.b2 = ex[,c("Gyro. X","Gyro. Y","Accel. X","Accel. Y")]## End(Not run)

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

Avec containing the coefficients of the AR process

ma

Avec containing the coefficients of the MA process

last_tau

Anint the Jth scale of 2^(1:J)

alpha

Adouble indicating the cutoff.

Value

Avec containing the wavelet variance of the ARMA process.


Bootstrap for Everything!

Description

Using the bootstrap approach, we simulate a model based on user supplied parameters, obtain the wavelet variance, and then V.

Usage

all_bootstrapper(  theta,  desc,  objdesc,  scales,  model_type,  N,  robust,  eff,  alpha,  H)

Arguments

theta

Avector with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

Details

Expand in detail...

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


Randomly guess starting parameters for AR1

Description

Sets starting parameters for each of the given parameters.

Usage

ar1_draw(draw_id, last_phi, sigma2_total, model_type)

Arguments

draw_id

Anunsigned int that contains the draw principles.

last_phi

Adouble containing the last guessed phi value.

sigma2_total

Adouble that contains the sum of all WVs.

model_type

Astring that describes the model transformation.

Value

Avec containing smart parameter starting guesses to be iterated over.


Transform AR1 to GM

Description

Takes AR1 values and transforms them to GM

Usage

ar1_to_gm(theta, freq)

Arguments

theta

Avec that contains AR1 values.

freq

Adouble indicating the frequency of the data.

Details

The function takes a vector of AR1 values\phi and\sigma ^2and transforms them to GM values\beta and\sigma ^2_{gm}using the formulas:\beta = - \frac{{\ln \left( \phi \right)}}{{\Delta t}}\sigma _{gm}^2 = \frac{{{\sigma ^2}}}{{1 - {\phi ^2}}}

Value

Avec containing GM values.

Author(s)

James Balamuta


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

Adouble that is the phi term of the AR(1) process

sigma2

Adouble corresponding to variance of AR(1) process

tau

Avec containing the scales e.g.2^{\tau}

Details

This function is significantly faster than its generalized counter partarma_to_wv.

Value

Avec containing the wavelet variance of the AR(1) process.

Process Haar Wavelet Variance Formula

The Autoregressive Order1 (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}}


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

Adouble corresponding to the autoregressive term.

theta

Adouble corresponding to the moving average term.

sigma2

Adouble the variance of the process.

tau

Avec containing the scales e.g.2^{\tau}

Details

This function is significantly faster than its generalized counter partarma_to_wv

Value

Avec containing the wavelet variance of the ARMA(1,1) process.

Process Haar Wavelet Variance Formula

The Autoregressive Order1 and Moving Average Order1 (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}}


ARMA Adapter to ARMA to WV Process function

Description

Molds the data so that it works with the arma_to_wv function.

Usage

arma_adapter(theta, p, q, tau)

Arguments

theta

Avec that contains all the parameter estimates.

p

Aint that indicates the number of AR coefficients

q

Aint that indicates the number of MA coefficients.

tau

Avec containing the scales e.g.2^{\tau}

Details

The data conversion is more or less a rearrangement of values without using the obj desc.

Value

Avec containing the ARMA to WV results

Author(s)

James Joseph Balamuta (JJB)


Randomly guess starting parameters for ARMA

Description

Sets starting parameters for each of the given parameters.

Usage

arma_draws(p, q, sigma2_total)

Arguments

p

Anunsigned int that contains the amount of AR parameters to generate.

q

Anunsigned int that contains the amount of MA parameters to generate.

sigma2_total

Adouble that contains the sum of all WVs.

Value

Avec containing smart parameter starting guesses to be iterated over.


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

Avec containing the coefficients of the AR process

ma

Avec containing the coefficients of the MA process

sigma2

Adouble containing the residual variance

tau

Avec containing the scales e.g.2^{\tau}

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

Avec containing the wavelet variance of the ARMA process.

Process Haar Wavelet Variance Formula

The Autoregressive Orderp and Moving Average Orderq (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


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

Avec containing the coefficients of the AR process

ma

Avec containing the coefficients of the MA process

sigma2

Adouble containing the residual variance

tau

Avec containing the scales e.g.2^{\tau}

alpha

Adouble indicating the cutoff.

Details

This function provides an approximation to thearma_to_wv as computation timeswere previously a concern. However, this is no longer the case and, thus, this has been leftin for the curious soul to discover...

Value

Avec containing the wavelet variance of the ARMA process.

Process Haar Wavelet Variance Formula

The Autoregressive Orderp and Moving Average Orderq (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


Quarterly Increase in Stocks Non-Farm Total, Australia

Description

A dataset containing the quarterly increase in stocks non-farm total in Australia, with frequency 4 starting from September 1959 to March 1991 with a total of 127 observations.

Usage

australia

Format

A data frame with 127 rows and 2 variables:

Quarter

year and quarter

Increase

quarterly increase in stocks non-farm total

Source

Time Series Data Library (citing: Australian Bureau of Statistics) datamarket


Empirical ACF and PACF

Description

This function can estimate either the autocovariance / autocorrelation for univariate time series,or the partial autocovariance / autocorrelation for univariate time series.

Usage

auto_corr(  x,  lag.max = NULL,  pacf = FALSE,  type = "correlation",  demean = TRUE,  robust = FALSE)

Arguments

x

Avector orts object (of lengthN > 1).

lag.max

Aninteger indicating the maximum lag up to which to compute the empirical ACF / PACF.

pacf

Aboolean indicating whether to output the PACF. If it'sTRUE, then the function will only estimate the empirical PACF. If it'sFALSE (the default),then the function will only estimate the empirical ACF.

type

Acharacter string giving the type of acf to be computed. Allowed values are "correlation" (the default) and "covariance".

demean

Aboolean indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults toTRUE.

robust

Aboolean indicating whether a robust estimator should be used (TRUE) or not (FALSE). Defaults toFALSE.This only works when the function is estimating ACF.

Details

lagmax default is10*log10(N/m) whereN is the number ofobservations andm is the number of time series being compared. Iflagmax supplied is greater than the number of observations N, then oneless than the total will be taken (i.e. N - 1).

Value

Anarray of dimensionsN \times 1 \times 1.

Author(s)

Yuming Zhang

Examples

m = auto_corr(datasets::AirPassengers)m = auto_corr(datasets::AirPassengers, pacf = TRUE)

Find the auto imu result

Description

Provides the core material to create an S3 object for auto.imu

Usage

auto_imu_cpp(  data,  combs,  full_model,  alpha,  compute_v,  model_type,  K,  H,  G,  robust,  eff,  bs_optimism,  seed)

Arguments

data

Amat containing multiple columns of independent data with the same number of observations.

full_model

Avector<string> that contains the largest / full model.

alpha

Adouble that indicates the alpha level for CIs.

compute_v

Astring indicating the type of V matrix to generate

model_type

Astring that describes the model generation / transformation: 'ssm' or 'imu'

K

Aint that controls how many times the GMWM is run.

H

Aint that controls how many bootstraps occur.

G

Aint that controls how many guesses occur.

robust

Abool that indicates whether to use classical or robust wavelet variance.

eff

Adouble that indicates the efficiency to use.

bs_optimism

Abool that indicates whether the model selection score should be calculated with bootstrap or asymptotics.

seed

Aunsigned int that is the seed one wishes to use.

Value

Afield<field<field<mat>>> that contains the model score matrix and the best GMWM model object.


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

Amatrix that contains the same number of observations per dataset

robust

Aboolean that triggers the use of the robust estimate.

eff

Adouble that indicates the efficiency as it relates to an MLE.

alpha

Adouble that indicates the\left(1-p\right)\times \alpha confidence level

ci_type

Astring indicating the confidence interval being calculated. Valid value: "eta3"

strWavelet

Astring indicating the type of wave filter to be applied. Must be "haar"

decomp

Astring indicating whether to use "modwt" or "dwt" decomp

Details

This function processes the decomposition of multiple signals quickly

Value

Afield<mat> with the structure:

"variance"

Wavelet Variance

"low"

Lower CI

"high"

Upper CI


Select the Best Model

Description

This function retrieves the best model from a selection procedure.

Usage

best_model(x, ic = "aic")

Arguments

x

An object of classselect_arma,select_ar orselect_ma.

ic

Astring indicating the type of criterion to use in selecting the best model. Supported criteria include "aic" (AIC), "bic" (BIC) and "hq" (HQ).

Examples

 set.seed(18)xt = gen_arima(N=100, ar=0.3, d=1, ma=0.3)x = select_arima(xt, d=1L)best_model(x, ic = "aic")set.seed(19)xt = gen_ma1(100, 0.3, 1)x = select_ma(xt, q.min=2L, q.max=5L)best_model(x, ic = "bic")set.seed(20)xt = gen_arma(100, c(.3,.5), c(.1), 1, 0)  x = select_arma(xt, p.min = 1L, p.max = 4L,                q.min = 1L, q.max = 3L)best_model(x, ic = "hq")

bl14 filter construction

Description

Creates the bl14 filter

Usage

bl14_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


bl20 filter construction

Description

Creates the bl20 filter

Usage

bl20_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


Generate the Confidence Interval for GOF Bootstrapped

Description

yaya

Usage

boot_pval_gof(obj, obj_boot, B = 1000L, alpha = 0.05)

Arguments

obj

Adouble containing the objective value of the solution.

obj_boot

Avec containing the objective values obtained while bootstrapping under Theta_hat.

B

Anint indicating how many times the bootstrapper should be run.

alpha

Adouble indicating the amount of confidence for CI

Value

Avec that has the alpha/2.0 quantile and then the 1-alpha/2.0 quantile.


Compute the Bootstrapped GoF Test

Description

Handles the bootstrap computation and the bootstrapped p-value.

Usage

bootstrap_gof_test(obj_value, bs_obj_values, alpha, bs_gof_p_ci)

Arguments

obj_value

Adouble that contains the optimized objective function value.

bs_obj_values

Avec that contains the objective function values under bootstrap.

alpha

Adouble that indicates the confidence.

bs_gof_p_ci

Abool that indicates whether CIs should be included or not.

Value

Avec that has


Removal of Boundary Wavelet Coefficients

Description

Removes the first n wavelet coefficients.

Usage

brick_wall(x, wave_filter, method)

Arguments

x

Afield<vec> that contains the nlevel decomposition using either modwt or dwt.

wave_filter

Afield<vec> containing filter information. Only "haar" is implemented.

method

Astring to describe the mode. Choose between "modwt" and "dwt"

Details

The vectors are truncated by removing the first n wavelet coefficients. These vectors are then stored into the field that is returned.Note: As a result, there are no NA's introduced and hence the na.omit is not needed.

Value

Afield<vec> with boundary modwt or dwt taken care of.


Build List of Unique Models

Description

Creates a set containing unique strings.

Usage

build_model_set(combs, x)

Arguments

combs

Amat that is a binary matrix (0,1) containing the combinations of different variables.

x

Avec<string> that contains a list of model descriptors.

Value

Aset<string> that contains the list of unique models.


Calculate the Psi matrix

Description

Computes the Psi matrix using supplied parameters

Usage

calculate_psi_matrix(A, v_hat, omega)

Arguments

A

first derivative matrix

v_hat

bootstrapped V

omega

original omega matrix

Value

Amat that has the first column


Time Series Convolution Filters

Description

Applies a convolution filter to a univariate time series.

Usage

cfilter(x, filter, sides, circular)

Arguments

x

Acolumn vector of length T

filter

Acolumn vector of length f

sides

Anint that takes either 1:for using past values only or 2: filter coefficients are centered around lag 0.

circular

Abool that indicates if the filter should be wrapped around the ends of the time series.

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

Acolumn vec that contains the results of the filtering process.

Author(s)

R Core Team and JJB


Diagnostics on Fitted Time Series Model

Description

This function can perform (simple) diagnostics on the fitted time series model.It can output 6 diagnostic plots to assess the model, including (1) residuals plot,(2) histogram of distribution of standardized residuals, (3) Normal Q-Q plot of residuals,(4) ACF plot, (5) PACF plot, (6) Box test results.

Usage

check(model = NULL, resids = NULL, simple = FALSE)

Arguments

model

Afitsimts,lm orgam object.

resids

Avector of residuals for diagnostics.

simple

Aboolean indicating whether to return simple diagnostic plots or not.

Author(s)

Stéphane Guerrier and Yuming Zhang

Examples

Xt = gen_gts(300, AR(phi = c(0, 0, 0.8), sigma2 = 1))model = estimate(AR(3), Xt)check(model)check(resids = rnorm(100))Xt = gen_gts(1000, SARIMA(ar = c(0.5, -0.25), i = 0, ma = 0.5, sar = -0.8, si = 1, sma = 0.25, s = 24, sigma2 = 1))model = estimate(SARIMA(ar = 2, i = 0, ma = 1, sar = 1, si = 1, sma = 1, s = 24), Xt, method = "rgmwm")check(model)check(model, simple=TRUE)

Generate eta3 confidence interval

Description

Computes the eta3 CI

Usage

ci_eta3(y, dims, alpha_ov_2)

Arguments

y

Avec that computes the brickwalled modwt dot product of each wavelet coefficient divided by their length.

dims

AString indicating the confidence interval being calculated.

alpha_ov_2

Adouble that indicates the\left(1-p\right)*\alpha confidence level

Value

Amatrix with the structure:

Column 1

Wavelet Variance

Column 2

Chi-squared Lower Bounds

Column 3

Chi-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

Avec that computes the brickwalled modwt dot product of each wavelet coefficient divided by their length.

wv_ci_class

Amat that contains the CI mean, CI Lower, and CI Upper

alpha_ov_2

Adouble that indicates the\left(1-p\right)*\alpha confidence level

eff

Adouble that indicates the efficiency.

Details

Within this function we are scaling the classical

Value

Amatrix with the structure:

Column 1

Robust Wavelet Variance

Column 2

Chi-squared Lower Bounds

Column 3

Chi-squared Upper Bounds


Generate a Confidence intervval 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

Afield<vec> that contains the brick walled modwt or dwt decomposition

wv

Avec that contains the wave variance.

type

AString indicating the confidence interval being calculated.

alpha_ov_2

Adouble that indicates the\left(1-p\right)*\alpha confidence level.

robust

Aboolean to determine the type of wave estimation.

eff

Adouble that indicates the efficiency.

Details

This function can be expanded to allow for other confidence interval calculations.

Value

Amatrix with the structure:

Column 1

Wavelet Variance

Column 2

Chi-squared Lower Bounds

Column 3

Chi-squared Upper Bounds


Optim loses NaN

Description

This function takes numbers that are very small and sets them to the minimal tolerance for C++.Doing this prevents NaN from entering the optim routine.

Usage

code_zero(theta)

Arguments

theta

Avec that contains estimated GMWM theta values (untransformed).

Value

Avec that contains safe theta values.


Combine math expressions

Description

Combine math expressions

Usage

comb(...)

Arguments

...

Expressions to combine.

Value

A combined expression.

Author(s)

Stephane Guerrier


Comparison of Classical and Robust Correlation Analysis Functions

Description

Compare classical and robust ACFof univariate time series.

Usage

compare_acf(  x,  lag.max = NULL,  demean = TRUE,  show.ci = TRUE,  alpha = 0.05,  plot = TRUE,  ...)

Arguments

x

Avector or"ts" object (of lengthN > 1).

lag.max

Ainteger indicating the maximum lag up to which to compute the ACF and PACF functions.

demean

Abool indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults toTRUE.

show.ci

Abool indicating whether to compute and show the confidence region. Defaults toTRUE.

alpha

Adouble indicating the level of significance for the confidence interval. By defaultalpha = 0.05 which gives a 1 -alpha = 0.95 confidence interval.

plot

Abool indicating whether a plot of the computed quantities should be produced. Defaults toTRUE.

...

Additional parameters.

Author(s)

Yunxiang Zhang

Examples

# Estimate both the ACF and PACF functionscompare_acf(datasets::AirPassengers)

Computes the (MODWT) wavelet covariance matrix

Description

Calculates the (MODWT) wavelet covariance matrix

Usage

compute_cov_cpp(  signal_modwt,  nb_level,  compute_v = "diag",  robust = TRUE,  eff = 0.6)

Arguments

signal_modwt

Afield<vec> that contains the modwt decomposition.

nb_level

Ainteger that contains the level of decomposition J.

compute_v

Astring that indicates what kind of matrix should be created. Possible options: "diag" or "none"

robust

Aboolean that triggers the use of the robust estimate.

eff

Adouble that indicates the efficiency as it relates to an MLE.

Value

Afield<mat> containing the covariance matrix.


GM Conversion

Description

Convert from AR1 to GM and vice-versa

Usage

conv.ar1.to.gm(theta, process.desc, freq)conv.gm.to.ar1(theta, process.desc, freq)

Arguments

theta

Anumeric vector containing the theta values

process.desc

Acharacter vector containing the names of parameters.

freq

Adouble indicating the frequency of the data.

Author(s)

James Balamuta


Correlation Analysis Functions

Description

Correlation Analysis function computes and plots both empirical ACF and PACFof univariate time series.

Usage

corr_analysis(  x,  lag.max = NULL,  type = "correlation",  demean = TRUE,  show.ci = TRUE,  alpha = 0.05,  plot = TRUE,  ...)

Arguments

x

Avector or"ts" object (of lengthN > 1).

lag.max

Ainteger indicating the maximum lag up to which to compute the ACF and PACF functions.

type

Acharacter string giving the type of acf to be computed. Allowed values are "correlation" (the default) and "covariance".

demean

Abool indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults toTRUE.

show.ci

Abool indicating whether to compute and show the confidence region. Defaults toTRUE.

alpha

Adouble indicating the level of significance for the confidence interval. By defaultalpha = 0.05 which gives a 1 -alpha = 0.95 confidence interval.

plot

Abool indicating whether a plot of the computed quantities should be produced. Defaults toTRUE.

...

Additional parameters.

Value

Twoarray objects (ACF and PACF) of dimensionN \times S \times S.

Author(s)

Yunxiang Zhang

Examples

# Estimate both the ACF and PACF functionscorr_analysis(datasets::AirPassengers)

Count Models

Description

Count the amount of models that exist.

Usage

count_models(desc)

Arguments

desc

Avector<string> that contains the model's components.

Value

Amap<string, int> containing how frequent the model component appears.


Bootstrap for Matrix V

Description

Using the bootstrap approach, we simulate a model based on user supplied parameters, obtain the wavelet variance, and then V.

Usage

cov_bootstrapper(theta, desc, objdesc, N, robust, eff, H, diagonal_matrix)

Arguments

theta

Avector with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

Details

Expand in detail...

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


Internal IMU Object Construction

Description

Internal quick build for imu object.

Usage

create_imu(  data,  ngyros,  nacces,  axis,  freq,  unit = NULL,  name = NULL,  stype = NULL)

Arguments

data

Amatrix with dimensions N x length(index)

ngyros

Aninteger containing the number of gyroscopes

nacces

Aninteger containing the number of accelerometers

axis

Avector unique representation of elements e.g. x,y,z or x,y or x.

freq

Aninteger that provides the frequency for the data.

unit

Astring that contains the unit expression of the frequency. Default value isNULL.

name

Astring that provides an identifier to the data. Default value isNULL.

stype

Astring that describes the sensor type. Default value isNULL.

Value

Animu object class.

Author(s)

James Balamuta


Custom legend function

Description

Legend placement function

Usage

custom_legend(x, usr = par("usr"), ...)

d16 filter construction

Description

Creates the d16 filter

Usage

d16_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


d4 filter construction

Description

Creates the d4 filter

Usage

d4_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


d6 filter construction

Description

Creates the d6 filter

Usage

d6_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


d8 filter construction

Description

Creates the d8 filter

Usage

d8_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


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

Avec containing the list of estimated parameters.

desc

Avector<string> containing a list of descriptors.

objdesc

Afield<vec> containing a list of object descriptors.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amat 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

Amat with scales as rows and processes as columns

Value

Avec containing the wavelet variance of the process for the overall model


Analytic second derivative matrix for AR(1) process

Description

Calculates the second derivative for the AR(1) process and places it into a matrix form.The matrix form in this case is for convenience of the calculation.

Usage

deriv_2nd_ar1(phi, sigma2, tau)

Arguments

phi

Adouble corresponding to the phi coefficient of an AR(1) process.

sigma2

Adouble corresponding to the error term of an AR(1) process.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing thesecond partial derivative with respect to\phi andthe second column contains the second partial derivative with respect to\sigma ^2

Process Haar WV Second Derivative

Taking the second derivative with respect to\phi yields:

\frac{{{\partial ^2}}}{{\partial {\phi ^2}}}\nu _j^2\left( \phi, \sigma ^2 \right) = \frac{2 \sigma ^2 \left(\left(\phi ^2-1\right) \tau _j \left(2 (\phi (7 \phi +4)+1) \phi ^{\frac{\tau _j}{2}-1}-(\phi (7 \phi +4)+1) \phi ^{\tau _j-1}+3 (\phi +1)^2\right)+\left(\phi ^2-1\right)^2 \tau _j^2 \left(\phi ^{\frac{\tau _j}{2}}-1\right) \phi ^{\frac{\tau _j}{2}-1}+4 (3 \phi +1) \left(\phi ^2+\phi +1\right) \left(\phi ^{\tau _j}-4 \phi ^{\frac{\tau _j}{2}}+3\right)\right)}{(\phi -1)^5 (\phi +1)^3 \tau _j^2}

Taking the second derivative with respect to\sigma^2 yields:

\frac{{{\partial ^2}}}{{\partial {\sigma ^4}}}\nu _j^2\left( \sigma ^2 \right) = 0

Taking the derivative with respect to\phi and\sigma ^2 yields:

\frac{{{\partial ^2}}}{{\partial {\phi } \partial {\sigma ^2}}}\nu _j^2\left( \phi, \sigma ^2 \right) = \frac{2 \left(\left(\phi ^2-1\right) \tau _j \left(\phi ^{\tau _j}-2 \phi ^{\frac{\tau _j}{2}}-\phi -1\right)-(\phi (3 \phi +2)+1) \left(\phi ^{\tau _j}-4 \phi ^{\frac{\tau _j}{2}}+3\right)\right)}{(\phi -1)^4 (\phi +1)^2 \tau _j^2}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix for ARMA(1,1) process

Description

Obtain the second derivative of the ARMA(1,1) process.

Usage

deriv_2nd_arma11(phi, theta, sigma2, tau)

Arguments

phi

Adouble corresponding to the phi coefficient of an ARMA(1,1) process.

theta

Adouble corresponding to the theta coefficient of an ARMA(1,1) process.

sigma2

Adouble corresponding to the error term of an ARMA(1,1) process.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with:

Process Haar WV Second Derivative

Taking the second derivative with respect to\phi yields:

\frac{{{\partial ^2}}}{{\partial {\phi ^2}}}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{{2{\sigma ^2}}}{{{{(\phi - 1)}^5}{{(\phi + 1)}^3}\tau _j^2}}\left( \begin{array}{cc}&{(\phi - 1)^2}\left( {{{(\phi + 1)}^2}\left( {{\theta ^2}\phi + \theta {\phi ^2} + \theta + \phi } \right)\tau _j^2\left( {{\phi ^{\frac{{{\tau _j}}}{2}}} - 1} \right){\phi ^{\frac{{{\tau _j}}}{2} - 2}} + \left( {{\phi ^2} - 1} \right)\left( {{\theta ^2}( - \phi ) + \theta \left( {{\phi ^2} + 4\phi + 1} \right) - \phi } \right){\tau _j}\left( {{\phi ^{\frac{{{\tau _j}}}{2}}} - 2} \right){\phi ^{\frac{{{\tau _j}}}{2} - 2}} - 2{{(\theta - 1)}^2}\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right)} \right) \\&- 12{(\phi + 1)^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) \\&+ 6(\phi + 1)(\phi - 1)\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) + (\phi + 1)\left( { - (\theta + \phi )(\theta \phi + 1){\tau _j}\left( {{\phi ^{\frac{{{\tau _j}}}{2}}} - 2} \right){\phi ^{\frac{{{\tau _j}}}{2} - 1}} - \theta (\theta + \phi )\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right) - (\theta \phi + 1)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right) - {{(\theta + 1)}^2}\phi {\tau _j}} \right)} \right) \\ \end{array} \right)

Taking the second derivative with respect to\theta yields:

\frac{{{\partial ^2}}}{{\partial {\theta ^2}}}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{{2{\sigma ^2}\left( {\left( {{\phi ^2} - 1} \right){\tau _j} + 2\phi \left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right)} \right)}}{{{{(\phi - 1)}^3}(\phi + 1)\tau _j^2}}

Taking the second derivative with respect to\sigma ^2 yields:

\frac{{{\partial ^2}}}{{\partial {\sigma ^4}}}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = 0

Taking the derivative with respect to\sigma^2 and\theta yields:

\frac{\partial }{{\partial \theta }}\frac{\partial }{{\partial {\sigma ^2}}}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{2}{{{{(\phi - 1)}^3}(\phi + 1)\tau _j^2}}\left( {(\theta + 1)\left( {{\phi ^2} - 1} \right){\tau _j} + \left( {2\theta \phi + {\phi ^2} + 1} \right)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right)} \right)

Taking the derivative with respect to\sigma^2 and\phi yields:

\frac{\partial }{{\partial \phi }}\frac{\partial }{{\partial {\sigma ^2}}}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{2}{{{{(\phi - 1)}^4}{{(\phi + 1)}^2}\tau _j^2}}\left( \begin{array}{ll}&- (\phi - 1)(\phi + 1)\left( \begin{array}{ll} &- (\theta + \phi )(\theta \phi + 1){\tau _j}\left( {{\phi ^{\frac{{{\tau _j}}}{2}}} - 2} \right){\phi ^{\frac{{{\tau _j}}}{2} - 1}} \\ &- \theta (\theta + \phi )\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right) \\ &- (\theta \phi + 1)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right) \\ &- {(\theta + 1)^2}\phi {\tau _j} \\ \end{array} \right) \\&+ (\phi - 1)\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) \\&+ 3(\phi + 1)\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) \\ \end{array} \right)

Taking the derivative with respect to\phi and\theta yields:

\frac{\partial }{{\partial \theta }}\frac{\partial }{{\partial \phi }}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = - \frac{{2{\sigma ^2}}}{{{{(\phi - 1)}^4}{{(\phi + 1)}^2}\tau _j^2}}\left( \begin{array}{cc}&{\tau _j}\left( \begin{array}{cc} &2(\theta + 1)(\phi - 1){(\phi + 1)^2} \\ &+ 2\left( {{\phi ^2} - 1} \right)\left( {2\theta \phi + {\phi ^2} + 1} \right){\phi ^{\frac{{{\tau _j}}}{2} - 1}} \\ &- \left( {{\phi ^2} - 1} \right)\left( {2\theta \phi + {\phi ^2} + 1} \right){\phi ^{{\tau _j} - 1}} \\ \end{array} \right) \\&+ 2\left( {\theta (\phi (3\phi + 2) + 1) + \phi \left( {{\phi ^2} + \phi + 3} \right) + 1} \right)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right) \\ \end{array} \right)

Author(s)

James Joseph Balamuta (JJB)


Analytic second derivative matrix for drift process

Description

To ease a later calculation, we place the result into a matrix structure.

Usage

deriv_2nd_dr(tau)

Arguments

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the second partial derivative with respect to\omega.

Author(s)

James Joseph Balamuta (JJB)


Analytic second derivative for MA(1) process

Description

To ease a later calculation, we place the result into a matrix structure.

Usage

deriv_2nd_ma1(theta, sigma2, tau)

Arguments

theta

Adouble corresponding to the theta coefficient of an MA(1) process.

sigma2

Adouble corresponding to the error term of an MA(1) process.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the second partial derivative with respect to\theta,the second column contains the partial derivative with respect to\theta and\sigma ^2,and lastly we have the second partial derivative with respect to\sigma ^2.

Process Haar WV Second Derivative

Taking the second derivative with respect to\theta yields:

\frac{{{\partial ^2}}}{{\partial {\theta ^2}}}\nu _j^2\left( {\theta ,{\sigma ^2}} \right) = \frac{{2{\sigma ^2}}}{{{\tau _j}}}

Taking the second derivative with respect to\sigma^2 yields:

\frac{{{\partial ^2}}}{{\partial {\sigma ^4}}}\nu _j^2\left( {\theta ,{\sigma ^2}} \right) = 0

Taking the first derivative with respect to\theta and\sigma^2 yields:

\frac{\partial }{{\partial \theta }}\frac{\partial }{{\partial {\sigma ^2}}}\nu _j^2\left( {\theta ,{\sigma ^2}} \right) = \frac{{2(\theta + 1){\tau _j} - 6}}{{\tau _j^2}}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix for AR(1) process

Description

Obtain the first derivative of the AR(1) process.

Usage

deriv_ar1(phi, sigma2, tau)

Arguments

phi

Adouble corresponding to the phi coefficient of an AR(1) process.

sigma2

Adouble corresponding to the error term of an AR(1) process.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the partial derivative with respect to\phi and the second column contains the partial derivative with respect to\sigma ^2

Process Haar WV First Derivative

Taking the derivative with respect to\phi yields:

\frac{\partial }{{\partial \phi }}\nu _j^2\left( {\phi ,{\sigma ^2}} \right) = \frac{{2{\sigma ^2}\left( {\left( {{\phi ^2} - 1} \right){\tau _j}\left( { - 2{\phi ^{\frac{{{\tau _j}}}{2}}} + {\phi ^{{\tau _j}}} - \phi - 1} \right) - \left( {\phi \left( {3\phi + 2} \right) + 1} \right)\left( { - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + {\phi ^{{\tau _j}}} + 3} \right)} \right)}}{{{{\left( {\phi - 1} \right)}^4}{{\left( {\phi + 1} \right)}^2}\tau _j^2}}

Taking the derivative with respect to\sigma ^2 yields:

\frac{\partial }{{\partial {\sigma ^2}}}\nu _j^2\left( {\phi ,{\sigma ^2}} \right) = \frac{{\left( {{\phi ^2} - 1} \right){\tau _j} + 2\phi \left( { - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + {\phi ^{{\tau _j}}} + 3} \right)}}{{{{\left( {\phi - 1} \right)}^3}\left( {\phi + 1} \right)\tau _j^2}}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix for ARMA(1,1) process

Description

Obtain the first derivative of the ARMA(1,1) process.

Usage

deriv_arma11(phi, theta, sigma2, tau)

Arguments

phi

Adouble corresponding to the phi coefficient of an ARMA(1,1) process.

theta

Adouble corresponding to the theta coefficient of an ARMA(1,1) process.

sigma2

Adouble corresponding to the error term of an ARMA(1,1) process.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with:

Process Haar WV First Derivative

Taking the derivative with respect to\phi yields:

\frac{\partial }{{\partial \phi }}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{{2{\sigma ^2}}}{{{{(\phi - 1)}^4}{{(\phi + 1)}^2}\tau _j^2}}\left( \begin{array}{cc}&{\tau _j}\left( { - {{(\theta + 1)}^2}(\phi - 1){{(\phi + 1)}^2} - 2\left( {{\phi ^2} - 1} \right)(\theta + \phi )(\theta \phi + 1){\phi ^{\frac{{{\tau _j}}}{2} - 1}} + \left( {{\phi ^2} - 1} \right)(\theta \phi + 1)(\theta + \phi ){\phi ^{{\tau _j} - 1}}} \right) \\&- \left( {{\theta ^2}((3\phi + 2)\phi + 1) + 2\theta \left( {\left( {{\phi ^2} + \phi + 3} \right)\phi + 1} \right) + (3\phi + 2)\phi + 1} \right)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right) \\ \end{array} \right)

Taking the derivative with respect to\theta yields:

\frac{\partial }{{\partial \theta }}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{{2{\sigma ^2}\left( {(\theta + 1)\left( {{\phi ^2} - 1} \right){\tau _j} + \left( {2\theta \phi + {\phi ^2} + 1} \right)\left( {{\phi ^{{\tau _j}}} - 4{\phi ^{\frac{{{\tau _j}}}{2}}} + 3} \right)} \right)}}{{{{(\phi - 1)}^3}(\phi + 1)\tau _j^2}}

Taking the derivative with respect to\sigma^2 yields:

\frac{\partial }{{\partial \sigma ^2 }}\nu _j^2\left( {\phi ,\theta ,{\sigma ^2}} \right) = \frac{2 \sigma ^2 \left(\left(\phi ^2-1\right) \tau _j+2 \phi \left(\phi ^{\tau _j}-4 \phi ^{\frac{\tau _j}{2}}+3\right)\right)}{(\phi -1)^3 (\phi +1) \tau _j^2}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix for Drift (DR) Process

Description

Obtain the first derivative of the Drift (DR) process.

Usage

deriv_dr(omega, tau)

Arguments

omega

Adouble that is the slope of the drift.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the partial derivative with respect to\omega.

Process Haar WV First Derivative

Taking the derivative with respect to\omega yields:

\frac{\partial }{{\partial \omega }}\nu _j^2\left( \omega \right) = \frac{{\tau _j^2\omega }}{8}

Note: We are taking the derivative with respect to\omega and not\omega^2 as the\omegarelates to the slope of the process and not the processes variance like RW and WN. As a result, a second derivative exists and is not zero.

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix for MA(1) process

Description

Obtain the first derivative of the MA(1) process.

Usage

deriv_ma1(theta, sigma2, tau)

Arguments

theta

Adouble corresponding to the theta coefficient of an MA(1) process.

sigma2

Adouble corresponding to the error term of an MA(1) process.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the partial derivative with respect to\thetaand the second column contains the partial derivative with respect to\sigma ^2

Process Haar WV First Derivative

Taking the derivative with respect to\theta yields:

\frac{\partial }{{\partial \theta }}\nu _j^2\left( {\theta ,{\sigma ^2}} \right) = \frac{{{\sigma ^2}\left( {2\left( {\theta + 1} \right){\tau _j} - 6} \right)}}{{\tau _j^2}}

Taking the derivative with respect to\sigma^2 yields:

\frac{\partial }{{\partial {\sigma ^2}}}\nu _j^2\left( {\theta ,{\sigma ^2}} \right) = \frac{{{{\left( {\theta + 1} \right)}^2}{\tau _j} - 6\theta }}{{\tau _j^2}}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix for Quantization Noise (QN) Process

Description

Obtain the first derivative of the Quantization Noise (QN) process.

Usage

deriv_qn(tau)

Arguments

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the partial derivative with respect toQ^2.

Process Haar WV First Derivative

Taking the derivative with respect toQ^2 yields:

\frac{\partial }{{\partial {Q^2}}}\nu _j^2\left( {{Q^2}} \right) = \frac{6}{{\tau _j^2}}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix Random Walk (RW) Process

Description

Obtain the first derivative of the Random Walk (RW) process.

Usage

deriv_rw(tau)

Arguments

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containingthe partial derivative with respect to\gamma^2.

Process Haar WV First Derivative

Taking the derivative with respect to\gamma ^2 yields:

\frac{\partial }{{\partial {\gamma ^2}}}\nu _j^2\left( {{\gamma ^2}} \right) = \frac{{\tau _j^2 + 2}}{{12{\tau _j}}}

Author(s)

James Joseph Balamuta (JJB)


Analytic D Matrix for a Gaussian White Noise (WN) Process

Description

Obtain the first derivative of the Gaussian White Noise (WN) process.

Usage

deriv_wn(tau)

Arguments

tau

Avec containing the scales e.g.2^{\tau}

Value

Amatrix with the first column containing the partial derivative with respect to\sigma^2.

Process Haar WV First Derivative

Taking the derivative with respect to\sigma^2 yields:

\frac{\partial }{{\partial {\sigma ^2}}}\nu _j^2\left( {{\sigma ^2}} \right) = \frac{1}{{{\tau _j}}}

Author(s)

James Joseph Balamuta (JJB)


Analytic D matrix of Processes

Description

This function computes each process to WV (haar) in a given model.

Usage

derivative_first_matrix(theta, desc, objdesc, tau)

Arguments

theta

Avec containing the list of estimated parameters.

desc

Avector<string> containing a list of descriptors.

objdesc

Afield<vec> containing a list of object descriptors.

tau

Avec containing the scales e.g.2^{\tau}

Details

Function returns the matrix effectively known as "D"

Value

Amatrix with the process derivatives going down the column

Author(s)

James Joseph Balamuta (JJB)


Create a ts.model from desc string

Description

Sets up the necessary backend for using Cpp functions to build R ts.model objects

Usage

desc.to.ts.model(desc)

Arguments

desc

Acharacter vector containing:"AR1","DR","WN","RW","QN"

Value

An S3 object with called ts.model with the following structure:

Author(s)

James Balamuta

Examples

desc.to.ts.model(c("AR1","WN"))

Discrete Fourier Transformation for Autocovariance Function

Description

Calculates the autovariance function (ACF) using Discrete Fourier Transformation.

Usage

dft_acf(x)

Arguments

x

Acx_vec.

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

Avec containing the ACF.


Box-Pierce

Description

Performs the Box-Pierce test to assess the Null Hypothesis of Independencein a Time Series

Usage

diag_boxpierce(x, order = NULL, stop_lag = 20, stdres = FALSE, plot = TRUE)

Arguments

x

Anarima or data set.

order

Aninteger indicating the degrees of freedom. If 'x' isnot a series of residuals, then set equal to 0.

stop_lag

Aninteger indicating the length of lags that shouldbe calculated.

stdres

Aboolean indicating whether to standardize theresidualizes (e.g.res/sd(res)) or not.

plot

A logical. IfTRUE (the default) a plot should be produced.

Author(s)

James Balamuta, Stéphane Guerrier, Yuming Zhang


Ljung-Box

Description

Performs the Ljung-Box test to assess the Null Hypothesis of Independencein a Time Series

Usage

diag_ljungbox(x, order = NULL, stop_lag = 20, stdres = FALSE, plot = TRUE)

Arguments

x

Anarima or data set.

order

Aninteger indicating the degrees of freedom. If 'x' isnot a series of residuals, then set equal to 0.

stop_lag

Aninteger indicating the length of lags that shouldbe calculated.

stdres

Aboolean indicating whether to standardize theresidualizes (e.g.res/sd(res)) or not.

plot

A logical. IfTRUE (the default) a plot should be produced.

Author(s)

James Balamuta, Stéphane Guerrier, Yuming Zhang


Diagnostic Plot of Residuals

Description

This function will plot 8 diagnostic plots to assess the model used to fit the data. These include: (1) residuals plot, (2) residuals vs fitted values, (3) histogram of distribution of standardized residuals, (4) Normal Q-Q plot of residuals, (5) ACF plot, (6) PACF plot, (7) Haar Wavelet Variance Representation,(8) Box test results.

Usage

diag_plot(Xt = NULL, model = NULL, resids = NULL, std = FALSE)

Arguments

Xt

The data used to construct said model.

model

Afitsimts,lm orgam object.

resids

Avector of residuals for diagnostics.

std

Aboolean indicating whether we use standardized residuals for (1) residuals plot and (8) Box test results.

Author(s)

Yuming Zhang


Portmanteau Tests

Description

Performs the Portmanteau test to assess the Null Hypothesis of Independencein a Time Series

Usage

diag_portmanteau_(  x,  order = NULL,  stop_lag = 20,  stdres = FALSE,  test = "Ljung-Box",  plot = TRUE)

Arguments

x

Anarima or data set.

order

Aninteger indicating the degrees of freedom. If 'x' isnot a series of residuals, then set equal to 0.

stop_lag

Aninteger indicating the length of lags that shouldbe calculated.

stdres

Aboolean indicating whether to standardize theresidualizes (e.g.res/sd(res)) or not.

test

Astring indicating whether to perform Ljung-Box test or Box-Pierce test.

plot

A logical. IfTRUE (the default) a plot should be produced.

Author(s)

James Balamuta, Stéphane Guerrier, Yuming Zhang


Lagged Differences in Armadillo

Description

Returns the ith difference of a time series of rth lag.

Usage

diff_cpp(x, lag, differences)

Arguments

x

Avec that is the time series

lag

Aunsigned int that indicates the lag

differences

Adif that indicates how many differences should be taken

Value

Avector containing the differenced time series.

Author(s)

JJB


Root Finding C++

Description

Used to interface with Armadillo

Usage

do_polyroot_arma(z)

Arguments

z

Acx_vec (complex vector) that has 1 in the beginning (e.g. c(1,3i,-3i))


Root Finding C++

Description

Vroom Vroom

Usage

do_polyroot_cpp(z)

Arguments

z

Avec<complex<double> (complex vector) that has 1 in the beginning (e.g. c(1,3i,-3i))


Drift to WV

Description

This function compute the WV (haar) of a Drift process

Usage

dr_to_wv(omega, tau)

Arguments

omega

Adouble corresponding to the slope of the drift

tau

Avec containing the scales e.g.2^{\tau}

Value

Avec 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_cpp(x, filter_name, nlevels, boundary, brickwall)

Arguments

x

Avector with dimensionsN\times 1.

filter_name

Astring indicating the filter.

nlevels

Aninteger,J, indicating the level of the decomposition.

boundary

Astring indicating the type of boundary method to use. Eitherboundary="periodic" or"reflection".

brickwall

Abool indicating whether the a brick wall procedure should be applied to the coefficients.

Details

Performs a level J decomposition of the time series using the pyramid algorithm

Value

y Afield<vec> that contains the wavelet coefficients for each decomposition level

Author(s)

JJB


Expected value DR

Description

This function computes the expected value of a drift process.

Usage

e_drift(omega, n_ts)

Arguments

omega

Adouble corresponding to variance of drift.

n_ts

Anint indicating the length of the time series.

Value

Avec containing the expected value of the drift.


Fit a Time Series Model to Data

Description

This function can fit a time series model to data using different methods.

Usage

estimate(model, Xt, method = "mle", demean = TRUE)

Arguments

model

A time series model.

Xt

Avector of time series data.

method

Astring indicating the method used for model fitting. Supported methods includemle,yule-walker,gmwm andrgmwm.

demean

Aboolean indicating whether the model includes a mean / intercept term or not.

Author(s)

Stéphane Guerrier and Yuming Zhang

Examples

Xt = gen_gts(300, AR(phi = c(0, 0, 0.8), sigma2 = 1))plot(Xt)estimate(AR(3), Xt)Xt = gen_gts(300, MA(theta = 0.5, sigma2 = 1))plot(Xt)estimate(MA(1), Xt, method = "gmwm")Xt = gen_gts(300, ARMA(ar = c(0.8, -0.5), ma = 0.5, sigma2 = 1))plot(Xt)estimate(ARMA(2,1), Xt, method = "rgmwm")Xt = gen_gts(300, ARIMA(ar = c(0.8, -0.5), i = 1, ma = 0.5, sigma2 = 1))plot(Xt)estimate(ARIMA(2,1,1), Xt, method = "mle")Xt = gen_gts(1000, SARIMA(ar = c(0.5, -0.25), i = 0, ma = 0.5, sar = -0.8, si = 1, sma = 0.25, s = 24, sigma2 = 1))plot(Xt)estimate(SARIMA(ar = 2, i = 0, ma = 1, sar = 1, si = 1, sma = 1, s = 24), Xt, method = "rgmwm")

Evalute a time series or a list of time series models

Description

This function calculates AIC, BIC and HQ or the MAPE for a list of time seriesmodels. This function currently only supports models estimated by the MLE.

Usage

evaluate(  models,  Xt,  criterion = "IC",  start = 0.8,  demean = TRUE,  print = TRUE)

Arguments

models

A time series model or a list of time series models.

Xt

A time series (i.e gts object).

criterion

Either "IC" for AIC, BIC and HQ or "MAPE" for MAPE.

start

Anumeric indicating the starting proportion of the data that is used for prediction (assuming criterion = "MAPE").

demean

Aboolean indicating whether the model includes a mean / intercept term or not.

print

logical. IfTRUE (the default) results are printed.

Value

AIC, BIC and HQ or MAPE

Author(s)

Stéphane Guerrier

Examples

set.seed(18)n = 300Xt = gen_gts(n, AR(phi = c(0, 0, 0.8), sigma2 = 1))evaluate(AR(1), Xt)evaluate(list(AR(1), AR(3), MA(3), ARMA(1,2), SARIMA(ar = 1, i = 0, ma = 1, sar = 1, si = 1, sma = 1, s = 12)), Xt)evaluate(list(AR(1), AR(3)), Xt, criterion = "MAPE")

Computes the (MODWT) wavelet covariance matrix using Chi-square confidence interval bounds

Description

Calculates the (MODWT) wavelet covariance matrix using Chi-square confidence interval bounds

Usage

fast_cov_cpp(ci_hi, ci_lo)

Arguments

ci_hi

Avec that contains the upper confidence interval points.

ci_lo

Avec that contains the lower confidence interval points.

Value

A diagonal matrix.


Transform an Armadillo field<vec> to a matrix

Description

Unlists vectors in a field and places them into a matrix

Usage

field_to_matrix(x)

Arguments

x

Afield<vec>.

Value

Amat containing the field elements within a column.

Author(s)

JJB


Find the Common Denominator of the Models

Description

Determines the common denominator among models

Usage

find_full_model(x)

Arguments

x

Avector< vector<string> > that contains all possible models under consideration

Value

Avector<string> that contains the terms of the common denominator of all models


fk14 filter construction

Description

Creates the fk14 filter

Usage

fk14_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


fk22 filter construction

Description

Creates the fk22 filter

Usage

fk22_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


fk4 filter construction

Description

Creates the fk4 filter

Usage

fk4_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


fk6 filter construction

Description

Creates the fk6 filter

Usage

fk6_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


fk8 filter construction

Description

Creates the fk8 filter

Usage

fk8_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


Format the Confidence Interval for Estimates

Description

Creates hi and lo confidence based on SE and alpha.

Usage

format_ci(theta, se, alpha)

Arguments

theta

Avec containing the estimates

se

Avec containing the standard error

alpha

Adouble that contains the confidence level.

Value

Amat that has:


Generate an Autoregressive Order 1 ( AR(1) ) sequence

Description

Generate an Autoregressive Order 1 sequence given\phi and\sigma^2.

Usage

gen_ar1(N, phi = 0.3, sigma2 = 1)

Arguments

N

Anunsigned integer for signal length.

phi

Adouble that contains autocorrection.

sigma2

Adouble that contains process variance.

Details

The function implements a way to generate the AR(1)'sx_t valueswithout calling the general ARMA function.Thus, the function is able to generate values much faster thangen_arma.

Value

Avec containing the AR(1) process.

Process Definition

The Autoregressive order 1 (AR1) process with non-zero parameter\phi \in (-1,+1) and\sigma^2 \in {\rm I\!R}^{2}.This process is defined as:

{X_t} = {\phi _1}{X_{t - 1}} + {\varepsilon_t}

,where

{\varepsilon_t}\mathop \sim \limits^{iid} N\left( {0,\sigma^2} \right)

AR(1) processes are sometimes used as an approximation for Bias Instability noises.

Generation Algorithm

The function first generates a vector of White Noise with lengthN+1 usinggen_wn and then obtains theautoregressive values under the above process definition.

TheX_0 (first value ofX_t) is discarded.


Generate AR(1) Block Process

Description

This function allows us to generate a non-stationary AR(1) block process.

Usage

gen_ar1blocks(phi, sigma2, n_total, n_block, scale = 10, title = NULL, seed = 135, ...)

Arguments

phi

Adouble value for the autocorrection parameter\phi.

sigma2

Adouble value for the variance parameter\sigma ^2.

n_total

Aninteger indicating the length of the simulated AR(1) block process.

n_block

Aninteger indicating the length of each block of the AR(1) block process.

scale

Aninteger indicating the number of levels of decomposition. The default value is 10.

title

Astring indicating the name of the time series data.

seed

Aninteger defined for simulation replication purposes.

...

Additional parameters.

Value

Avector containing the AR(1) block process.

Note

This function generates a non-stationary AR(1) block process whose theoretical maximum overlapping allan variance (MOAV) is different from the theoretical MOAV of a stationary AR(1) process. This difference in the value of the allan variance between stationary and non-stationary processes has been shown through the calculation of the theoretical allan variance given in "A Study of the Allan Variance for Constant-Mean Non-Stationary Processes" by Xu et al. (IEEE Signal Processing Letters, 2017), preprint available:https://arxiv.org/abs/1702.07795.

Author(s)

Yuming Zhang and Haotian Xu

Examples

Xt = gen_ar1blocks(phi = 0.9, sigma2 = 1, n_total = 1000, n_block = 10, scale = 100)plot(Xt)Yt = gen_ar1blocks(phi = 0.5, sigma2 = 5, n_total = 800, n_block = 20, scale = 50)plot(Yt)

Generate Autoregressive Order p, Integrated d, Moving Average Order q (ARIMA(p,d,q)) Model

Description

Generate an ARIMA(p,d,q) process with supplied vector of Autoregressive Coefficients (\phi), Integratedd, Moving Average Coefficients (\theta), and\sigma^2.

Usage

gen_arima(N, ar, d, ma, sigma2 = 1.5, n_start = 0L)

Arguments

N

Aninteger for signal length.

ar

Avec that contains the AR coefficients.

d

Aninteger that indicates a difference.

ma

Avec that contains the MA coefficients.

sigma2

Adouble that contains process variance.

n_start

Anunsigned int that indicates the amount of observations to be used for the burn in period.

Details

The innovations are generated from a normal distribution.The\sigma^2 parameter is indeed a variance parameter. This differs from R's use of the standard deviation,\sigma.

Value

Avec that contains the generated observations.

Warning

Please note, this function will generate a sum ofN + d number of observations,whered denotes the number of differences necessary.


Generate Autoregressive Orderp - Moving Average Orderq (ARMA(p,q)) Model

Description

Generate an ARMA(p,q) process with supplied vector of Autoregressive Coefficients (\phi), Moving Average Coefficients (\theta), and\sigma^2.

Usage

gen_arma(N, ar, ma, sigma2 = 1.5, n_start = 0L)

Arguments

N

Aninteger for signal length.

ar

Avec that contains the AR coefficients.

ma

Avec that contains the MA coefficients.

sigma2

Adouble that contains process variance.

n_start

Anunsigned int that indicates the amount of observations to be used for the burn in period.

Details

ForAR(1),MA(1), andARMA(1,1) please use their functions if speed is importantas this function is designed to generate generic ARMA processes.

Value

Avec that contains the generated observations.

Process Definition

The Autoregressive orderp and Moving Average orderq (ARMA(p,q)) process with non-zero parameters\phi_i \in (-1,+1) for the AR components,\theta_j \in (-1,+1) for the MA components, and\sigma^2 \in {\rm I\!R}^{+}.This process is defined as:

{X_t} = \sum\limits_{i = 1}^p {{\phi _i}{X_{t - i}}} + \sum\limits_{i = 1}^q {{\theta _i}{\varepsilon _{t - i}}} + {\varepsilon _t}

where

{\varepsilon_t}\mathop \sim \limits^{iid} N\left( {0,\sigma^2} \right)

Generation Algorithm

The innovations are generated from a normal distribution.The\sigma^2 parameter is indeed a variance parameter. This differs from R's use of the standard deviation,\sigma.


Generate an ARMA(1,1) sequence

Description

Generate an ARMA(1,1) sequence given\phi,\theta, and\sigma^2.

Usage

gen_arma11(N, phi = 0.1, theta = 0.3, sigma2 = 1)

Arguments

N

Aninteger for signal length.

phi

Adouble that contains autoregressive.

theta

Adouble that contains moving average.

sigma2

Adouble that contains process variance.

Details

The function implements a way to generate thex_t values without calling the general ARMA function.

Value

Avec containing the MA(1) process.

Process Definition

The Autoregressive order 1 and Moving Average order 1 (ARMA(1,1)) process with non-zero parameters\phi \in (-1,+1) for the AR component,\theta \in (-1,+1) for the MA component, and\sigma^2 \in {\rm I\!R}^{+}.This process is defined as:

{X_t} = {\phi _1}{X_{t - 1}} + {\theta _1}{\varepsilon_{t - 1}} + {\varepsilon_t}

,where

{\varepsilon_t}\mathop \sim \limits^{iid} N\left( {0,\sigma^2} \right)

Generation Algorithm

The function first generates a vector of white noise usinggen_wn and then obtains theARMA values under the above equation.

TheX_0 (first value ofX_t) is discarded.


Generate Bias-Instability Process

Description

This function allows to generate a non-stationary bias-instability process.

Usage

gen_bi(sigma2, n_total, n_block, title = NULL, seed = 135, ...)

Arguments

sigma2

Adouble value for the variance parameter\sigma ^2.

n_total

Aninteger indicating the length of the simulated bias-instability process.

n_block

Aninteger indicating the length of each block of the bias-instability process.

title

Astring defining the name of the time series data.

seed

Aninteger defined for simulation replication purposes.

...

Additional parameters.

Value

Avector containing the bias-instability process.

Note

This function generates a non-stationary bias-instability processwhose theoretical maximum overlapping allan variance (MOAV) is close to the theoreticalMOAV of the best approximation of this process through a stationary AR(1) process over some scales. However, this approximation is not good enough when considering the logarithmic representation of the allan variance.Therefore, the exact form of the allan variance of this non-stationary process allows us to better interpret the signals characterized by bias-instability, as shown in "A Study of the Allan Variance for Constant-Mean Non-Stationary Processes" by Xu et al. (IEEE Signal Processing Letters, 2017), preprint available:https://arxiv.org/abs/1702.07795.

Author(s)

Yuming Zhang

Examples

Xt = gen_bi(sigma2 = 1, n_total = 1000, n_block = 10)plot(Xt)Yt = gen_bi(sigma2 = 0.8, n_total = 800, n_block = 20,title = "non-stationary bias-instability process")plot(Yt)

Generate a Drift Process

Description

Simulates a Drift Process with a given slope,\omega.

Usage

gen_dr(N, omega = 5)

Arguments

N

Aninteger for signal length.

omega

Adouble that contains drift slope

Value

Avec containing the drift.

Process Definition

Drift with parameter\omega \in \Omega where\Omega is in{\rm I\!R}^{+} or{\rm I\!R}^{-}. This process is defined as:X_t = \omega t and is occasionally referred to as Rate Ramp.

Generation Algorithm

To generate the Drift process, we first fill avector with the\omega parameter.After, we take the cumulative sum along the vector.


Generate a Fractional Gaussian noise given\sigma^2 andH.

Description

Simulates a Fractional Gaussian noise given\sigma^2 andH.

Usage

gen_fgn(N, sigma2 = 1, H = 0.9)

Arguments

N

Aninteger for signal length.

sigma2

Adouble.

H

Adouble.

Value

fgn Avec containing the Fractional Gaussian noise process.


Generate Generic Seasonal Autoregressive Order P - Moving Average Order Q (SARMA(p,q)x(P,Q)) Model

Description

Generate an ARMA(P,Q) process with supplied vector of Autoregressive Coefficients (\phi), Moving Average Coefficients (\theta), and\sigma^2.

Usage

gen_generic_sarima(N, theta_values, objdesc, sigma2 = 1.5, n_start = 0L)

Arguments

N

Aninteger for signal length.

theta_values

Avec containing the parameters for (S)AR and (S)MA.

objdesc

Avec that contains the+.ts.model's obj.desc field.

sigma2

Adouble that contains process variance.

n_start

Anunsigned int that indicates the amount of observations to be used for the burn in period.

Details

The innovations are generated from a normal distribution.The\sigma^2 parameter is indeed a variance parameter. This differs from R's use of the standard deviation,\sigma.

Value

Avec that contains the generated observations.


Simulate a simts TS object using a theoretical model

Description

Create agts object based on a time series model.

Usage

gen_gts(  n,  model,  start = 0,  end = NULL,  freq = 1,  unit_ts = NULL,  unit_time = NULL,  name_ts = NULL,  name_time = NULL)

Arguments

n

Aninteger containing the length of the time series.

model

Ats.model orsimts object containing the available models in the simts package.

start

Anumeric that provides the time of the first observation.

end

Anumeric that provides the time of the last observation.

freq

Anumeric that provides the rate of samples. Default value is 1.

unit_ts

Astring that contains the unit expression of the time series. Default value isNULL.

unit_time

Astring that contains the unit expression of the time. Default value isNULL.

name_ts

Astring that provides an identifier for the time series data. Default value isNULL.

name_time

Astring that provides an identifier for the time. Default value isNULL.

Details

This function accepts either ats.model object (e.g. AR1(phi = .3, sigma2 =1) + WN(sigma2 = 1)) or asimts object.

Value

Agts object

Author(s)

James Balamuta and Wenchao Yang

Examples

# Set seed for reproducibilityset.seed(1336)n = 1000# AR1 + WNmodel = AR1(phi = .5, sigma2 = .1) + WN(sigma2=1)x = gen_gts(n, model)plot(x)# Reset seedset.seed(1336)# GM + WN# Convert from AR1 to GM valuesm = ar1_to_gm(c(.5,.1),10)# Beta = 6.9314718, Sigma2_gm = 0.1333333model = GM(beta = m[1], sigma2_gm = m[2]) + WN(sigma2=1)x2 = gen_gts(n, model, freq = 10, unit_time = 'sec')plot(x2)# Same time seriesall.equal(x, x2, check.attributes = FALSE)

Generate a Latent Time Series Object Based on a Model

Description

Simulate alts object based on a supplied time series model.

Usage

gen_lts(  n,  model,  start = 0,  end = NULL,  freq = 1,  unit_ts = NULL,  unit_time = NULL,  name_ts = NULL,  name_time = NULL,  process = NULL)

Arguments

n

Aninterger indicating the amount of observations generated in this function.

model

Ats.model orsimts object containing one of the allowed models.

start

Anumeric that provides the time of the first observation.

end

Anumeric that provides the time of the last observation.

freq

Anumeric that provides the rate/frequency at which the time series is sampled. The default value is 1.

unit_ts

Astring that contains the unit of measure of the time series. The default value isNULL.

unit_time

Astring that contains the unit of measure of the time. The default value isNULL.

name_ts

Astring that provides an identifier for the time series data. Default value isNULL.

name_time

Astring that provides an identifier for the time. Default value isNULL.

process

Avector that contains model names of each column in thedata object where the last name is the sum of the previous names.

Details

This function accepts either ats.model object (e.g. AR1(phi = .3, sigma2 =1) + WN(sigma2 = 1)) or asimts object.

Value

Alts object with the following attributes:

start

The time of the first observation.

end

The time of the last observation.

freq

Numeric representation of the sampling frequency/rate.

unit

A string reporting the unit of measurement.

name

Name of the generated dataset.

process

Avector that contains model names of decomposed and combined processes

Author(s)

James Balamuta, Wenchao Yang, and Justin Lee

Examples

# ARset.seed(1336)model = AR1(phi = .99, sigma2 = 1) + WN(sigma2 = 1)test = gen_lts(1000, model)plot(test)

Generate Latent Time Series based on Model (Internal)

Description

Create a latent time series based on a supplied time series model.

Usage

gen_lts_cpp(N, theta, desc, objdesc)

Arguments

N

Aninterger containing the amount of observations for the time series.

theta

Avec containing the parameters to use to generate the model.

desc

Avector<string> containing the different model types (AR1, WN, etc..).

objdesc

Afield<vec> containing the different model objects e.g. AR1 = c(1,1)

Value

Amat containing data for each decomposed and combined time series.


Generate an Moving Average Order 1 (MA(1)) Process

Description

Generate an MA(1) Process given\theta and\sigma^2.

Usage

gen_ma1(N, theta = 0.3, sigma2 = 1)

Arguments

N

Aninteger for signal length.

theta

Adouble that contains moving average.

sigma2

Adouble that contains process variance.

Details

The function implements a way to generate thex_t values without calling the general ARMA function.

Value

Avec containing the MA(1) process.

Process Definition

The Moving Average order 1 (MA(1)) process with non-zero parameter\theta \in (-1,+1) and\sigma^2 \in {\rm I\!R}^{+}. This process is defined as:

{x_t} = {\varepsilon_t} + {\theta _1}{\varepsilon_{t - 1}}

,where

{\varepsilon_t}\mathop \sim \limits^{iid} N\left( {0,\sigma^2} \right)

Generation Algorithm

The function first generates a vector of white noise usinggen_wn and then obtains theMA values under the above equation.

TheX_0 (first value ofX_t) is discarded.


Generate a Matern Process given\sigma^2,\lambda and\alpha.

Description

Simulates a Matern Process given\sigma^2,\lambda and\alpha.

Usage

gen_matern(N, sigma2 = 1, lambda = 0.35, alpha = 0.9)

Arguments

N

Aninteger for signal length.

sigma2

Adouble.

lambda

Adouble.

alpha

Adouble.

Value

mtp Avec containing the Matern Process.


Generate a determinist vector returned by the matrix by vector product of matrixX and vector\beta.

Description

Generate a determinist vector returned by the matrix by vector product of matrixX and vector\beta.

Usage

gen_mean(X, beta)

Arguments

X

AMatrix with dimension n*p.

beta

Avector with dimension p*1

Value

mean_vec Avec containing the determinist vector.


Generate Time Series based on Model (Internal)

Description

Create a time series process based on a suppliedts.model.

Usage

gen_model(N, theta, desc, objdesc)

Arguments

N

Aninterger containing the amount of observations for the time series.

theta

Avec containing the parameters to use to generate the model

desc

Avector<string> containing the different model types (AR1, WN, etc..)

objdesc

Afield<vec> contains the different model objects e.g. AR1 = c(1,1)

Value

Avec that contains combined time series.


Generate Non-Stationary White Noise Process

Description

This function allows to generate a non-stationary white noise process.

Usage

gen_nswn(n_total, title = NULL, seed = 135, ...)

Arguments

n_total

Aninteger indicating the length of the simulated non-stationary white noise process.

title

Astring defining the name of the time series data.

seed

Aninteger defined for simulation replication purposes.

...

Additional parameters.

Value

Avector containing the non-stationary white noise process.

Note

This function generates a non-stationary white noise process whose theoretical maximum overlapping allan variance (MOAV) corresponds to the theoretical MOAV of the stationary white noise process. This example confirms that the allan variance is unable to distinguish between a stationary white noise process and a white noise process whose second-order behavior is non-stationary, as pointed out in the paper "A Study of the Allan Variance for Constant-Mean Non-Stationary Processes" by Xu et al. (IEEE Signal Processing Letters, 2017), preprint available:https://arxiv.org/abs/1702.07795.

Author(s)

Yuming Zhang

Examples

Xt = gen_nswn(n_total = 1000)plot(Xt)Yt = gen_nswn(n_total = 2000, title = "non-stationary white noise process", seed = 1960)plot(Yt)

Generate a Power Law Process given\sigma^2 andd.

Description

Simulates a a Power Law Process given\sigma^2 andd.

Usage

gen_powerlaw(N, sigma2 = 1, d = 0.9)

Arguments

N

Aninteger for signal length.

sigma2

Adouble.

d

Adouble.

Value

plp Avec containing the Power Law Process.


Generate a Quantisation Noise (QN) or Rounding Error Sequence

Description

Simulates a QN sequence givenQ^2.

Usage

gen_qn(N, q2 = 0.1)

Arguments

N

Aninteger for signal length.

q2

Adouble that contains autocorrection.

Value

Avec containing the QN process.

Process Definition

Quantization Noise (QN) with parameterQ^2 \in R^{+}. With i.i.dY_t \sim U(0,1) (i.e. a standard uniform variable), this process isdefined as:

X_t = \sqrt{12Q^2}(Y_{t}-Y_{t-1})

Generation Algorithm

To generate the quantisation noise, we follow this recipe:First, we generate using a random uniform distribution:

U_k^*\sim U\left[ {0,1} \right]

Then, we multiple the sequence by\sqrt{12} so:

{U_k} = \sqrt{12} U_k^*

Next, we find the derivative of{U_k}

{{\dot U}_k} = \frac{{{U_{k + \Delta t}} - {U_k}}}{{\Delta t}}

In this case, we modify the derivative such that:{{\dot U}_k}\Delta t = {U_{k + \Delta t}} - {U_k}

Thus, we end up with:

{x_k} = \sqrt Q {{\dot U}_k}\Delta t

{x_k} = \sqrt Q \left( {{U_{k + 1}} - {U_k}} \right)


Generate a Random Walk without Drift

Description

Generates a random walk without drift.

Usage

gen_rw(N, sigma2 = 1)

Arguments

N

Aninteger for signal length.

sigma2

Adouble that contains process variance.

Value

grw Avec containing the random walk without drift.

Process Definition

Random Walk (RW) with parameter\gamma^2 \in {\rm I\!R}^{+}. This process is defined as:

{X_t} = \sum\limits_{t = 1}^T {\gamma {Z_t}}

and is often calledRate Random Walk in the engineering literature.

Generation Algorithm

To generate we first obtain the standard deviation from the variance by taking a square root. Then, we sampleN times from aN(0,\sigma^2) distribution. Lastly, we take thecumulative sum over the vector.


Generate Seasonal Autoregressive Order P - Moving Average Order Q (SARMA(p,q)x(P,Q)) Model

Description

Generate an ARMA(P,Q) process with supplied vector of Autoregressive Coefficients (\phi), Moving Average Coefficients (\theta), and\sigma^2.

Usage

gen_sarima(N, ar, d, ma, sar, sd, sma, sigma2 = 1.5, s = 12L, n_start = 0L)

Arguments

N

Aninteger for signal length.

ar

Avec that contains the AR coefficients.

d

Aninteger that indicates a non-seasonal difference.

ma

Avec that contains the MA coefficients.

sar

Avec that contains the SAR coefficients.

sd

Aninteger that indicates a seasonal difference.

sma

Avec that contains the SMA coefficients.

sigma2

Adouble that contains process variance.

s

Aninteger that contains a seasonal id.

n_start

Anunsigned int that indicates the amount of observations to be used for the burn in period.

Details

The innovations are generated from a normal distribution.The\sigma^2 parameter is indeed a variance parameter. This differs from R's use of the standard deviation,\sigma.

Value

Avec that contains the generated observations.


Generate Seasonal Autoregressive Order P - Moving Average Order Q (SARMA(p,q)x(P,Q)) Model

Description

Generate an ARMA(P,Q) process with supplied vector of Autoregressive Coefficients (\phi), Moving Average Coefficients (\theta), and\sigma^2.

Usage

gen_sarma(N, ar, ma, sar, sma, sigma2 = 1.5, s = 12L, n_start = 0L)

Arguments

N

Aninteger for signal length.

ar

Avec that contains the AR coefficients.

ma

Avec that contains the MA coefficients.

sar

Avec that contains the SAR coefficients.

sma

Avec that contains the SMA coefficients.

sigma2

Adouble that contains process variance.

s

Aninteger that contains a seasonal id.

n_start

Anunsigned int that indicates the amount of observations to be used for the burn in period.

Details

The innovations are generated from a normal distribution.The\sigma^2 parameter is indeed a variance parameter. This differs from R's use of the standard deviation,\sigma.

Value

Avec that contains the generated observations.


Generate a Sinusoidal Process given\alpha^2 and\beta.

Description

Simulates a Sinusoidal Process Process with parameter\alpha^2 and\beta

Usage

gen_sin(N, alpha2 = 9e-04, beta = 0.06, U = 1)

Arguments

N

Aninteger for signal length.

alpha2

Adouble that contains the squared amplitude parameter alpha2.

beta

Adouble that contains the angular frequency parameter beta.

Value

sn Avec containing the sinusoidal process.

Generation Algorithm

The function first generates a initial cycle oscillation at t=0 from a Uniform law with parameter a = 0 and b = 2 * pi and then compute the signal from its definition

X_t = \alpha \sin(\beta t + U)

.


Generate a Gaussian White Noise Process (WN(\sigma ^2))

Description

Simulates a Gaussian White Noise Process with variance parameter\sigma ^2.

Usage

gen_wn(N, sigma2 = 1)

Arguments

N

Aninteger for signal length.

sigma2

Adouble that contains process variance.

Value

wn Avec containing the white noise.

Process Definition

Gaussian White Noise (WN) with parameter\sigma^2 \in {\rm I\!R}^{+}.This process is defined asX_t\sim N(0,\sigma^2) andis sometimes referred to as Angle (Velocity) Random Walk.

Generation Algorithm

To generate the Gaussian White Noise (WN) process, we first obtain the standard deviation from the variance by taking a square root. Then, we sampleN times from aN(0,\sigma ^2) distribution.


Retrieve GMWM starting value from Yannick's objective function

Description

Obtains the GMWM starting value given by Yannick's objective function optimization

Usage

getObjFun(theta, desc, objdesc, model_type, omega, wv_empir, tau)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring containing the model type. Either 'imu' or 'ssm'

omega

Amat that is the inverse of the diagonal of the V matrix.

wv_empir

Avec containing the empirical wavelet variance.

tau

Avec that contains the scales of 2^(1:J), where J is the number of scales created by the decomposition.

Value

Adouble that is the value of the Objective function under Yannick's starting algorithm


Retrieve GMWM starting value from Yannick's objective function

Description

Obtains the GMWM starting value given by Yannick's objective function optimization

Usage

getObjFunStarting(theta, desc, objdesc, model_type, wv_empir, tau)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring containing the model type. Either 'imu' or 'ssm'

wv_empir

Avec containing the empirical wavelet variance.

tau

Avec that contains the scales of 2^(1:J), where J is the number of scales created by the decomposition.

Value

Adouble that is the value of the Objective function under Yannick's starting algorithm


Routing function for summary info

Description

Gets all the data for the summary.gmwm function.

Usage

get_summary(  theta,  desc,  objdesc,  model_type,  wv_empir,  theo,  scales,  V,  omega,  obj_value,  N,  alpha,  robust,  eff,  inference,  fullV,  bs_gof,  bs_gof_p_ci,  bs_theta_est,  bs_ci,  B)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that represents the model transformation

wv_empir

Avec that

theo

Avec that

scales

Avec that

V

Amat that contains the V matrix used to obtain the GMWM.

omega

Amat that

obj_value

Adouble that contains the objective function value at the optimized solution.

N

Aint that indicates how long the time series is.

alpha

Adouble that handles the alpha level of the confidence interval (1-alpha)*100

robust

Abool that indicates whether the estimation should be robust or not.

eff

Adouble that specifies the amount of efficiency required by the robust estimator.

inference

Abool that indicates whether inference (e.g. GoF) should be run.

fullV

Abool that indicates whether the matrix has been fully bootstrapped.

bs_gof

Abool indicating whether the GoF should be bootstrapped or done asymptotically.

bs_gof_p_ci

Abool indicating whether a bootstrapped p-value should be generated during the bootstrapped GoF

bs_ci

Abool that indicates whether a bootstrapped CI should be obtained or to use analytical derivatives.

B

Aint that indicates how many iterations should take place.

Value

Afield<mat> that contains bootstrapped / asymptotic GoF results as well as CIs.


Transform GM to AR1

Description

Takes GM values and transforms them to AR1

Usage

gm_to_ar1(theta, freq)

Arguments

theta

Avec that contains AR1 values.

freq

Adouble indicating the frequency of the data.

Value

Avec containing GM values.

Author(s)

James BalamutaThe function takes a vector of GM values\beta and\sigma ^2_{gm}and transforms them to AR1 values\phi and\sigma ^2using the formulas:\phi = \exp \left( { - \beta \Delta t} \right){\sigma ^2} = \sigma _{gm}^2\left( {1 - \exp \left( { - 2\beta \Delta t} \right)} \right)


Generalized Method of Wavelet Moments (GMWM)

Description

Performs estimation of time series models by using the GMWM estimator.

Usage

gmwm(  model,  data,  model.type = "imu",  compute.v = "auto",  robust = FALSE,  eff = 0.6,  alpha = 0.05,  seed = 1337,  G = NULL,  K = 1,  H = 100,  freq = 1)

Arguments

model

Ats.model object containing one of the allowed models.

data

Amatrix ordata.frame object with only column(e.g.N \times 1), alts object,or agts object.

model.type

Astring containing the type of GMWM needed:"imu" or"ssm".

compute.v

Astring indicating the type of covariance matrixsolver. Valid values are:"fast","bootstrap","diag" (asymptotic diag),"full" (asymptotic full). By default, the programwill fit a "fast" model.

robust

Aboolean indicating whether to use the robustcomputation (TRUE) or not (FALSE).

eff

Adouble between 0 and 1 that indicates theefficiency.

alpha

Adouble between 0 and 1 that correspondings to the\frac{\alpha}{2} value for the waveletconfidence intervals.

seed

Aninteger that controls the reproducibility of theauto model selection phase.

G

Aninteger to sample the space for IMU and SSMmodels to ensure optimal identitability.

K

Aninteger that controls how many times thebootstrapping procedure will be initiated.

H

Aninteger that indicates how many differentsamples the bootstrap will be collect.

freq

Adouble that indicates the sampling frequency. Bydefault, this is set to 1 and only is important ifGM()is in the model

Details

This function is under work. Some of the features are active. Others... Not so much.

The V matrix is calculated by:diag\left[ {{{\left( {Hi - Lo} \right)}^2}} \right].

The function is implemented in the following manner:1. Calculate MODWT of data with levels = floor(log2(data))2. Apply the brick.wall of the MODWT (e.g. remove boundary values)3. Compute the empirical wavelet variance (WV Empirical).4. Obtain the V matrix by squaring the difference of the WV Empirical's Chi-squared confidence interval (hi - lo)^25. Optimize the values to obtain\hat{\theta}6. If FAST = TRUE, return these results. Else, continue.

Loop k = 1 to KLoop h = 1 to H7. Simulate xt underF_{\hat{\theta}}8. Compute WV EmpiricalEND9. Calculate the covariance matrix10. Optimize the values to obtain\hat{\theta}END11. Return optimized values.

The function estimates a variety of time series models. If type = "imu" or "ssm", thenparameter vector should indicate the characters of the models that compose the latent or state-space model. The modeloptions are:

If only an ARMA() term is supplied, then the function takes conditional least squares as starting valuesIf robust = TRUE the function takes the robust estimate of the wavelet variance to be used in the GMWM estimation procedure.

Value

Agmwm object with the structure:


Engine for obtaining the GMWM Estimator

Description

This function uses the Generalized Method of Wavelet Moments (GMWM) to estimate the parameters of a time series model.

Usage

gmwm_engine(  theta,  desc,  objdesc,  model_type,  wv_empir,  omega,  scales,  starting)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that represents the model transformation

wv_empir

Avec that contains the empirical wavelet variance

omega

Amat that represents the covariance matrix.

scales

Avec that contains the scales or taus (2^(1:J))

starting

Abool that indicates whether we guessed starting (T) or the user supplied estimates (F).

Details

If type = "imu" or "ssm", then parameter vector should indicate the characters of the models that compose the latent or state-space model.The model options are:

"AR1"

a first order autoregressive process with parameters(\phi,\sigma^2)

"ARMA"

an autoregressive moving average process with parameters(\phi _p, \theta _q, \sigma^2)

"DR"

a drift with parameter\omega

"QN"

a quantization noise process with parameterQ

"RW"

a random walk process with parameter\sigma^2

"WN"

a white noise process with parameter\sigma^2

If model_type = "imu" or type = "ssm" thenstarting values pass through an initial bootstrap and pseudo-optimization before being passed to the GMWM optimization.If robust = TRUE the function takes the robust estimate of the wavelet variance to be used in the GMWM estimation procedure.

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB

References

Wavelet variance based estimation for composite stochastic processes, S. Guerrier and Robust Inference for Time Series Models: a Wavelet-Based Framework, S. Guerrier


GMWM for (Robust) Inertial Measurement Units (IMUs)

Description

Performs the GMWM estimation procedure using a parameter transform and samplingscheme specific to IMUs.

Usage

gmwm_imu(model, data, compute.v = "fast", robust = F, eff = 0.6, ...)

Arguments

model

Ats.model object containing one of the allowed models.

data

Amatrix ordata.frame object with only column (e.g.N \times 1), or alts object, or agts object.

compute.v

Astring indicating the type of covariance matrix solver. "fast", "bootstrap", "asymp.diag", "asymp.comp", "fft"

robust

Aboolean indicating whether to use the robust computation (TRUE) or not (FALSE).

eff

Adouble between 0 and 1 that indicates the efficiency.

...

Other arguments passed to the main gmwm function

Details

This version of the gmwm function has customized settingsideal for modeling with an IMU object. If you seek to model with an GaussMarkov,GM, object. Please note results depend on thefreq specified in the data construction step within theimu. If you wish for results to be stable but lose theability to interpret with respect tofreq, then useAR1 terms.

Value

Agmwm object with the structure:

estimate

Estimated Parameters Values from the GMWM Procedure

init.guess

Initial Starting Values given to the Optimization Algorithm

wv.empir

The data's empirical wavelet variance

ci_low

Lower Confidence Interval

ci_high

Upper Confidence Interval

orgV

Original V matrix

V

Updated V matrix (if bootstrapped)

omega

The V matrix inversed

obj.fun

Value of the objective function at Estimated Parameter Values

theo

Summed Theoretical Wavelet Variance

decomp.theo

Decomposed Theoretical Wavelet Variance by Process

scales

Scales of the GMWM Object

robust

Indicates if parameter estimation was done under robust or classical

eff

Level of efficiency of robust estimation

model.type

Models being guessed

compute.v

Type of V matrix computation

augmented

Indicates moments have been augmented

alpha

Alpha level used to generate confidence intervals

expect.diff

Mean of the First Difference of the Signal

N

Length of the Signal

G

Number of Guesses Performed

H

Number of Bootstrap replications

K

Number of V matrix bootstraps

model

ts.model supplied to gmwm

model.hat

A new value ofts.model object supplied to gmwm

starting

Indicates whether the procedure used the initial guessing approach

seed

Randomization seed used to generate the guessing values

freq

Frequency of data


Master Wrapper for the GMWM Estimator

Description

This function generates WV, GMWM Estimator, and an initial test estimate.

Usage

gmwm_master_cpp(  data,  theta,  desc,  objdesc,  model_type,  starting,  alpha,  compute_v,  K,  H,  G,  robust,  eff)

Arguments

data

Avec containing the data.

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that represents the model transformation

starting

Abool that indicates whether the supplied values are guessed (T) or are user-based (F).

alpha

Adouble that handles the alpha level of the confidence interval (1-alpha)*100

compute_v

Astring that describes what kind of covariance matrix should be computed.

K

Anint that controls how many times theta is updated.

H

Anint that controls how many bootstrap replications are done.

G

Anint that controls how many guesses at different parameters are made.

robust

Abool that indicates whether the estimation should be robust or not.

eff

Adouble that specifies the amount of efficiency required by the robust estimator.

Value

Afield<mat> that contains a list of ever-changing estimates...

Author(s)

JJB

References

Wavelet variance based estimation for composite stochastic processes, S. Guerrier and Robust Inference for Time Series Models: a Wavelet-Based Framework, S. Guerrier


Bootstrap for Estimating Both Theta and Theta SD

Description

Using the bootstrap approach, we simulate a model based on user supplied parameters, obtain the wavelet variance, and then V.

Usage

gmwm_param_bootstrapper(  theta,  desc,  objdesc,  scales,  model_type,  N,  robust,  eff,  alpha,  H)

Arguments

theta

Avector with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

Details

Expand in detail...

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


Bootstrap for Standard Deviations of Theta Estimates

Description

Using the bootstrap approach, we simulate a model based on user supplied parameters

Usage

gmwm_sd_bootstrapper(  theta,  desc,  objdesc,  scales,  model_type,  N,  robust,  eff,  alpha,  H)

Arguments

theta

Avector with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

Details

Expand in detail...

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


Update Wrapper for the GMWM Estimator

Description

This function uses information obtained previously (e.g. WV covariance matrix) to re-estimate a different model parameterization

Usage

gmwm_update_cpp(  theta,  desc,  objdesc,  model_type,  N,  expect_diff,  ranged,  orgV,  scales,  wv,  starting,  compute_v,  K,  H,  G,  robust,  eff)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that represents the model transformation

scales

Avec that contains the scales or taus (2^(1:J))

starting

Abool that indicates whether we guessed starting (T) or the user supplied estimates (F).

Value

Afield<mat> that contains the parameter estimates from GMWM estimator.

Author(s)

JJB

References

Wavelet variance based estimation for composite stochastic processes, S. Guerrier and Robust Inference for Time Series Models: a Wavelet-Based Framework, S. Guerrier


Compute the GOF Test

Description

yaya

Usage

gof_test(theta, desc, objdesc, model_type, tau, v_hat, wv_empir)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that contains the model type:"imu" or"ssm"

tau

Avec containing the scales of a proccess.

v_hat

Amat that contains the bootstrapped matrix.

wv_empir

Avec that contains the empirical wavelet variance.

Value

Avec that has


Create a simts TS object using time series data

Description

Takes a time series and turns it into a time series oriented object that can be used for summary and graphing functions in thesimts package.

Usage

gts(  data,  start = 0,  end = NULL,  freq = 1,  unit_ts = NULL,  unit_time = NULL,  name_ts = NULL,  name_time = NULL,  data_name = NULL,  Time = NULL,  time_format = NULL)

Arguments

data

A one-columnmatrix,data.frame, or a numericvector.

start

Anumeric that provides the time of the first observation.

end

Anumeric that provides the time of the last observation.

freq

Anumeric that provides the rate/frequency at which the time series is sampled. The default value is 1.

unit_ts

Astring that contains the unit of measure of the time series. The default value isNULL.

unit_time

Astring that contains the unit of measure of the time. The default value isNULL.

name_ts

Astring that provides an identifier for the time series data. Default value isNULL.

name_time

Astring that provides an identifier for the time. Default value isNULL.

data_name

Astring that contains the name of the time series data.

Time

A numeric or charactervector containing the times of observations. Default value isNULL. Seex object inas.Date function.

time_format

Astring specifiying the format of 'Time'. If not provided, 'Time' is assumed to be all integers. Default value isNULL. Seeformat argument inas.Date function.

Value

Agts object

Author(s)

James Balamuta and Wenchao Yang

Examples

m = data.frame(rnorm(50))x = gts(m, unit_time = 'sec', name_ts = 'example')plot(x)x = gen_gts(50, WN(sigma2 = 1))x = gts(x, freq = 100, unit_time = 'sec')plot(x)

Time of a gts object

Description

Extracting the time of a gts object

Usage

gts_time(x)

Value

Time vector of a gts object.

Author(s)

Stéphane Guerrier


Randomly guess a starting parameter

Description

Sets starting parameters for each of the given parameters.

Usage

guess_initial(  desc,  objdesc,  model_type,  num_param,  expect_diff,  N,  wv,  tau,  ranged,  G)

Arguments

desc

Avector<string> that contains the model's components.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

model_type

Astring that indicates whether it is an SSM or sensor.

num_param

Anunsigned int number of parameters in the model (e.g. # of thetas).

expect_diff

Adouble that contains the mean of the first difference of the data

N

Ainteger that contains the number of observations in the data.

tau

Avec that contains the scales. (e.g. 2^(1:J))

G

Ainteger that indicates how many random draws that should be performed.

Value

Avec containing smart parameter starting guesses to be iterated over.


Randomly guess a starting parameter

Description

Sets starting parameters for each of the given parameters.

Usage

guess_initial_old(  desc,  objdesc,  model_type,  num_param,  expect_diff,  N,  wv_empir,  tau,  B)

Arguments

desc

Avector<string> that contains the model's components.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

model_type

Astring that indicates whether it is an SSM or sensor.

num_param

Anunsigned int number of parameters in the model (e.g. # of thetas).

expect_diff

Adouble that contains the mean of the first difference of the data

N

Ainteger that contains the number of observations in the data.

wv_empir

Avec that contains the empirical wavelet variance.

tau

Avec that contains the scales. (e.g. 2^(1:J))

B

Ainteger that indicates how many random draws that should be performed.

Value

Avec containing smart parameter starting guesses to be iterated over.


Haar filter construction

Description

Creates the haar filter

Usage

haar_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


Obtain the value of an object's properties

Description

Used to access different properties of thegts,imu, orlts object.

Usage

has(x, type)## S3 method for class 'imu'has(x, type)

Arguments

x

Agts,imu, orlts object.

type

Astring indicating the field to be retrieved.

Details

To access information aboutimu properties use:

"accel"

Returns whether accelerometers have been specified

"gyro"

Returns whether accelerometers have been specified

"sensors"

Returns whether there exists both types of sensors

Value

The method will return a single TRUE or FALSE response

Methods (by class)

Author(s)

James Balamuta


Mean Monthly Precipitation, from 1907 to 1972

Description

Hydrology data that indicates a robust approach may be preferred to aclassical approach when estimating time series.

Usage

hydro

Format

A time series object with frequency 12 starting at 1907 and going to 1972for a total of 781 observations.

Source

datamarket, mean-monthly-precipitation-1907-1972


Indirect Inference for ARMA

Description

Option for indirect inference

Usage

idf_arma(ar, ma, sigma2, N, robust, eff, H)

Arguments

ar

Avec that contains the coefficients of the AR process.

ma

Avec that contains the coefficients of the MA process.

sigma2

Adouble that indicates the sigma2 parameter of the ARMA process.

N

Aint that indicates how long the time series is.

robust

Abool that indicates whether the estimation should be robust or not.

eff

Adouble that specifies the amount of efficiency required by the robust estimator.

H

Aint that indicates how many iterations should take place.

Value

Avec with the indirect inference results.


Indirect Inference for ARMA

Description

Option for indirect inference

Usage

idf_arma_total(ar, ma, sigma2, N, robust, eff, H)

Arguments

ar

Avec that contains the coefficients of the AR process.

ma

Avec that contains the coefficients of the MA process.

sigma2

Adouble that indicates the sigma2 parameter of the ARMA process.

N

Aint that indicates how long the time series is.

robust

Abool that indicates whether the estimation should be robust or not.

eff

Adouble that specifies the amount of efficiency required by the robust estimator.

H

Aint that indicates how many iterations should take place.

Value

Avec with the indirect inference results.


Create an IMU Object

Description

Builds an IMU object that provides the program with gyroscope, accelerometer, and axis information per column in the dataset.

Usage

imu(  data,  gyros = NULL,  accels = NULL,  axis = NULL,  freq = NULL,  unit = NULL,  name = NULL)

Arguments

data

Avector which contains data, or amatrix ordata.frame which contains the data in each column.

gyros

Avector that contains the index of columns where gyroscope data (such as Gyro. X, Gyro. Y and Gyro. Z) is placed.

accels

Avector that contains the index of columns where accelerometer data (such as Accel. X, Accel. Y and Accel. Z) is placed.

axis

Avector that indicates the axises, such as 'X', 'Y', 'Z'. Please supply the axises for gyroscope data before that for accelerometer data, if gyroscope data exists.

freq

Aninteger that provides the frequency for the data.

unit

Astring that contains the unit expression of the frequency. Default value isNULL.

name

Astring that provides an identifier to the data. Default value isNULL.

Details

data can be a numeric vector, matrix or data frame.

gyros andaccels cannot beNULL at the same time, but it will be fine if one of them isNULL.In the new implementation, the length ofgyros andaccels do not need to be equal.

Inaxis, duplicate elements are not alowed for each sensor. In the new implementation, please specify the axis for each column of data.axis will be automatically generated if there are less than or equal to 3 axises for each sensor.

Value

Animu object in the following attributes:

sensor

Avector that indicates whether data contains gyroscope sensor, accelerometer sensor, or both.

num.sensor

Avector that indicates how many columns of data are for gyroscope sensor and accelerometer sensor.

axis

Axis value such as 'X', 'Y', 'Z'.

freq

Observations per second.

unit

String representation of the unit.

name

Name of the dataset.

Author(s)

James Balamuta and Wenchao Yang

Examples

## Not run: if(!require("imudata")){   install_imudata()   library("imudata")}data(imu6)# Example 1 - Only gyrostest1 = imu(imu6, gyros = 1:3, axis = c('X', 'Y', 'Z'), freq = 100)df1 = wvar.imu(test1)plot(df1)# Example 2 - One gyro and one accelerometertest2 = imu(imu6, gyros = 1, accels = 4, freq = 100)df2 = wvar.imu(test2)plot(df2)# Example 3 - 3 gyros and 3 accelerometerstest3 = imu(imu6, gyros = 1:3, accels = 4:6, axis =                        c('X', 'Y', 'Z', 'X', 'Y', 'Z'), freq = 100)df3 = wvar.imu(test3)plot(df3)# Example 4 - Custom axistest4 = imu(imu6, gyros = 1:2, accels = 4:6, axis =                        c('X', 'Y', 'X', 'Y', 'Z'), freq = 100)df4 = wvar.imu(test4)plot(df4)## End(Not run)

Pulls the IMU time from the IMU object

Description

Helper function for the IMU object to accessrownames() with a numeric conversion.

Usage

imu_time(x)

Arguments

x

Aimu object

Value

Avector with numeric information.


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

Avec containing the data

xi

Avec with lengthlag*d that provides initial values for the integration.

lag

Anunsigned int indicating the lag between observations.

d

Anunsigned int which gives the number of "differences" to invert.


Check Invertibility Conditions

Description

Checks the invertiveness of series of coefficients.

Usage

invert_check(x)

Arguments

x

Acx_vec that has a 1 appended before the coefficents. (e.g. c(1, x))

Value

True (if outside unit circle) || False (if inside unit circle)


Is simts Object

Description

Is the object agts,imu, orlts object?

Usage

is.gts(x)is.imu(x)is.lts(x)is.ts.model(x)

Arguments

x

Agts,imu,lts object.

Details

Usesinherits overis for speed.

Value

Alogical value that indicates whether the object is of that class (TRUE) or not (FALSE).

Author(s)

James Balamuta


Integer Check

Description

Checks whether the submitted value is an integer

Usage

is.whole(x)

Arguments

x

Anumeric value.

Value

Aboolean value indicating whether the value is an integer or not.

Author(s)

James Balamuta

Examples

is.whole(2.3)is.whole(4)is.whole(c(1,2,3))is.whole(c(.4,.5,.6))is.whole(c(7,.8,9))

Calculates the Jacobian for the ARMA process

Description

Take the numerical derivative for the first derivative of an ARMA using the 2 point rule.

Usage

jacobian_arma(theta, p, q, tau)

Arguments

theta

Avec that contains all the parameter estimates.

p

Aint that indicates the number of AR coefficients

q

Aint that indicates the number of MA coefficients.

tau

Avec containing the scales e.g.2^{\tau}

Value

Amat that returns the first numerical derivative of the ARMA process.

Author(s)

James Joseph Balamuta (JJB)


la16 filter construction

Description

Creates the la16 filter

Usage

la16_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


la20 filter construction

Description

Creates the la20 filter

Usage

la20_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


la8 filter construction

Description

Creates the la8 filter

Usage

la8_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


MLR in Armadillo

Description

Perform Multiple Linear Regression using armadillo in C++

Usage

lm_arma(y, X)

Arguments

y

Avec of lengthN\times 1 containing the responses.

X

Amat with dimensionsN \times p, which is the design matrix.

Value

Afield<vec> with:

coef

Coefficients

resid

Residuals

sigma2

Sigma^2


Linear Regression with Drift

Description

Perform a linear regression with drift.

Usage

lm_dr(x)

Arguments

x

Avec of lengthN\times 1 containing the responses.

Value

Afield<vec> with:

coef

Coefficients

resid

Residuals

sigma2

Sigma^2


Logit Function

Description

This function computes the logit link function.

Usage

logit(x)

Arguments

x

Avec containing probabilities (e.g. -1 <= x <= 1)

Value

Avec containing logit terms.

Author(s)

James Joseph Balamuta (JJB)


Logit2 Function

Description

This function computes the logit2 link function.

Usage

logit2(x)

Arguments

x

Avec containing probabilities (e.g. -2 <= x <= 2)

Value

Avec containing logit terms.

Author(s)

James Joseph Balamuta (JJB)


Logit2 Inverse Function

Description

This function computes the inverse of a logit transformation of the parameters.

Usage

logit2_inv(x)

Arguments

x

Avec containing real numbers.

Value

Avec containing logit probabilities.

Author(s)

James Joseph Balamuta (JJB)


Logit Inverse Function

Description

This function computes the inverse of a logit transformation of the parameters.

Usage

logit_inv(x)

Arguments

x

Avec containing real numbers.

Value

Avec containing logit probabilities.

Author(s)

James Joseph Balamuta (JJB)


Generate a Latent Time Series Object from Data

Description

Create alts object based on a supplied matrix or data frame. The latent time series is obtained by the sum of underlying time series.

Usage

lts(  data,  start = 0,  end = NULL,  freq = 1,  unit_ts = NULL,  unit_time = NULL,  name_ts = NULL,  name_time = NULL,  process = NULL)

Arguments

data

A multiple-columnmatrix ordata.frame. It must contain at least 3 columns of which the last represents the latent time series obtained through the sum of the previous columns.

start

Anumeric that provides the time of the first observation.

end

Anumeric that provides the time of the last observation.

freq

Anumeric that provides the rate/frequency at which the time series is sampled. The default value is 1.

unit_ts

Astring that contains the unit of measure of the time series. The default value isNULL.

unit_time

Astring that contains the unit of measure of the time. The default value isNULL.

name_ts

Astring that provides an identifier for the time series data. Default value isNULL.

name_time

Astring that provides an identifier for the time. Default value isNULL.

process

Avector that contains model names of each column in thedata object where the last name is the sum of the previous names.

Value

Alts object

Author(s)

Wenchao Yang and Justin Lee

Examples

model1 = AR1(phi = .99, sigma2 = 1) model2 = WN(sigma2 = 1)col1 = gen_gts(1000, model1)col2 = gen_gts(1000, model2)testMat = cbind(col1, col2, col1+col2)testLts = lts(testMat, unit_time = 'sec', process = c('AR1', 'WN', 'AR1+WN'))plot(testLts)

Second moment DR

Description

This function computes the second moment of a drift process.

Usage

m2_drift(omega, n_ts)

Arguments

omega

Adouble corresponding to variance of drift.

n_ts

Anint indicating the length of the time series.

Value

Avec containing the second moment of the drift.


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

Adouble corresponding to the moving average term.

sigma2

Adouble the variance of the process.

tau

Avec containing the scales e.g.2^{\tau}

Details

This function is significantly faster than its generalized counter partarma_to_wv.

Value

Avec containing the wavelet variance of the MA(1) process.

Process Haar Wavelet Variance Formula

The Moving Average Order1 (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}}


Default utility function for various plots titles

Description

Adds title, grid, and required x- and y-axes.

Usage

make_frame(  x_range,  y_range,  xlab,  ylab,  main = "",  mar = c(5.1, 5.1, 1, 2.1),  add_axis_x = TRUE,  add_axis_y = TRUE,  col_box = "black",  col_grid = "grey95",  col_band = "grey95",  col_title = "black",  add_band = TRUE,  title_band_width = 0.09,  grid_lty = 1)

Arguments

x_range

Anumeric providing the range of values for the x-axis.

y_range

Anumeric providing the range of values for the y-axis.

xlab

Astring that gives a title for the x-axis.

ylab

Astring that gives a title for the y-axis.

main

Astring that gives an overall title for the plot. Default is an empty string.

mar

Avector indicating overall margin values for the plot.

add_axis_x

Aboolean indicating whether a x-axis should be added.

add_axis_y

Aboolean indicating whether a y-axis should be added.

col_box

Astring indicating the color for the title box.

col_grid

Astring indicating the color of the grid for the plot.

col_band

Astring indicating the color of the band.

col_title

Astring indicating the color of the plot title.

add_band

Aboolean indicating whether there should be a band.

title_band_width

Adouble providing the value of the band width. Default is 0.09.

grid_lty

Ainteger indicating the line type of the grid lines.

Value

Added title, grid, and axes.

Author(s)

Stephane Guerrier and Justin Lee

Examples

make_frame(x_range = c(0, 1), y_range = c(0, 1), xlab = "my xlab",            ylab = "my ylab", main = "my title")           make_frame(x_range = c(0, 1), y_range = c(0, 1), xlab = "my xlab",            ylab = "my ylab", add_band = FALSE)           make_frame(x_range = c(0, 1), y_range = c(0, 1), xlab = "my xlab",            ylab = "my ylab", main = "my title", col_band = "blue3",            col_title = "white", col_grid = "lightblue", grid_lty = 3)make_frame(x_range = c(0, 1), y_range = c(0, 1), xlab = "my xlab",            ylab = "my ylab", main = "my title", col_band = "blue3",            col_title = "white", col_grid = "lightblue", grid_lty = 3,           title_band_width = 0.18)

mb16 filter construction

Description

Creates the mb16 filter

Usage

mb16_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


mb24 filter construction

Description

Creates the mb24 filter

Usage

mb24_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


mb4 filter construction

Description

Creates the mb4 filter

Usage

mb4_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


mb8 filter construction

Description

Creates the mb8 filter

Usage

mb8_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


Mean of the First Difference of the Data

Description

The mean of the first difference of the data

Usage

mean_diff(x)

Arguments

x

Avec containing the data

Value

Adouble that contains the mean of the first difference of the data.


Obtain the smallest polynomial root

Description

Calculates all the roots of a polynomial and returns the root that is the smallest.

Usage

minroot(x)

Arguments

x

Acx_vec that has a 1 appended before the coefficents. (e.g. c(1, x))

Value

Adouble with the minimum root value.


Generate the ts model object description

Description

Creates the ts.model's obj.desc value

Usage

model_objdesc(desc)

Arguments

desc

Avector<string> that contains a list of the strings of each process.

Details

This function currently does NOT support ARMA(P,Q) models. That is, there is no support for ARMA(P,Q), AR(P), or MA(Q).There is support for ARMA11, AR1, MA1, GM, WN, DR, QN, and RW.

Value

Afield<vec> that contains the object description of each process.


Generate the ts model object's process desc

Description

Creates the ts.model's process desc

Usage

model_process_desc(desc)

Arguments

desc

Avector<string> that contains a list of the strings of each process.

Details

This function currently does NOT support ARMA(P,Q) models. That is, there is no support for ARMA(P,Q), AR(P), or MA(Q).There is support for ARMA11, AR1, MA1, GM, WN, DR, QN, and RW.

Value

Avector<string> with a list of descriptive values to label the estimate matrix with


Model Score

Description

Calculates the modeling score of a GMWM

Usage

model_score(A, D, omega, v_hat, obj_value)

Arguments

A

Amat that contains the first derivatives of the processes

omega

Amat that contains the omega used when calculating the GMWM

v_hat

Amat that contains the covariance matrix

Details

The equation is slightly different than that stated in the paper due to the bootstrap already incorporating in N.

Value

Avec


Generate the ts model object's theta vector

Description

Creates the ts.model's theta vector

Usage

model_theta(desc)

Arguments

desc

Avector<string> that contains a list of the strings of each process.

Details

This function currently does NOT support ARMA(P,Q) models. That is, there is no support for ARMA(P,Q), AR(P), or MA(Q).There is support for ARMA11, AR1, MA1, GM, WN, DR, QN, and RW.

Value

Avec with values initialized at 0 that span the space of parameters to be estimated.


Maximum Overlap Discrete Wavelet Transform

Description

Calculation of the coefficients for the discrete wavelet transformation

Usage

modwt_cpp(x, filter_name, nlevels, boundary, brickwall)

Arguments

x

Avector with dimensionsN\times 1.

filter_name

Astring indicating the filter.

nlevels

Aninteger,J, indicating the level of the decomposition.

boundary

Astring indicating the type of boundary method to use. Eitherboundary="periodic" or"reflection".

brickwall

Abool indicating whether the a brick wall procedure should be applied to the coefficients.

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 Afield<vec> that contains the wavelet coefficients for each decomposition level

Author(s)

JJB


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

Avec that contains the data.

robust

Aboolean that triggers the use of the robust estimate.

eff

Adouble that indicates the efficiency as it relates to an MLE.

alpha

Adouble that indicates the\left(1-p\right)\times \alpha confidence level

ci_type

Astring indicating the confidence interval being calculated. Valid value: "eta3"

strWavelet

Astring indicating the type of wave filter to be applied. Must be "haar"

decomp

Astring indicating whether to use "modwt" or "dwt" decomp

Details

This function powers the wvar object. It is also extendable...

Value

Amat with the structure:

"variance"

Wavelet Variance

"low"

Lower CI

"high"

Upper CI


Bootstrap standard error for the median

Description

Non-parametric bootstrap to obtain the standard of the median ofiid data.

Usage

np_boot_sd_med(x, B = 5000)

Arguments

x

Avector of data.

B

Anumeric indicating the number of simulations.

Value

Bootstrap standard error for the median


Replicate a Vector of Elementsn times

Description

This function takes a vector and replicates all of the datan times

Usage

num_rep(x, n)

Arguments

x

Avec containing the data

n

Anunsigned int indicating the number of times the vector should be repeated.

Value

Avec with repeated elements of the initial supplied vector.


Extract Object

Description

Extracts the object information and returns it.

Usage

obj_extract(theta, objdesc, cur_position)

Arguments

theta

Avec containing the theta values.

objdesc

Avec at the desc point.

cur_position

Aninteger at the current position.

Value

Afield<vec> containing the breakdown of the object.


Bootstrap for Optimism and GoF

Description

Using the bootstrap approach, we simulate a model based on user supplied parameters, obtain the wavelet variance, and then V.

Usage

opt_n_gof_bootstrapper(  theta,  desc,  objdesc,  scales,  model_type,  N,  robust,  eff,  alpha,  H)

Arguments

theta

Avector with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

scales

Avec containing the scales of the process.

model_type

Astring containing the model type either: SSM or IMU

N

Aint indicating how long the integer is.

robust

Abool indicating robust (T) or classical (F).

eff

Adouble that handles efficiency.

H

Aint that indicates how many bootstraps should be obtained.

Details

Expand in detail...

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


Bootstrap for Optimism

Description

Using the bootstrap approach, we simulate a model based on user supplied parameters, obtain the wavelet variance, and then V.

Usage

optimism_bootstrapper(  theta,  desc,  objdesc,  scales,  model_type,  N,  robust,  eff,  alpha,  H)

Arguments

theta

Avector with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> that contains an object description (e.g. values) of the model.

Details

Expand in detail...

Value

Avec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


Order the Model

Description

Orders the model and changes it to the correct format

Usage

orderModel(models)

Arguments

models

A vector ofstring that specifies the models

Details

If themodels are c("AR1", "WN", "AR1", "WN", "AR1+WN+AR1+WN"), it will be converted to c("AR1-1", "WN-1", "AR1-2", "WN-2", "AR1+WN+AR1+WN").

This function is used ingen.lts()

Examples

models = c("AR1", "WN", "AR1", "WN", "AR1+WN+AR1+WN")new.models = orderModel(models)new.modelsmodels = c('AR1', 'QN', 'WN', 'AR1+QN+WN')new.models = orderModel(models)new.models

Order AR1s by size of phi.

Description

Changes the order of AR1s in a string by size.

Usage

order_AR1s(theta, desc, objdesc)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

Value

Avec that has AR1s shown in descending parameter value.


Plot Partial Auto-Covariance and Correlation Functions

Description

The function plots the output of thetheo_pacf andauto_corr functions (partial autocovariance or autocorrelation functions).

Usage

## S3 method for class 'PACF'plot(  x,  xlab = NULL,  ylab = NULL,  show.ci = TRUE,  alpha = NULL,  col_ci = NULL,  transparency = NULL,  main = NULL,  parValue = NULL,  ...)

Arguments

x

A"PACF" object output fromtheo_pacf orauto_corr.

xlab

Astring indicating the label of the x axis: the default name is 'Lags'.

ylab

Astring indicating the label of the y axis: the default name is 'PACF'.

show.ci

Abool indicating whether to show the confidence region. Defaults toTRUE.

alpha

Adouble indicating the level of significance for the confidence interval. By defaultalpha = 0.05 which gives a 1 -alpha = 0.95 confidence interval.

col_ci

Astring that specifies the color of the region covered by the confidence intervals (confidence region).

transparency

Adouble between 0 and 1 indicating the transparency level of the color defined incol_ci.Defaults to 0.25.

main

Astring indicating the title of the plot. Default name is "Variable name PACF plot'.

parValue

Avector defining the margins for the plot.

...

Additional parameters

Author(s)

Yunxiang Zhang and Yuming Zhang

Examples

# Plot the Partial Autocorrelationm = auto_corr(datasets::AirPassengers, pacf = TRUE)plot(m)# More customized CIplot(m, xlab = "my xlab", ylab = "my ylab", show.ci = TRUE, alpha = NULL, col_ci = "grey", transparency = 0.5, main = "my main")

Plot the GMWM with the Wavelet Variance

Description

Displays a plot of the Wavelet Variance (WV) with the CI values and the WV implied by the estimated parameters.

Usage

## S3 method for class 'gmwm'plot(  x,  decomp = FALSE,  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

Agmwm object.

decomp

Aboolean that determines whether the contributions of each individual model are plotted.

units

Astring that specifies the units of time plotted on the x axis.

xlab

Astring that gives a title for the x axis.

ylab

Astring that gives a title for the y axis.

main

Astring that gives an overall title for the plot.

col_wv

Astring that specifies the color of the wavelet variance line.

col_ci

Astring that specifies the color of the shaded area covered by the confidence intervals.

nb_ticks_x

Aninteger that specifies the maximum number of ticks for the x-axis.

nb_ticks_y

Aninteger that specifies the maximum number of ticks for the y-axis.

legend_position

Astring that specifies the position of the legend (uselegend_position = NA to remove legend).

ci_wv

Aboolean that determines whether to plot the confidence interval shaded area.

point_cex

Adouble that specifies the size of each symbol to be plotted.

point_pch

Adouble that specifies the symbol type to be plotted.

...

Additional arguments affecting the plot.

Value

Plot of WV and relative confidence intervals for each scale.

Author(s)

Stephane Guerrier and Yuming Zhang


Plot simts Time Series Data

Description

Plot simts Time Series Data generated by gts or gen_gts.

Usage

## S3 method for class 'gts'plot(  x,  evenly = TRUE,  xlab = NULL,  ylab = NULL,  main = NULL,  couleur = "blue4",  ...)

Arguments

x

Agts object

evenly

Aboolean indicating whether the time series is evenly spaced or not.

xlab

Astring that gives a title for the x axis.

ylab

Astring that gives a title for the y axis.

main

Astring that gives an overall title for the plot.

couleur

Astring that gives a couleuror for the line.

...

additional arguments affecting the plot produced.

Value

A plot containing the graph of the simts time series.

Author(s)

Justin Lee and Stéphane Guerrier


Plot Latent Time Series Object

Description

Plot Latent Time Series Data included in anlts object.

Usage

## S3 method for class 'lts'plot(  x,  xlab = NULL,  ylab = NULL,  main = NULL,  color = NULL,  fixed_range = FALSE,  ...)

Arguments

x

Alts object

xlab

Astring that gives a title for the x axis.

ylab

Astring that gives a title for the y axis.

main

Astring that gives an overall title for the plot.

color

Astring that gives a color for the line.

...

additional arguments affecting the plot produced.

Value

A plot containing the graph of the latent time series.

Author(s)

Stephane Gurrier and Justin Lee


Plot Auto-Covariance and Correlation Functions

Description

The function plots the output of thetheo_acf andauto_corr functions (autocovariance or autocorrelation functions).

Usage

## S3 method for class 'simtsACF'plot(  x,  xlab = NULL,  ylab = NULL,  show.ci = TRUE,  alpha = NULL,  col_ci = NULL,  transparency = NULL,  main = NULL,  parValue = NULL,  ...)

Arguments

x

An"ACF" object output fromtheo_acf andauto_corr.

xlab

Astring indicating the label of the x axis: the default name is 'Lags'.

ylab

Astring indicating the label of the y axis: the default name is 'ACF'.

show.ci

Abool indicating whether to show the confidence region. Defaults toTRUE.

alpha

Adouble indicating the level of significance for the confidence interval. By defaultalpha = 0.05 which gives a 1 -alpha = 0.95 confidence interval.

col_ci

Astring that specifies the color of the region covered by the confidence intervals (confidence region).

transparency

Adouble between 0 and 1 indicating the transparency level of the color defined incol_ci.Defaults to 0.25.

main

Astring indicating the title of the plot. Default name is "Variable name ACF plot'.

parValue

Avector defining the margins for the plot.

...

Additional parameters

Author(s)

Yunxiang Zhang, Stéphane Guerrier and Yuming Zhang

Examples

# Calculate the Autocorrelationm = auto_corr(datasets::AirPassengers)# Plot with 95% CIplot(m) # Plot with 90% CIplot(m, alpha = 0.1) # Plot without 95% CIplot(m, show.ci = FALSE)# More customized CIplot(m, xlab = "my xlab", ylab = "my ylab", show.ci = TRUE,alpha = NULL, col_ci = "grey", transparency = 0.5, main = "my main")

Plot Time Series Forecast Function

Description

This function plots the time series output from a forecast method with approximate 68

Usage

plot_pred(  x,  model,  n.ahead,  level = NULL,  xlab = NULL,  ylab = NULL,  main = NULL,  ...)

Arguments

x

Agts object

model

Ats model

n.ahead

Aninteger indicating number of units of time ahead for which to make forecasts

level

Adouble orvector indicating confidence level of prediction interval.By default, it uses the levels of 0.50 and 0.95.

xlab

Astring for the title of x axis

ylab

Astring for the title of y axis

main

Astring for the over all title of the plot

...

Additional parameters

Author(s)

Yuming Zhang


Time Series Prediction

Description

This function plots the time series forecast.

Usage

## S3 method for class 'fitsimts'predict(  object,  n.ahead = 10,  show_last = 100,  level = NULL,  xlab = NULL,  ylab = NULL,  main = NULL,  plot = TRUE,  ...)

Arguments

object

Afitsimts object obtained fromestimate function.

n.ahead

Aninteger indicating number of units of time ahead for which to make forecasts.

show_last

Ainteger indicating the number of last observations to show in the forecast plot.

level

Adouble orvector indicating confidence level of prediction interval.By default, it uses the levels of 0.50 and 0.95.

xlab

Astring for the title of x axis.

ylab

Astring for the title of y axis.

main

Astring for the over all title of the plot.

plot

Alogical value. logical. IfTRUE(the default) the predictions are plotted.

...

Additional arguments.

Author(s)

Stéphane Guerrier and Yuming Zhang

Examples

Xt = gen_gts(300, AR(phi = c(0, 0, 0.8), sigma2 = 1))model = estimate(AR(3), Xt)predict(model)predict(model, level = 0.95)x = gts(as.vector(lynx), start = 1821, end = 1934, freq = 1, unit_ts = bquote(paste(10^8," ",m^3)), name_ts = "Numbers", unit_time = "year", data_name = "Annual Numbers of Lynx Trappings")model = estimate(AR(1), x)predict(model, n.ahead = 20)predict(model, n.ahead = 20, level = 0.95)predict(model, n.ahead = 20, level = c(0.50, 0.80, 0.95))

Predict future points in the time series using the solution of theGeneralized Method of Wavelet Moments

Description

Creates a prediction using the estimated values of GMWM through theARIMA function within R.

Usage

## S3 method for class 'gmwm'predict(object, data.in.gmwm, n.ahead = 1, ...)

Arguments

object

Agmwm object

data.in.gmwm

The data SAME EXACT DATA used in the GMWM estimation

n.ahead

Number of observations to forecast

...

Additional parameters passed to ARIMA Predict

Value

Apredict.gmwm object with:

pred

Predictions

se

Standard Errors

resid

Residuals from ARIMA ML Fit


Print fitsimts object

Description

This function displays the information of a fitsimts object.

Usage

## S3 method for class 'fitsimts'print(x, ...)

Arguments

x

Afitsimts object

...

Other arguments passed to specific methods

Value

Text output via print

Author(s)

Stéphane Guerrier and Yuming Zhang


Print gmwm object

Description

Displays information about GMWM object

Usage

## S3 method for class 'gmwm'print(x, ...)

Arguments

x

AGMWM object

...

Other arguments passed to specific methods

Value

Text output via print

Author(s)

JJB


Print simts Objects

Description

Pretty formatting forgts,imu, andlts objects.

Usage

## S3 method for class 'imu'print(x, obs = 10L, row.names = TRUE, ...)## S3 method for class 'lts'print(x, obs = 10L, row.names = TRUE, ...)## S3 method for class 'gts'print(x, obs = 10L, row.names = TRUE, ...)outf(x, obs = 10L, row.names = TRUE)

Arguments

x

Agts,imu,lts object.

obs

Ainteger the specifies how many from the beginning and end of the data set to show.

row.names

Aboolean that indicates whether row names should be displayed or surpressed.

...

Further arguments passed to or from other methods.

Value

Alogical value that indicates whether the object is of that class (TRUE) or not (FALSE).

Author(s)

James Balamuta


Print summary.gmwm object

Description

Displays summary information about GMWM object

Usage

## S3 method for class 'summary.gmwm'print(x, ...)

Arguments

x

AGMWM object

...

Other arguments passed to specific methods

Value

Text output via print

Author(s)

JJB


Multiply a ts.model by constant

Description

Sets up the necessary backend for creating multiple model objects.

Usage

## S3 method for class 'ts.model'print(x, ...)

Arguments

x

Anumeric value

...

further arguments passed to or from other methods.

Value

An S3 object with called ts.model with the following structure:

Author(s)

James Balamuta

Examples

# Creates a parameter space for guessingQN() + DR() + WN() + RW() + AR1() + ARMA(1,2)# Creates a user-specified starting value modelAR1(phi = .9, sigma2 = .1) + WN(sigma2 = 1) # Similarly, with the addition of a generic ARMARW(gamma2 = .3) + DR(omega = .5) + QN(q2 = .9) + ARMA(ar = c(.3,.1), ma = c(.3,.2), sigma2 = .99)# In a similar vein, this example highlights the lack of need for specifying parameters. AR1(.9,.1) + WN(1) + RW(.3) + DR(.5) + QN(.9) + ARMA(c(.3,.1), c(.3,.2), .99)

Pseudo Logit Function

Description

This function compute the link function to constrain parameters to a positive domain.

Usage

pseudo_logit(x)

Arguments

x

Avec containing probabilities (e.g. 0 <= x <= 1)

Value

Avec containing logit terms.

Author(s)

James Joseph Balamuta (JJB)


Pseudo Logit Inverse Function

Description

This function computes the pseudo inverse of a logit transformation of the parameters in order to constrain them to a positive domain

Usage

pseudo_logit_inv(x)

Arguments

x

Avec containing real numbers.

Value

Avec containing logit probabilities.

Author(s)

James Joseph Balamuta (JJB)


Quadrature Mirror Filter

Description

Calculate the series quadrature mirror filter (QMF). Requires a series of an even length.

Usage

qmf(g, inverse)

Arguments

g

Avector that contains the filter constants.

inverse

Abool that indicates whether the inverse quadrature mirror filter is computed. By default, the inverse quadrature mirror is computed.

Value

Avector that contains either the forward QMF (evalute in order) or the inverse QMF (reverse order).

Author(s)

JJB


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

Adouble corresponding to variance of drift

tau

Avec containing the scales e.g.2^{\tau}

Value

Avec 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

Avec of data

probs

Avec of the quantiles to find.

Value

Avector containing the quantiles

Author(s)

James J Balamuta


Find the Rank Models result

Description

Provides the core material to create an S3 object for rank.models

Usage

rank_models_cpp(  data,  model_str,  full_model,  alpha,  compute_v,  model_type,  K,  H,  G,  robust,  eff,  bs_optimism,  seed)

Arguments

data

Avec of data.

model_str

Avector<vector<string>> that gives a list of models to test.

full_model

Avector<string> that contains the largest / full model.

alpha

Adouble that indicates the alpha level for CIs.

compute_v

Astring indicating the type of V matrix to generate

model_type

Astring that describes the model generation / transformation: 'ssm' or 'imu'

K

Aint that controls how many times the GMWM is run.

H

Aint that controls how many bootstraps occur.

G

Aint that controls how many guesses occur.

robust

Abool that indicates whether to use classical or robust wavelet variance.

eff

Adouble that indicates the efficiency to use.

bs_optimism

Abool that indicates whether the model selection score should be calculated with bootstrap or asymptotics.

seed

Aunsigned int that is the seed one wishes to use.

Value

Afield<field<field<mat>>> that contains the model score matrix and the best GMWM model object.


Read an IMU Binary File into R

Description

Process binary files within the

Usage

read.imu(file, type, unit = NULL, name = NULL)

Arguments

file

Astring containing file names or paths.

type

Astring that contains a supported IMU type given below.

unit

Astring that contains the unit expression of the frequency. Default value isNULL.

name

Astring that provides an identifier to the data. Default value isNULL.

Details

Currently supports the following IMUs:

Value

Animu object that contains 3 gyroscopes and 3 accelerometers in that order.

Author(s)

James BalamutaWe hope to soon be able to support delimited files.

References

Thanks goes to Philipp Clausen of Labo TOPO, EPFL, Switzerland, topo.epfl.ch, Tel:+41(0)21 693 27 55for providing a matlab function that reads in IMUs.This function is a heavily modified port of MATLAB code into Armadillo/C++.

Examples

## Not run: # Relativesetwd("F:/")a = read.imu(file = "Documents/James/short_test_data.imu", type = "IXSEA")# Fixed pathb = read.imu(file = "F:/Desktop/short_test_data.imu", type = "IXSEA")## End(Not run)

Read an IMU Binary File into R

Description

The function will take a file location in addition to the type of sensor itcame from and read the data into R.

Usage

read_imu(file_path, imu_type)

Arguments

file_path

Astring that contains the full file path.

imu_type

Astring that contains a supported IMU type given below.

Details

Currently supports the following IMUs:

We hope to soon be able to support delimited files.

Value

A matrix with dimensions N x 7, where the columns represent:

Col 0

Time

Col 1

Gyro 1

Col 2

Gyro 2

Col 3

Gyro 3

Col 4

Accel 1

Col 5

Accel 2

Col 6

Accel 3

References

Thanks goes to Philipp Clausen of Labo TOPO, EPFL, Switzerland, topo.epfl.ch, Tel:+41(0)21 693 27 55for providing a matlab function that reads in IMUs.The function below is a heavily modified port of MATLAB code into Armadillo/C++.


Plot the Distribution of (Standardized) Residuals

Description

This function plots a histogram (with kernel density function and normal distribution) of the standardizedresiduals or a basic plot the (standardized) residuals, or both.

Usage

resid_plot(res, std = FALSE, type = "hist", ...)

Arguments

res

Avector of residuals.

std

Aboolean indicating whether the residuals plot is for standardizedresiduals or original residuals.

type

Astring indicating either:"hist" (standardized residual histogram with superimposed kernel density estimator and normal distribution),"resid" (standard residual plot),or"both"

...

Additional parameters

Author(s)

Yuming Zhang


Reverse Subset Column

Description

Subsets the column by going from high indices to low (the reverse of the supported practice)

Usage

rev_col_subset(x, start, end)

Arguments

x

Amatrix of dimensions M x N

start

Aunsigned int that indicates the starting column.

end

Aunsigned int that indicates the ending column.

Details

Consider a vector x=[[1,2],[3,4]].By settingstart=1 andend=0, the function would output x=[[2,1],[4,1]].Start and end must be valid C++ matrix locations. (e.g. matrix cols start at 0 and not 1)

Value

x Amatrix with matrix rows displayed in reverse order

Author(s)

JJB


Reverse Subset Row

Description

Subsets the row by going from high indices to low (the reverse of the supported practice)

Usage

rev_row_subset(x, start, end)

Arguments

x

Amatrix of dimensions M x N

start

Aunsigned int that indicates the starting row.

end

Aunsigned int that indicates the ending row.

Details

Consider a vector x=[[1,2],[3,4]], the function would output x=[[3,4],[1,2]].Start and end must be valid C++ matrix locations. (e.g. matrix rows start at 0 and not 1)

Value

x Amatrix with matrix rows displayed in reversed order

Author(s)

JJB


Reverse Armadillo Vector

Description

Reverses the order of an Armadillo Vector

Usage

reverse_vec(x)

Arguments

x

Acolumn vector of length N

Details

Consider a vector x=[1,2,3,4,5], the function would output x=[5,4,3,2,1].

Value

x Acolumn vector with its contents reversed.

Author(s)

JJB


Time Series Recursive Filters

Description

Applies a recursive filter to a univariate time series.

Usage

rfilter(x, filter, init)

Arguments

x

Acolumn vector of length T

filter

Acolumn vector of length f

init

Acolumn vector of length f that contains the initial values of the time series in reverse.

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 Acolumn vector with its contents reversed.

Author(s)

JJB


GMWM for Robust/Classical Comparison

Description

Creates argmwm object to compare the results generated by robust/classical method.

Usage

rgmwm(model, data, eff = c(0.9, 0.8, 0.6), ...)

Arguments

model

Ats.model object containing one of the allowed models.

data

Amatrix ordata.frame object with only one column (e.g.N \times 1), or alts object, or agts object.

eff

Adouble vector between 0 and 1 that indicates the efficiency.

...

Other arguments passed to the maingmwm function.

Details

By default, thergmwm function will fit a classicalgmwmobject. From there, the user has the ability to specify anyeff that isless than or equal to 0.99.

Value

Argmwm object


Truncated Normal Distribution Sampling Algorithm

Description

Enables sampling from a truncated normal

Usage

rtruncated_normal(n, mu, sigma, a, b)

Arguments

n

Anunsigned int indicating the number of observations to generate.

mu

Adouble indicating the mean of the normal.

sigma

Adouble indicating the standard deviation of the normal.

a

Adouble that is the lower bound of the truncated normal.

b

Adouble that is the upper bound of the truncated normal.


Random Walk to WV

Description

This function compute the WV (haar) of a Random Walk process

Usage

rw_to_wv(gamma2, tau)

Arguments

gamma2

Adouble corresponding to variance of RW

tau

Avec containing the scales e.g.2^{\tau}

Value

Avec 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

Anunsigned int containing the number of non-seasonal phi parameters.

nq

Anunsigned int containing the number of non-seasonal theta parameters.

nsp

Anunsigned int containing the number of seasonal phi parameters.

nsq

Anunsigned int containing the number of seasonal theta parameters.

Value

Avec with rows:

p

Number of phi parameters

q

Number of theta parameters


Determine parameter expansion based upon objdesc

Description

Calculates the necessary vec space needed to pad the vectorsfor seasonal terms.

Usage

sarma_components(objdesc)

Arguments

objdesc

Avec with the appropriate sarima object description

Value

Avec 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

Avec containing the theta values of the parameters.

objdesc

Avec containing the model term information.

Details

Theobjdesc is assumed to have the structure of:

Value

Afield<vec> of size two as follows:


(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

Avec containing the theta values of the parameters.

np

Anunsigned int containing the number of non-seasonal phi parameters.

nq

Anunsigned int containing the number of non-seasonal theta parameters.

nsp

Anunsigned int containing the number of seasonal phi parameters.

nsq

Anunsigned int containing the number of seasonal theta parameters.

p

Anunsigned int that is the total size of the phi vector.

q

Anunsigned int that is the total size of the theta vector.

Value

Afield<vec> that contains the expansion.


Efficient way to merge items together

Description

Efficient way to merge items together

Usage

sarma_params_construct(ar, ma, sar, sma)

Personal Saving Rate

Description

Personal saving as a percentage of disposable personalincome (DPI), frequently referred to as "the personal saving rate,"is calculated as the ratio of personal saving to DPI.

Usage

savingrt

Format

A gts time series object with frequency 12 starting at 1959 and goingto 2016 for a total of 691 observations.

Source

https://fred.stlouisfed.org/series/PSAVERT


Computes the MODWT scales

Description

Calculates the MODWT scales

Usage

scales_cpp(nb_level)

Arguments

nb_level

Ainteger that contains the level of decomposition J.

Details

Used in wvar object.

Value

Avec that contains 2^1, ... , 2^J


Time Series Model Selection

Description

This function performs model fitting and calculates the model selection criteria to be plotted.

Usage

select(model, Xt, include.mean = TRUE, criterion = "aic", plot = TRUE)

Arguments

model

A time series model (only ARIMA are currently supported).

Xt

Avector of time series data.

include.mean

Aboolean indicating whether to fit ARIMA with the mean or not.

criterion

Astring indicating which model selection criterion should be used (possible values:"aic" (default),"bic","hq").

plot

Aboolean indicating whether a model selection plot is returned or not.

Author(s)

Stéphane Guerrier and Yuming Zhang

Examples

set.seed(763)Xt = gen_gts(100, AR(phi = c(0.2, -0.5, 0.4), sigma2 = 1))select(AR(5), Xt, include.mean = FALSE)Xt = gen_gts(100, MA(theta = c(0.2, -0.5, 0.4), sigma2 = 1))select(MA(5), Xt, include.mean = FALSE)Xt = gen_gts(500, ARMA(ar = 0.5, ma = c(0.5, -0.5, 0.4), sigma2 = 1))select(ARMA(5,3), Xt, criterion = "hq", include.mean = FALSE)

Run Model Selection Criteria on ARIMA Models

Description

This function performs model fitting and calculates the model selection criteria to be plotted or used inbest_model function.

Usage

select_arima(  xt,  p.min = 0L,  p.max = 3L,  d = 0L,  q.min = 0L,  q.max = 3L,  include.mean = TRUE,  plot = TRUE)select_arma(  xt,  p.min = 0L,  p.max = 3L,  q.min = 0L,  q.max = 3L,  include.mean = TRUE,  plot = TRUE)select_ar(xt, p.min = 0L, p.max = 3L, include.mean = TRUE, plot = TRUE)select_ma(xt, q.min = 0L, q.max = 3L, include.mean = TRUE, plot = TRUE)

Arguments

xt

Avector of univariate time series.

p.min

Aninteger indicating the lowest order of AR(p) process to search.

p.max

Aninteger indicating the highest order of AR(p) process to search.

d

Aninteger indicating the differencing order for the data.

q.min

Aninteger indicating the lowest order of MA(q) process to search.

q.max

Aninteger indicating the highest order of MA(q) process to search.

include.mean

Abool indicating whether to fit ARIMA with the mean or not.

plot

Alogical. IfTRUE (the default) a plot should be produced.

Examples

xt = gen_arima(N=100, ar=0.3, d=1, ma=0.3)x = select_arima(xt, d=1L)xt = gen_ma1(100, 0.3, 1)x = select_ma(xt, q.min=2L, q.max=5L)best_model(x)xt = gen_arma(10, c(.4,.5), c(.1), 1, 0)  x = select_arma(xt, p.min = 1L, p.max = 4L,                q.min = 1L, q.max = 3L)

Select the Wavelet Filter

Description

Constructs the wavelet filter to be used.

Usage

select_filter(filter_name)

Arguments

filter_name

AString that must receive:"haar".

Details

The package is oriented toward using only the haar filter. If the package extends at a later time, then the supporting infrastructure is there.

Value

info Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


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

Anint, that denotes the starting point.

b

Anint, that denotes the ending point.

Value

Avector 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

Anint that denotes the length of the vector.

Value

Avector containing values moving from 1 to n.

Author(s)

James J Balamuta


Set the RNG Seed from within Rcpp

Description

Within Rcpp, one can set the R session seed without triggeringthe CRAN rng modifier check.

Usage

set_seed(seed)

Arguments

seed

Aunsigned int that is the seed one wishes to use.

Value

A set RNG scope.


Basic Diagnostic Plot of Residuals

Description

This function will plot four diagnostic plots to assess how well the model fits the data. These plots are: (1) residuals plot, (2) histogram of (standardized) residuals, (3) normal Q-Q plot of residuals and (4) residuals vs fitted values plot.

Usage

simple_diag_plot(Xt, model, std = FALSE)

Arguments

Xt

The original time series data.

model

Thearima model fit to the data.

std

Aboolean indicating whether we use standardized residuals for the (1) residuals plot and the (2) histogram of (standardized) residuals.

Author(s)

Yuming Zhang


Simplify and print SARIMA model

Description

Simplify and print SARIMA model

Usage

simplified_print_SARIMA(p, i, q, P, si, Q, s)

Arguments

p

Aninteger denoting the length ofar.

i

Aninteger containing the number of differences to be done.

q

Aninteger denoting the length ofma.

P

Aninteger denoting the length ofsma.

si

Aninteger containing the number of seasonal differences to be done.

Q

Aninteger denoting the length ofsar.

s

Aninteger indicating the seasonal value of the data.

Value

An S3 object with the following structure:

print

String containing simplified model

simplified

Type of model (after simplification)

Author(s)

Stephane Guerrier


Sort Matrix by Column

Description

Sorts a given matrix by a specific column while retain the elements in each row.

Usage

sort_mat(x, col)

Arguments

x

Amatrix to sort

col

Aint that indicates the column the matrix should sort by.

Details

The functional difference between armadillo's sort() and sort_mat() is straight forward.sort() will sort each column without respect to the rows. Using sort_matrix will sort only 1 column and retain the other elements to be in the same row.

Value

The matrix sorted by values in the specified column.


Accumulation of Armadillo field<vec>

Description

Sums vectors in a field into a single variable.

Usage

sum_field_vec(x)

Arguments

x

Afield<vec>.

Value

Anmat containing the field elements within a column.

Author(s)

JJB


Summary of fitsimts object

Description

Displays summary information about fitsimts object

Usage

## S3 method for class 'fitsimts'summary(object, ...)

Arguments

object

Afitsimts object

...

Other arguments passed to specific methods

Value

Estimated parameters values with confidence intervals and standard errors.

Author(s)

Stéphane Guerrier


Summary of GMWM object

Description

Displays summary information about GMWM object

Usage

## S3 method for class 'gmwm'summary(  object,  inference = NULL,  bs.gof = NULL,  bs.gof.p.ci = NULL,  bs.theta.est = NULL,  bs.ci = NULL,  B = 100,  ...)

Arguments

object

AGMWM object

inference

A value containing either: NULL (auto), TRUE, or FALSE

bs.gof

A value containing either: NULL (auto), TRUE, FALSE

bs.gof.p.ci

A value containing either: NULL (auto), TRUE, FALSE

bs.theta.est

A value containing either: NULL (auto), TRUE, FALSE

bs.ci

A value containing either: NULL (auto), TRUE, FALSE

B

Anint that indicates how many bootstraps should be performed.

...

Other arguments passed to specific methods

Value

Asummary.gmwm object with:

estimate

Estimated Theta Values

testinfo

Goodness of Fit Information

inference

Inference performed? T/F

bs.gof

Bootstrap GOF? T/F

bs.gof.p.ci

Bootstrap GOF P-Value CI? T/F

bs.theta.est

Bootstrap Theta Estimates? T/F

bs.ci

Bootstrap CI? T/F

starting

Indicates if program supplied initial starting values

seed

Seed used during guessing / bootstrapping

obj.fun

Value of obj.fun at minimized theta

N

Length of Time Series

Author(s)

JJB


Theoretical Autocorrelation (ACF) of an ARMA process

Description

This function computes the theoretical Autocorrelation (ACF) of an ARMA process.

Usage

theo_acf(ar, ma = NULL, lagmax = 20)

Arguments

ar

Avector containing the AR coefficients.

ma

Avector containing the MA coefficients.

lagmax

Aninteger indicating the maximum lag up to which to compute the theoretical ACF.

Author(s)

Yuming Zhang

Examples

# Compute the theoretical ACF for an ARMA(1,0) (i.e. a first-order autoregressive model: AR(1))theo_acf(ar = -0.25, ma = NULL)# Computes the theoretical ACF for an ARMA(2, 1)theo_acf(ar = c(.50, -0.25), ma = 0.20, lagmax = 10)

Theoretical Partial Autocorrelation (PACF) of an ARMA process

Description

This function computes the theoretical Partial Autocorrelation (PACF) of an ARMA process.

Usage

theo_pacf(ar, ma = NULL, lagmax = 20)

Arguments

ar

Avector containing the AR coefficients.

ma

Avector containing the MA coefficients.

lagmax

Aninteger indicating the maximum lag up to which to compute the theoretical PACF.

Author(s)

Yuming Zhang

Examples

# Computes the theoretical ACF for an ARMA(1,0) (i.e. a first-order autoregressive model: AR(1))theo_pacf(ar = -0.25, ma = NULL, lagmax = 7)# Computes the theoretical ACF for an ARMA(2, 1)theo_pacf(ar = c(.50, -0.25), ma = .20, lagmax = 10)

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

Avec containing the list of estimated parameters.

desc

Avector<string> containing a list of descriptors.

objdesc

Afield<vec> containing a list of object descriptors.

tau

Avec containing the scales e.g.2^{\tau}

Value

Avec containing the wavelet variance of the model.


Generate the Confidence Interval for Theta Estimates

Description

Create an Asymptotic CI for the Theta Estimates.

Usage

theta_ci(theta, A, v_hat, omega, alpha)

Arguments

theta

Avec containing the estimates

A

Amat that is the first derivative matrix.

v_hat

Amat that is the bootstrapped V matrix

omega

Amat that is the inverse of the diagonal V matrix.

alpha

Adouble that contains the confidence level.

Value

Amat that has the first column


Transform Values for Optimization

Description

Transform parameter guesses prior to estimating with GMWM

Usage

transform_values(theta, desc, objdesc, model_type)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that contains the model type:"imu" or"ssm"

Value

Avec containing the transformed guesses.

Author(s)

James Joseph Balamuta (JJB)


Convert Unit of Time Series Data

Description

Manipulate the units of time to different ones

Usage

unitConversion(x, from.unit, to.unit)

Arguments

x

Avector containing the values on x-axis.

from.unit

Astring indicating the unit which the data is converted from.

to.unit

Astring indicating the unit which the data is converted to.

Details

The supported units are "ns"(nanosecond), "ms"(millisecond), "sec", "min", "hour", "day", "month", and "year".Make surefrom.unit andto.unit are notNULL before it is passed to this function.

Value

Alist with the following structure:

x

Data

converted

Aboolean indicating whether conversion is made

Examples

x = seq(60, 3600, 60)unitConversion(x, 'sec', 'min')y = 1:10unitConversion(y, 'hour', 'sec')

Revert Transform Values for Display

Description

Undo the previous transform of parameter guesses to obtain the GMWM estimates.

Usage

untransform_values(theta, desc, objdesc, model_type)

Arguments

theta

Avec with dimensions N x 1 that contains user-supplied initial values for parameters

desc

Avector<string> indicating the models that should be considered.

objdesc

Afield<vec> containing a list of parameters (e.g. AR(1) = c(1,1), ARMA(p,q) = c(p,q,1))

model_type

Astring that contains the model type:"imu" or"ssm"

Value

Avec containing the undone transformation of parameters.

Author(s)

James Joseph Balamuta (JJB)


Update (Robust) GMWM object for IMU or SSM

Description

Provides a way to estimate different models over the previously estimatedwavelet variance values and covariance matrix.

Usage

## S3 method for class 'gmwm'update(object, model, ...)

Arguments

object

Agmwm object.

model

Ats.model object containing one of the allowed models

...

Additional parameters (not used)

Value

Agmwm object with the structure:

estimate

Estimated Parameters Values from the GMWM Procedure

init.guess

Initial Starting Values given to the Optimization Algorithm

wv.empir

The data's empirical wavelet variance

ci_low

Lower Confidence Interval

ci_high

Upper Confidence Interval

orgV

Original V matrix

V

Updated V matrix (if bootstrapped)

omega

The V matrix inversed

obj.fun

Value of the objective function at Estimated Parameter Values

theo

Summed Theoretical Wavelet Variance

decomp.theo

Decomposed Theoretical Wavelet Variance by Process

scales

Scales of the GMWM Object

robust

Indicates if parameter estimation was done under robust or classical

eff

Level of efficiency of robust estimation

model.type

Models being guessed

compute.v

Type of V matrix computation

augmented

Indicates moments have been augmented

alpha

Alpha level used to generate confidence intervals

expect.diff

Mean of the First Difference of the Signal

N

Length of the Signal

G

Number of Guesses Performed

H

Number of Bootstrap replications

K

Number of V matrix bootstraps

model

ts.model supplied to gmwm

model.hat

A new value ofts.model object supplied to gmwm

starting

Indicates whether the procedure used the initial guessing approach

seed

Randomization seed used to generate the guessing values

freq

Frequency of data


Update Object Attribute

Description

Update the attributes oflts,gts andimu object

Usage

## S3 method for class 'lts'update(object, type, new, keep.start = T, ...)## S3 method for class 'gts'update(object, type, new, keep.start = T, ...)## S3 method for class 'imu'update(object, type, new, ...)

Arguments

object

Alts,gts orimu object

type

Astring that contains the attribute to be updated

new

The updated value for the attribute

keep.start

Aboolean value that indicates whether 'start' or 'end' should remain the same when 'freq' is updated

...

Further arguments passed to or from other methods.

Details

This function is able to update some attributes forgts,lts andimu objects. Forlts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit_time', 'name_ts' and 'process'.Forgts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit_time' and 'name_ts'.Forimu object, the attributes that can be updated are 'axis', 'freq', 'unit_time' and 'name_ts'.

If one between 'start' and 'end' is updated, the other one will also be updated, sinceend-start == (N-1)/freq must be TRUE, whereNis the number of observations in the object.

If 'freq' is updated, by default 'start' will remain the same, and 'end' will be updated at the same time,unless you set 'keep.start = F'.

If 'unit_time' is updated, the old unit_time will be replaced by the new one, and other attributes will remain the same.It is different from the unit_time conversion feature.

Value

An object with the updated attribute.

Examples

gts1 = gts(rnorm(50), freq = 1, unit_time = 'sec', name_ts = 'test1')gts2 = update(gts1, 'unit_time', 'min')attr(gts2, 'unit_time')gts3 = update(gts1, 'name_ts', 'test2')attr(gts3, 'name_ts')

Update the Attributes of Objects

Description

Internal Function to Update the Attributes of Objects

Usage

update_obj(object, type, new, keep.start = T)

Arguments

object

Alts,gts orimu object

type

Astring that contains the attribute to be updated

new

The updated value for the attribute

keep.start

Aboolean value that indicates whether 'start' or 'end' should remain the same when 'freq' is updated

Value

An object with the updated attribute.


Obtain the value of an object's properties

Description

Used to access different properties of thegts,imu, orlts object.

Usage

value(x, type)## S3 method for class 'imu'value(x, type)

Arguments

x

Agts,imu, orlts object.

type

Astring indicating the field to be retrieved.

Details

To access information aboutimu properties use:

"accel"

Returns the number of accelerometers

"gyro"

Returns the number of gyroscopes

"sensors"

Returns total number of sensors

Value

The method will return a single numeric or string result depending on theslot being accessed.

Methods (by class)

Author(s)

James Balamuta


Variance DR

Description

This function computes the variance of a drift process.

Usage

var_drift(omega, n_ts)

Arguments

omega

Adouble corresponding to variance of drift.

n_ts

Anint indicating the length of the time series.

Value

Avec containing the variance of the drift.


Conversion function of Vector to Set

Description

Converts a vector into a set

Usage

vector_to_set(model_str)

Value

Aset<vector<string>> that contains the list of unique models.


w4 filter construction

Description

Creates the w4 filter

Usage

w4_filter()

Details

This template can be used to increase the amount of filters available for selection.

Value

Afield<vec> that contains:

"L"

Ainteger specifying the length of the filter

"h"

Avector containing the coefficients for the wavelet filter

"g"

Avector containing the coefficients for the scaling filter

Author(s)

JJB


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

Afield<vec> that contains the brick walled modwt or dwt decomposition

robust

Aboolean to determine the type of wave estimation.

eff

Adouble that indicates the efficiency.

Value

Avec that contains the wave variance.


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

Adouble corresponding to variance of WN

tau

Avec containing the scales e.g.2^{\tau}

Value

Avec 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}}


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

Afield<vec> that contains the modwt decomposition after it has been brick walled.

robust

Aboolean that triggers the use of the robust estimate.

eff

Adouble that indicates the efficiency as it relates to an MLE.

alpha

Adouble that indicates the\left(1-p\right)*\alpha confidence level

ci_type

AString indicating the confidence interval being calculated. Valid value: "eta3"

Details

This function does the heavy lifting with the signal_modwt_bw

Value

Amat with the structure:

"variance"

Wavelet Variance

"low"

Lower CI

"high"

Upper CI


[8]ページ先頭

©2009-2025 Movatter.jp