Type: Package
Title: Time Series Analysis Tools
Version: 0.2.2
Date: 2023-09-29
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.2.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: 2023-08-31 11:13:12 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: 2023-08-31 12:40:02 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 Guerrier stef.guerrier@gmail.com [copyright holder]

Authors:

Other contributors:

James Balamuta balamut2@illinois.edu, Stephane Guerrier stef.guerrier@gmail.com, Roberto Molinari roberto.molinari@hotmail.it, Wenchao Yang wyang40@illinois.edu Justin Lee munsheet93@gmail.com Yuming Zhang yuming.zhang@unige.ch

See Also

Useful links:

Useful links:


Auto-Covariance and Correlation Functions

Description

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

Usage

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

Arguments

x

A matrix with dimensions N \times S or N observations and S processes

lagmax

A integer

cor

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

demean

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


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

A imu object

i

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

j

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

drop

A boolean 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

An imu 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 Y
ex.b = ex[,c(1,2,4,5)]
ex.b2 = ex[,c("Gyro. X","Gyro. Y","Accel. X","Accel. Y")]


## End(Not run)


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

A numeric value

y

A ts.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()*2
AR1(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

A ts.model object

y

A ts.model object

Value

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

Author(s)

James Balamuta

Examples

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

Helper Function for ARMA to WV Approximation

Description

Indicates where the minimum ARMAacf value is and returns that as an index.

Usage

acf_sum(ar, ma, last_tau, alpha = 0.99)

Arguments

ar

A vec containing the coefficients of the AR process

ma

A vec containing the coefficients of the MA process

last_tau

An int the Jth scale of 2^(1:J)

alpha

A double indicating the cutoff.

Value

A vec containing the wavelet variance of the ARMA process.


Akaike's Information Criterion

Description

This function calculates AIC, BIC or HQ for a fitsimts object. This function currently only 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 = 300
Xt = gen_gts(n, AR(phi = c(0, 0, 0.8), sigma2 = 1))
mod = estimate(AR(3), Xt)

# AIC
AIC(mod)

# BIC
AIC(mod, k = log(n))

# HQ
AIC(mod, k = 2*log(log(n)))

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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

Details

Expand in detail...

Value

A vec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


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

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

sigma2

A double 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

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

sigma2

A double 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)

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

An unsigned int that contains the draw principles.

last_phi

A double containing the last guessed phi value.

sigma2_total

A double that contains the sum of all WVs.

model_type

A string that describes the model transformation.

Value

A vec 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

A vec that contains AR1 values.

freq

A double indicating the frequency of the data.

Details

The function takes a vector of AR1 values \phi and \sigma ^2 and 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

A vec 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

A double that is the phi term of the AR(1) process

sigma2

A double corresponding to variance of AR(1) process

tau

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

Details

This function is significantly faster than its generalized counter part arma_to_wv.

Value

A vec containing the wavelet variance of the AR(1) process.

Process Haar Wavelet Variance Formula

The Autoregressive Order 1 (AR(1)) process has a Haar Wavelet Variance given by:

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


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

A vector or integer containing either the coefficients for \phi's or the process number p for the Autoregressive (AR) term.

i

An integer containing the number of differences to be done.

ma

A vector or integer containing either the coefficients for \theta's or the process number q for the Moving Average (MA) term.

sigma2

A double 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) process
ARIMA(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 deviation
ARIMA(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

A vector or integer containing either the coefficients for \phi's or the process number p for the Autoregressive (AR) term.

ma

A vector or integer containing either the coefficients for \theta's or the process number q for the Moving Average (MA) term.

sigma2

A double 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) process
ARMA(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 deviation
ARMA(ar=c(0.23,.43, .59), ma=c(0.4,.3), sigma2 = 1.5)

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

A vec that contains all the parameter estimates.

p

A int that indicates the number of AR coefficients

q

A int that indicates the number of MA coefficients.

tau

A vec 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

A vec 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

An unsigned int that contains the amount of AR parameters to generate.

q

An unsigned int that contains the amount of MA parameters to generate.

sigma2_total

A double that contains the sum of all WVs.

Value

A vec 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

A vec containing the coefficients of the AR process

ma

A vec containing the coefficients of the MA process

sigma2

A double containing the residual variance

tau

A vec 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

A vec containing the wavelet variance of the ARMA process.

Process Haar Wavelet Variance Formula

The Autoregressive Order p and Moving Average Order q (ARMA(p,q)) process has a Haar Wavelet Variance given by:

\frac{{{\tau _j}\left[ {1 - \rho \left( {\frac{{{\tau _j}}}{2}} \right)} \right] + 2\sum\limits_{i = 1}^{\frac{{{\tau _j}}}{2} - 1} {i\left[ {2\rho \left( {\frac{{{\tau _j}}}{2} - i} \right) - \rho \left( i \right) - \rho \left( {{\tau _j} - i} \right)} \right]} }}{{\tau _j^2}}\sigma _X^2

where \sigma _X^2 is given by the variance of the ARMA process. Furthermore, this assumes that stationarity has been achieved as it directly


ARMA process to WV Approximation

Description

This function computes the (haar) WV of an ARMA process

Usage

arma_to_wv_app(ar, ma, sigma2, tau, alpha = 0.9999)

Arguments

ar

A vec containing the coefficients of the AR process

ma

A vec containing the coefficients of the MA process

sigma2

A double containing the residual variance

tau

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

alpha

A double indicating the cutoff.

Details

This function provides an approximation to the arma_to_wv as computation times were previously a concern. However, this is no longer the case and, thus, this has been left in for the curious soul to discover...

Value

A vec containing the wavelet variance of the ARMA process.

Process Haar Wavelet Variance Formula

The Autoregressive Order p and Moving Average Order q (ARMA(p,q)) process has a Haar Wavelet Variance given by:

\frac{{{\tau _j}\left[ {1 - \rho \left( {\frac{{{\tau _j}}}{2}} \right)} \right] + 2\sum\limits_{i = 1}^{\frac{{{\tau _j}}}{2} - 1} {i\left[ {2\rho \left( {\frac{{{\tau _j}}}{2} - i} \right) - \rho \left( i \right) - \rho \left( {{\tau _j} - i} \right)} \right]} }}{{\tau _j^2}}\sigma _X^2

where \sigma _X^2 is given by the variance of the ARMA process. Furthermore, this assumes that stationarity has been achieved as it directly


Definition of an ARMA(1,1)

Description

Definition of an ARMA(1,1)

Usage

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

Arguments

phi

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

theta

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

sigma2

A double 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 or FALSE (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()

ARMA(1,1) to WV

Description

This function computes the WV (haar) of an Autoregressive Order 1 - Moving Average Order 1 (ARMA(1,1)) process.

Usage

arma11_to_wv(phi, theta, sigma2, tau)

Arguments

phi

A double corresponding to the autoregressive term.

theta

A double corresponding to the moving average term.

sigma2

A double the variance of the process.

tau

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

Details

This function is significantly faster than its generalized counter part arma_to_wv

Value

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

Process Haar Wavelet Variance Formula

The Autoregressive Order 1 and Moving Average Order 1 (ARMA(1,1)) process has a Haar Wavelet Variance given by:

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


Compute Theoretical ACF for an ARMA Process

Description

Compute the theoretical autocorrelation function for an ARMA process.

Usage

ARMAacf_cpp(ar,ma,lag_max)

Arguments

ar

A vector of length p containing AR coefficients

ma

A vector of length q containing MA coefficients

lag_max

A unsigned 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 A matrix 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

A column vector of length p

ma

A column vector of length q

lag_max

A int 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

A column vector containing coefficients

Author(s)

R Core Team and JJB


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

A vector or ts object (of length N > 1).

lag.max

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

pacf

A boolean indicating whether to output the PACF. If it's TRUE, then the function will only estimate the empirical PACF. If it's FALSE (the default), then the function will only estimate the empirical ACF.

type

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

demean

A boolean indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults to TRUE.

robust

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

Details

lagmax default is 10*log10(N/m) where N is the number of observations and m is the number of time series being compared. If lagmax supplied is greater than the number of observations N, then one less than the total will be taken (i.e. N - 1).

Value

An array of dimensions N \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

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

full_model

A vector<string> that contains the largest / full model.

alpha

A double that indicates the alpha level for CIs.

compute_v

A string indicating the type of V matrix to generate

model_type

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

K

A int that controls how many times the GMWM is run.

H

A int that controls how many bootstraps occur.

G

A int that controls how many guesses occur.

robust

A bool that indicates whether to use classical or robust wavelet variance.

eff

A double that indicates the efficiency to use.

bs_optimism

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

seed

A unsigned int that is the seed one wishes to use.

Value

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


B Matrix

Description

B Matrix

Usage

B_matrix(A, at_omega)

Arguments

A

A mat containing the first derivatives of the process.

at_omega

A mat containing A^T * Omega

Value

A mat


Computes the MO/DWT wavelet variance for multiple processes

Description

Calculates the MO/DWT wavelet variance

Usage

batch_modwt_wvar_cpp(
  signal,
  nlevels,
  robust,
  eff,
  alpha,
  ci_type,
  strWavelet,
  decomp
)

Arguments

signal

A matrix that contains the same number of observations per dataset

robust

A boolean that triggers the use of the robust estimate.

eff

A double that indicates the efficiency as it relates to an MLE.

alpha

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

ci_type

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

strWavelet

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

decomp

A string indicating whether to use "modwt" or "dwt" decomp

Details

This function processes the decomposition of multiple signals quickly

Value

A field<mat> with the structure:


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 class select_arma, select_ar or select_ma.

ic

A string 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

A field<vec> that contains:

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

A field<vec> that contains:

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

A double containing the objective value of the solution.

obj_boot

A vec containing the objective values obtained while bootstrapping under Theta_hat.

B

An int indicating how many times the bootstrapper should be run.

alpha

A double indicating the amount of confidence for CI

Value

A vec 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

A double that contains the optimized objective function value.

bs_obj_values

A vec that contains the objective function values under bootstrap.

alpha

A double that indicates the confidence.

bs_gof_p_ci

A bool that indicates whether CIs should be included or not.

Value

A vec that has


Removal of Boundary Wavelet Coefficients

Description

Removes the first n wavelet coefficients.

Usage

brick_wall(x, wave_filter, method)

Arguments

x

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

wave_filter

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

method

A string 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

A field<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

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

x

A vec<string> that contains a list of model descriptors.

Value

A set<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

A mat 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

A column vector of length T

filter

A column vector of length f

sides

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

circular

A bool 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

A column 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

A fitsimts, lm or gam object.

resids

A vector of residuals for diagnostics.

simple

A boolean 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

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

dims

A String indicating the confidence interval being calculated.

alpha_ov_2

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

Value

A matrix with the structure:


Generate eta3 robust confidence interval

Description

Computes the eta3 robust CI

Usage

ci_eta3_robust(wv_robust, wv_ci_class, alpha_ov_2, eff)

Arguments

wv_robust

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

wv_ci_class

A mat that contains the CI mean, CI Lower, and CI Upper

alpha_ov_2

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

eff

A double that indicates the efficiency.

Details

Within this function we are scaling the classical

Value

A matrix with the structure:


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

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

wv

A vec that contains the wave variance.

type

A String indicating the confidence interval being calculated.

alpha_ov_2

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

robust

A boolean to determine the type of wave estimation.

eff

A double that indicates the efficiency.

Details

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

Value

A matrix with the structure:


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

A vec that contains estimated GMWM theta values (untransformed).

Value

A vec 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 ACF of univariate time series.

Usage

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

Arguments

x

A vector or "ts" object (of length N > 1).

lag.max

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

demean

A bool indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults to TRUE.

show.ci

A bool indicating whether to compute and show the confidence region. Defaults to TRUE.

alpha

A double indicating the level of significance for the confidence interval. By default alpha = 0.05 which gives a 1 - alpha = 0.95 confidence interval.

plot

A bool indicating whether a plot of the computed quantities should be produced. Defaults to TRUE.

...

Additional parameters.

Author(s)

Yunxiang Zhang

Examples

# Estimate both the ACF and PACF functions
compare_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

A field<vec> that contains the modwt decomposition.

nb_level

A integer that contains the level of decomposition J.

compute_v

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

robust

A boolean that triggers the use of the robust estimate.

eff

A double that indicates the efficiency as it relates to an MLE.

Value

A field<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

A numeric vector containing the theta values

process.desc

A character vector containing the names of parameters.

freq

A double indicating the frequency of the data.

Author(s)

James Balamuta


Correlation Analysis Functions

Description

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

Usage

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

Arguments

x

A vector or "ts" object (of length N > 1).

lag.max

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

type

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

demean

A bool indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults to TRUE.

show.ci

A bool indicating whether to compute and show the confidence region. Defaults to TRUE.

alpha

A double indicating the level of significance for the confidence interval. By default alpha = 0.05 which gives a 1 - alpha = 0.95 confidence interval.

plot

A bool indicating whether a plot of the computed quantities should be produced. Defaults to TRUE.

...

Additional parameters.

Value

Two array objects (ACF and PACF) of dimension N \times S \times S.

Author(s)

Yunxiang Zhang

Examples

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

Count Models

Description

Count the amount of models that exist.

Usage

count_models(desc)

Arguments

desc

A vector<string> that contains the model's components.

Value

A map<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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

Details

Expand in detail...

Value

A vec 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

A matrix with dimensions N x length(index)

ngyros

An integer containing the number of gyroscopes

nacces

An integer containing the number of accelerometers

axis

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

freq

An integer that provides the frequency for the data.

unit

A string that contains the unit expression of the frequency. Default value is NULL.

name

A string that provides an identifier to the data. Default value is NULL.

stype

A string that describes the sensor type. Default value is NULL.

Value

An imu object class.

Author(s)

James Balamuta


Custom legend function

Description

Legend placement function

Usage

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

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

A vec containing the list of estimated parameters.

desc

A vector<string> containing a list of descriptors.

objdesc

A field<vec> containing a list of object descriptors.

tau

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

omegadiff

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

Details

Function returns the matrix effectively known as "D"

Value

A matrix with the process derivatives going down the column

Author(s)

James Joseph Balamuta (JJB)


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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A vec containing the list of estimated parameters.

desc

A vector<string> containing a list of descriptors.

objdesc

A field<vec> containing a list of object descriptors.

tau

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

Value

A mat containing the wavelet variance of each process in the model


Decomposed WV to Single WV

Description

This function computes the combined processes to WV (haar) in a given model.

Usage

decomp_to_theo_wv(decomp)

Arguments

decomp

A mat with scales as rows and processes as columns

Value

A vec 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

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

sigma2

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

tau

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

Value

A matrix with the first column containing the second partial derivative with respect to \phi and the 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

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

theta

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

sigma2

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

tau

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

Value

A matrix 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

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

Value

A matrix 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

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

sigma2

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

tau

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

Value

A matrix 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

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

sigma2

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

tau

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

Value

A matrix 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

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

theta

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

sigma2

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

tau

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

Value

A matrix 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

A double that is the slope of the drift.

tau

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

Value

A matrix 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 \omega relates 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

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

sigma2

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

tau

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

Value

A matrix with the first column containing the partial derivative with respect to \theta and 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

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

Value

A matrix with the first column containing the partial derivative with respect to Q^2.

Process Haar WV First Derivative

Taking the derivative with respect to Q^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

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

Value

A matrix with the first column containing the 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

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

Value

A matrix 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

A vec containing the list of estimated parameters.

desc

A vector<string> containing a list of descriptors.

objdesc

A field<vec> containing a list of object descriptors.

tau

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

Details

Function returns the matrix effectively known as "D"

Value

A matrix 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

A character 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

A cx_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

A vec containing the ACF.


Box-Pierce

Description

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

Usage

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

Arguments

x

An arima or data set.

order

An integer indicating the degrees of freedom. If 'x' is not a series of residuals, then set equal to 0.

stop_lag

An integer indicating the length of lags that should be calculated.

stdres

A boolean indicating whether to standardize the residualizes (e.g. res/sd(res)) or not.

plot

A logical. If TRUE (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 Independence in a Time Series

Usage

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

Arguments

x

An arima or data set.

order

An integer indicating the degrees of freedom. If 'x' is not a series of residuals, then set equal to 0.

stop_lag

An integer indicating the length of lags that should be calculated.

stdres

A boolean indicating whether to standardize the residualizes (e.g. res/sd(res)) or not.

plot

A logical. If TRUE (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

A fitsimts, lm or gam object.

resids

A vector of residuals for diagnostics.

std

A boolean 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 Independence in a Time Series

Usage

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

Arguments

x

An arima or data set.

order

An integer indicating the degrees of freedom. If 'x' is not a series of residuals, then set equal to 0.

stop_lag

An integer indicating the length of lags that should be calculated.

stdres

A boolean indicating whether to standardize the residualizes (e.g. res/sd(res)) or not.

test

A string indicating whether to perform Ljung-Box test or Box-Pierce test.

plot

A logical. If TRUE (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

A vec that is the time series

lag

A unsigned int that indicates the lag

differences

A dif that indicates how many differences should be taken

Value

A vector containing the differenced time series.

Author(s)

JJB


Root Finding C++

Description

Used to interface with Armadillo

Usage

do_polyroot_arma(z)

Arguments

z

A cx_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

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


Create an Drift (DR) Process

Description

Sets up the necessary backend for the DR process.

Usage

DR(omega = NULL)

Arguments

omega

A double 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)

Drift to WV

Description

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

Usage

dr_to_wv(omega, tau)

Arguments

omega

A double corresponding to the slope of the drift

tau

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

Value

A vec containing the wavelet variance of the drift.

Process Haar Wavelet Variance Formula

The Drift (DR) process has a Haar Wavelet Variance given by:

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


Discrete Wavelet Transform

Description

Calculation of the coefficients for the discrete wavelet transformation.

Usage

dwt_cpp(x, filter_name, nlevels, boundary, brickwall)

Arguments

x

A vector with dimensions N\times 1.

filter_name

A string indicating the filter.

nlevels

An integer, J, indicating the level of the decomposition.

boundary

A string indicating the type of boundary method to use. Either boundary="periodic" or "reflection".

brickwall

A bool 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 A field<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

A double corresponding to variance of drift.

n_ts

An int indicating the length of the time series.

Value

A vec 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

A vector of time series data.

method

A string indicating the method used for model fitting. Supported methods include mle, yule-walker, gmwm and rgmwm.

demean

A boolean 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 series models. 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

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

demean

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

print

logical. If TRUE (the default) results are printed.

Value

AIC, BIC and HQ or MAPE

Author(s)

Stéphane Guerrier

Examples

set.seed(18)
n = 300
Xt = 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

A vec that contains the upper confidence interval points.

ci_lo

A vec that contains the lower confidence interval points.

Value

A diagonal matrix.


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

A double.

H

A double.

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)

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

A field<vec>.

Value

A mat 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

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

Value

A vector<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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A vec containing the estimates

se

A vec containing the standard error

alpha

A double that contains the confidence level.

Value

A mat 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

An unsigned integer for signal length.

phi

A double that contains autocorrection.

sigma2

A double that contains process variance.

Details

The function implements a way to generate the AR(1)'s x_t values without calling the general ARMA function. Thus, the function is able to generate values much faster than gen_arma.

Value

A vec 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 length N+1 using gen_wn and then obtains the autoregressive values under the above process definition.

The X_0 (first value of X_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

A double value for the autocorrection parameter \phi.

sigma2

A double value for the variance parameter \sigma ^2.

n_total

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

n_block

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

scale

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

title

A string indicating the name of the time series data.

seed

An integer defined for simulation replication purposes.

...

Additional parameters.

Value

A vector 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), Integrated d, Moving Average Coefficients (\theta), and \sigma^2.

Usage

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

Arguments

N

An integer for signal length.

ar

A vec that contains the AR coefficients.

d

An integer that indicates a difference.

ma

A vec that contains the MA coefficients.

sigma2

A double that contains process variance.

n_start

An unsigned 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

A vec that contains the generated observations.

Warning

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


Generate Autoregressive Order p - Moving Average Order q (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

An integer for signal length.

ar

A vec that contains the AR coefficients.

ma

A vec that contains the MA coefficients.

sigma2

A double that contains process variance.

n_start

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

Details

For AR(1), MA(1), and ARMA(1,1) please use their functions if speed is important as this function is designed to generate generic ARMA processes.

Value

A vec that contains the generated observations.

Process Definition

The Autoregressive order p and Moving Average order q (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

An integer for signal length.

phi

A double that contains autoregressive.

theta

A double that contains moving average.

sigma2

A double that contains process variance.

Details

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

Value

A vec 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 using gen_wn and then obtains the ARMA values under the above equation.

The X_0 (first value of X_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

A double value for the variance parameter \sigma ^2.

n_total

An integer indicating the length of the simulated bias-instability process.

n_block

An integer indicating the length of each block of the bias-instability process.

title

A string defining the name of the time series data.

seed

An integer defined for simulation replication purposes.

...

Additional parameters.

Value

A vector containing the bias-instability process.

Note

This function generates a non-stationary bias-instability process whose theoretical maximum overlapping allan variance (MOAV) is close to the theoretical MOAV 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

An integer for signal length.

omega

A double that contains drift slope

Value

A vec 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 a vector with the \omega parameter. After, we take the cumulative sum along the vector.


Generate a Fractional Gaussian noise given \sigma^2 and H.

Description

Simulates a Fractional Gaussian noise given \sigma^2 and H.

Usage

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

Arguments

N

An integer for signal length.

sigma2

A double.

H

A double.

Value

fgn A vec 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

An integer for signal length.

theta_values

A vec containing the parameters for (S)AR and (S)MA.

objdesc

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

sigma2

A double that contains process variance.

n_start

An unsigned 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

A vec that contains the generated observations.


Simulate a simts TS object using a theoretical model

Description

Create a gts 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

An integer containing the length of the time series.

model

A ts.model or simts object containing the available models in the simts package.

start

A numeric that provides the time of the first observation.

end

A numeric that provides the time of the last observation.

freq

A numeric that provides the rate of samples. Default value is 1.

unit_ts

A string that contains the unit expression of the time series. Default value is NULL.

unit_time

A string that contains the unit expression of the time. Default value is NULL.

name_ts

A string that provides an identifier for the time series data. Default value is NULL.

name_time

A string that provides an identifier for the time. Default value is NULL.

Details

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

Value

A gts object

Author(s)

James Balamuta and Wenchao Yang

Examples

# Set seed for reproducibility
set.seed(1336)
n = 1000

# AR1 + WN
model = AR1(phi = .5, sigma2 = .1) + WN(sigma2=1)
x = gen_gts(n, model)
plot(x)

# Reset seed
set.seed(1336)

# GM + WN
# Convert from AR1 to GM values
m = ar1_to_gm(c(.5,.1),10)

# Beta = 6.9314718, Sigma2_gm = 0.1333333
model = 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 series
all.equal(x, x2, check.attributes = FALSE)

Generate a Latent Time Series Object Based on a Model

Description

Simulate a lts 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

An interger indicating the amount of observations generated in this function.

model

A ts.model or simts object containing one of the allowed models.

start

A numeric that provides the time of the first observation.

end

A numeric that provides the time of the last observation.

freq

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

unit_ts

A string that contains the unit of measure of the time series. The default value is NULL.

unit_time

A string that contains the unit of measure of the time. The default value is NULL.

name_ts

A string that provides an identifier for the time series data. Default value is NULL.

name_time

A string that provides an identifier for the time. Default value is NULL.

process

A vector that contains model names of each column in the data object where the last name is the sum of the previous names.

Details

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

Value

A lts 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

A vector that contains model names of decomposed and combined processes

Author(s)

James Balamuta, Wenchao Yang, and Justin Lee

Examples

# AR
set.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

An interger containing the amount of observations for the time series.

theta

A vec containing the parameters to use to generate the model.

desc

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

objdesc

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

Value

A mat 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

An integer for signal length.

theta

A double that contains moving average.

sigma2

A double that contains process variance.

Details

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

Value

A vec 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 using gen_wn and then obtains the MA values under the above equation.

The X_0 (first value of X_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

An integer for signal length.

sigma2

A double.

lambda

A double.

alpha

A double.

Value

mtp A vec containing the Matern Process.


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

Description

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

Usage

gen_mean(X, beta)

Arguments

X

A Matrix with dimension n*p.

beta

A vector with dimension p*1

Value

mean_vec A vec containing the determinist vector.


Generate Time Series based on Model (Internal)

Description

Create a time series process based on a supplied ts.model.

Usage

gen_model(N, theta, desc, objdesc)

Arguments

N

An interger containing the amount of observations for the time series.

theta

A vec containing the parameters to use to generate the model

desc

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

objdesc

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

Value

A vec 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

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

title

A string defining the name of the time series data.

seed

An integer defined for simulation replication purposes.

...

Additional parameters.

Value

A vector 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 and d.

Description

Simulates a a Power Law Process given \sigma^2 and d.

Usage

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

Arguments

N

An integer for signal length.

sigma2

A double.

d

A double.

Value

plp A vec containing the Power Law Process.


Generate a Quantisation Noise (QN) or Rounding Error Sequence

Description

Simulates a QN sequence given Q^2.

Usage

gen_qn(N, q2 = 0.1)

Arguments

N

An integer for signal length.

q2

A double that contains autocorrection.

Value

A vec containing the QN process.

Process Definition

Quantization Noise (QN) with parameter Q^2 \in R^{+}. With i.i.d Y_t \sim U(0,1) (i.e. a standard uniform variable), this process is defined 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

An integer for signal length.

sigma2

A double that contains process variance.

Value

grw A vec 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 called Rate 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 sample N times from a N(0,\sigma^2) distribution. Lastly, we take the cumulative 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

An integer for signal length.

ar

A vec that contains the AR coefficients.

d

An integer that indicates a non-seasonal difference.

ma

A vec that contains the MA coefficients.

sar

A vec that contains the SAR coefficients.

sd

An integer that indicates a seasonal difference.

sma

A vec that contains the SMA coefficients.

sigma2

A double that contains process variance.

s

An integer that contains a seasonal id.

n_start

An unsigned 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

A vec 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

An integer for signal length.

ar

A vec that contains the AR coefficients.

ma

A vec that contains the MA coefficients.

sar

A vec that contains the SAR coefficients.

sma

A vec that contains the SMA coefficients.

sigma2

A double that contains process variance.

s

An integer that contains a seasonal id.

n_start

An unsigned 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

A vec 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

An integer for signal length.

alpha2

A double that contains the squared amplitude parameter alpha2.

beta

A double that contains the angular frequency parameter beta.

Value

sn A vec 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

An integer for signal length.

sigma2

A double that contains process variance.

Value

wn A vec containing the white noise.

Process Definition

Gaussian White Noise (WN) with parameter \sigma^2 \in {\rm I\!R}^{+}. This process is defined as X_t\sim N(0,\sigma^2) and is 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 sample N times from a N(0,\sigma ^2) distribution.


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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that represents the model transformation

wv_empir

A vec that

theo

A vec that

scales

A vec that

V

A mat that contains the V matrix used to obtain the GMWM.

omega

A mat that

obj_value

A double that contains the objective function value at the optimized solution.

N

A int that indicates how long the time series is.

alpha

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

robust

A bool that indicates whether the estimation should be robust or not.

eff

A double that specifies the amount of efficiency required by the robust estimator.

inference

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

fullV

A bool that indicates whether the matrix has been fully bootstrapped.

bs_gof

A bool indicating whether the GoF should be bootstrapped or done asymptotically.

bs_gof_p_ci

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

bs_ci

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

B

A int that indicates how many iterations should take place.

Value

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


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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string containing the model type. Either 'imu' or 'ssm'

omega

A mat that is the inverse of the diagonal of the V matrix.

wv_empir

A vec containing the empirical wavelet variance.

tau

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

Value

A double 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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string containing the model type. Either 'imu' or 'ssm'

wv_empir

A vec containing the empirical wavelet variance.

tau

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

Value

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


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

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

sigma2_gm

A double 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)

Transform GM to AR1

Description

Takes GM values and transforms them to AR1

Usage

gm_to_ar1(theta, freq)

Arguments

theta

A vec that contains AR1 values.

freq

A double indicating the frequency of the data.

Value

A vec containing GM values.

Author(s)

James Balamuta The function takes a vector of GM values \beta and \sigma ^2_{gm} and transforms them to AR1 values \phi and \sigma ^2 using 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

A ts.model object containing one of the allowed models.

data

A matrix or data.frame object with only column (e.g. N \times 1), a lts object, or a gts object.

model.type

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

compute.v

A string indicating the type of covariance matrix solver. Valid values are: "fast", "bootstrap", "diag" (asymptotic diag), "full" (asymptotic full). By default, the program will fit a "fast" model.

robust

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

eff

A double between 0 and 1 that indicates the efficiency.

alpha

A double between 0 and 1 that correspondings to the \frac{\alpha}{2} value for the wavelet confidence intervals.

seed

An integer that controls the reproducibility of the auto model selection phase.

G

An integer to sample the space for IMU and SSM models to ensure optimal identitability.

K

An integer that controls how many times the bootstrapping procedure will be initiated.

H

An integer that indicates how many different samples the bootstrap will be collect.

freq

A double that indicates the sampling frequency. By default, this is set to 1 and only is important if GM() 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)^2 5. Optimize the values to obtain \hat{\theta} 6. If FAST = TRUE, return these results. Else, continue.

Loop k = 1 to K Loop h = 1 to H 7. Simulate xt under F_{\hat{\theta}} 8. Compute WV Empirical END 9. Calculate the covariance matrix 10. Optimize the values to obtain \hat{\theta} END 11. Return optimized values.

The function estimates a variety of time series models. 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:

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

Value

A gmwm 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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that represents the model transformation

wv_empir

A vec that contains the empirical wavelet variance

omega

A mat that represents the covariance matrix.

scales

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

starting

A bool 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:

If model_type = "imu" or type = "ssm" then starting 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

A vec 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 sampling scheme specific to IMUs.

Usage

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

Arguments

model

A ts.model object containing one of the allowed models.

data

A matrix or data.frame object with only column (e.g. N \times 1), or a lts object, or a gts object.

compute.v

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

robust

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

eff

A double 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 settings ideal for modeling with an IMU object. If you seek to model with an Gauss Markov, GM, object. Please note results depend on the freq specified in the data construction step within the imu. If you wish for results to be stable but lose the ability to interpret with respect to freq, then use AR1 terms.

Value

A gmwm object with the structure:


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

A vec containing the data.

theta

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that represents the model transformation

starting

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

alpha

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

compute_v

A string that describes what kind of covariance matrix should be computed.

K

An int that controls how many times theta is updated.

H

An int that controls how many bootstrap replications are done.

G

An int that controls how many guesses at different parameters are made.

robust

A bool that indicates whether the estimation should be robust or not.

eff

A double that specifies the amount of efficiency required by the robust estimator.

Value

A field<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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

Details

Expand in detail...

Value

A vec 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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

Details

Expand in detail...

Value

A vec 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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that represents the model transformation

scales

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

starting

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

Value

A field<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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that contains the model type: "imu" or "ssm"

tau

A vec containing the scales of a proccess.

v_hat

A mat that contains the bootstrapped matrix.

wv_empir

A vec that contains the empirical wavelet variance.

Value

A vec 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 the simts 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-column matrix, data.frame, or a numeric vector.

start

A numeric that provides the time of the first observation.

end

A numeric that provides the time of the last observation.

freq

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

unit_ts

A string that contains the unit of measure of the time series. The default value is NULL.

unit_time

A string that contains the unit of measure of the time. The default value is NULL.

name_ts

A string that provides an identifier for the time series data. Default value is NULL.

name_time

A string that provides an identifier for the time. Default value is NULL.

data_name

A string that contains the name of the time series data.

Time

A numeric or character vector containing the times of observations. Default value is NULL. See x object in as.Date function.

time_format

A string specifiying the format of 'Time'. If not provided, 'Time' is assumed to be all integers. Default value is NULL. See format argument in as.Date function.

Value

A gts 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

A vector<string> that contains the model's components.

objdesc

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

model_type

A string that indicates whether it is an SSM or sensor.

num_param

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

expect_diff

A double that contains the mean of the first difference of the data

N

A integer that contains the number of observations in the data.

tau

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

G

A integer that indicates how many random draws that should be performed.

Value

A vec 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

A vector<string> that contains the model's components.

objdesc

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

model_type

A string that indicates whether it is an SSM or sensor.

num_param

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

expect_diff

A double that contains the mean of the first difference of the data

N

A integer that contains the number of observations in the data.

wv_empir

A vec that contains the empirical wavelet variance.

tau

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

B

A integer that indicates how many random draws that should be performed.

Value

A vec 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

A field<vec> that contains:

Author(s)

JJB


Obtain the value of an object's properties

Description

Used to access different properties of the gts, imu, or lts object.

Usage

has(x, type)

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

Arguments

x

A gts, imu, or lts object.

type

A string indicating the field to be retrieved.

Details

To access information about imu 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 a classical approach when estimating time series.

Usage

hydro

Format

A time series object with frequency 12 starting at 1907 and going to 1972 for 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

A vec that contains the coefficients of the AR process.

ma

A vec that contains the coefficients of the MA process.

sigma2

A double that indicates the sigma2 parameter of the ARMA process.

N

A int that indicates how long the time series is.

robust

A bool that indicates whether the estimation should be robust or not.

eff

A double that specifies the amount of efficiency required by the robust estimator.

H

A int that indicates how many iterations should take place.

Value

A vec 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

A vec that contains the coefficients of the AR process.

ma

A vec that contains the coefficients of the MA process.

sigma2

A double that indicates the sigma2 parameter of the ARMA process.

N

A int that indicates how long the time series is.

robust

A bool that indicates whether the estimation should be robust or not.

eff

A double that specifies the amount of efficiency required by the robust estimator.

H

A int that indicates how many iterations should take place.

Value

A vec 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

A vector which contains data, or a matrix or data.frame which contains the data in each column.

gyros

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

accels

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

axis

A vector 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

An integer that provides the frequency for the data.

unit

A string that contains the unit expression of the frequency. Default value is NULL.

name

A string that provides an identifier to the data. Default value is NULL.

Details

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

gyros and accels cannot be NULL at the same time, but it will be fine if one of them is NULL. In the new implementation, the length of gyros and accels do not need to be equal.

In axis, 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

An imu object in the following attributes:

sensor

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

num.sensor

A vector 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 gyros
test1 = imu(imu6, gyros = 1:3, axis = c('X', 'Y', 'Z'), freq = 100)
df1 = wvar.imu(test1)
plot(df1)

# Example 2 - One gyro and one accelerometer
test2 = imu(imu6, gyros = 1, accels = 4, freq = 100)
df2 = wvar.imu(test2)
plot(df2)

# Example 3 - 3 gyros and 3 accelerometers
test3 = 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 axis
test4 = 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 access rownames() with a numeric conversion.

Usage

imu_time(x)

Arguments

x

A imu object

Value

A vector 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

A vec containing the data

xi

A vec with length lag*d that provides initial values for the integration.

lag

An unsigned int indicating the lag between observations.

d

An unsigned 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

A cx_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 a gts, imu, or lts object?

Usage

is.gts(x)

is.imu(x)

is.lts(x)

is.ts.model(x)

Arguments

x

A gts, imu, lts object.

Details

Uses inherits over is for speed.

Value

A logical 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

A numeric value.

Value

A boolean 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

A vec that contains all the parameter estimates.

p

A int that indicates the number of AR coefficients

q

A int that indicates the number of MA coefficients.

tau

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

Value

A mat 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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

Author(s)

JJB


MLR in Armadillo

Description

Perform Multiple Linear Regression using armadillo in C++

Usage

lm_arma(y, X)

Arguments

y

A vec of length N\times 1 containing the responses.

X

A mat with dimensions N \times p, which is the design matrix.

Value

A field<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

A vec of length N\times 1 containing the responses.

Value

A field<vec> with:

coef

Coefficients

resid

Residuals

sigma2

Sigma^2


Logit Function

Description

This function computes the logit link function.

Usage

logit(x)

Arguments

x

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

Value

A vec containing logit terms.

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

A vec containing real numbers.

Value

A vec containing logit probabilities.

Author(s)

James Joseph Balamuta (JJB)


Logit2 Function

Description

This function computes the logit2 link function.

Usage

logit2(x)

Arguments

x

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

Value

A vec 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

A vec containing real numbers.

Value

A vec containing logit probabilities.

Author(s)

James Joseph Balamuta (JJB)


Generate a Latent Time Series Object from Data

Description

Create a lts 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-column matrix or data.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

A numeric that provides the time of the first observation.

end

A numeric that provides the time of the last observation.

freq

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

unit_ts

A string that contains the unit of measure of the time series. The default value is NULL.

unit_time

A string that contains the unit of measure of the time. The default value is NULL.

name_ts

A string that provides an identifier for the time series data. Default value is NULL.

name_time

A string that provides an identifier for the time. Default value is NULL.

process

A vector that contains model names of each column in the data object where the last name is the sum of the previous names.

Value

A lts 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)

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

Description

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

Usage

M(X, beta)

Arguments

X

A Matrix with dimension n*p.

beta

A vector 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)

Second moment DR

Description

This function computes the second moment of a drift process.

Usage

m2_drift(omega, n_ts)

Arguments

omega

A double corresponding to variance of drift.

n_ts

An int indicating the length of the time series.

Value

A vec containing the second moment of the drift.


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

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

sigma2

A double 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 theta
MA(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.

Ma function.

Description

Ma function.

Usage

Ma_cpp(x, alpha)

Arguments

x

A double.

alpha

A double.


Ma vectorized function.

Description

Ma vectorized function.

Usage

Ma_cpp_vec(x, alpha)

Arguments

x

A NumericVector.


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

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

sigma2

A double 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)

Moving Average Order 1 (MA(1)) to WV

Description

This function computes the WV (haar) of a Moving Average order 1 (MA1) process.

Usage

ma1_to_wv(theta, sigma2, tau)

Arguments

theta

A double corresponding to the moving average term.

sigma2

A double the variance of the process.

tau

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

Details

This function is significantly faster than its generalized counter part arma_to_wv.

Value

A vec containing the wavelet variance of the MA(1) process.

Process Haar Wavelet Variance Formula

The Moving Average Order 1 (MA(1)) process has a Haar Wavelet Variance given by:

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


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

A numeric providing the range of values for the x-axis.

y_range

A numeric providing the range of values for the y-axis.

xlab

A string that gives a title for the x-axis.

ylab

A string that gives a title for the y-axis.

main

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

mar

A vector indicating overall margin values for the plot.

add_axis_x

A boolean indicating whether a x-axis should be added.

add_axis_y

A boolean indicating whether a y-axis should be added.

col_box

A string indicating the color for the title box.

col_grid

A string indicating the color of the grid for the plot.

col_band

A string indicating the color of the band.

col_title

A string indicating the color of the plot title.

add_band

A boolean indicating whether there should be a band.

title_band_width

A double providing the value of the band width. Default is 0.09.

grid_lty

A integer 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)

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

A vector of time series data.

start

A numeric indicating the starting proportion of the data that is used for prediction.

plot

A boolean indicating whether a model accuracy plot based on MAPE is returned or not.

Value

The MAPE calculated based on one-step ahead prediction and reforecasting is 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

A double.

lambda

A double.

alpha

A double.

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)

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A field<vec> that contains:

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

A vec containing the data

Value

A double 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

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

Value

A double with the minimum root value.


Absolute Value or Modulus of a Complex Number.

Description

Computes the value of the Modulus.

Usage

Mod_cpp(x)

Arguments

x

A cx_vec.

Details

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

Value

A vec containing the modulus for each element.


Generate the ts model object description

Description

Creates the ts.model's obj.desc value

Usage

model_objdesc(desc)

Arguments

desc

A vector<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

A field<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

A vector<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

A vector<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

A mat that contains the first derivatives of the processes

omega

A mat that contains the omega used when calculating the GMWM

v_hat

A mat 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

A vec


Generate the ts model object's theta vector

Description

Creates the ts.model's theta vector

Usage

model_theta(desc)

Arguments

desc

A vector<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

A vec 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

A vector with dimensions N\times 1.

filter_name

A string indicating the filter.

nlevels

An integer, J, indicating the level of the decomposition.

boundary

A string indicating the type of boundary method to use. Either boundary="periodic" or "reflection".

brickwall

A bool 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 A field<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

A vec that contains the data.

robust

A boolean that triggers the use of the robust estimate.

eff

A double that indicates the efficiency as it relates to an MLE.

alpha

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

ci_type

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

strWavelet

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

decomp

A string indicating whether to use "modwt" or "dwt" decomp

Details

This function powers the wvar object. It is also extendable...

Value

A mat with the structure:


Bootstrap standard error for the median

Description

Non-parametric bootstrap to obtain the standard of the median of iid data.

Usage

np_boot_sd_med(x, B = 5000)

Arguments

x

A vector of data.

B

A numeric indicating the number of simulations.

Value

Bootstrap standard error for the median


Replicate a Vector of Elements n times

Description

This function takes a vector and replicates all of the data n times

Usage

num_rep(x, n)

Arguments

x

A vec containing the data

n

An unsigned int indicating the number of times the vector should be repeated.

Value

A vec 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

A vec containing the theta values.

objdesc

A vec at the desc point.

cur_position

An integer at the current position.

Value

A field<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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

scales

A vec containing the scales of the process.

model_type

A string containing the model type either: SSM or IMU

N

A int indicating how long the integer is.

robust

A bool indicating robust (T) or classical (F).

eff

A double that handles efficiency.

H

A int that indicates how many bootstraps should be obtained.

Details

Expand in detail...

Value

A vec 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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

Details

Expand in detail...

Value

A vec that contains the parameter estimates from GMWM estimator.

Author(s)

JJB


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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

Value

A vec that has AR1s shown in descending parameter value.


Order the Model

Description

Orders the model and changes it to the correct format

Usage

orderModel(models)

Arguments

models

A vector of string that specifies the models

Details

If the models 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 in gen.lts()

Examples

models = c("AR1", "WN", "AR1", "WN", "AR1+WN+AR1+WN")
new.models = orderModel(models)
new.models

models = c('AR1', 'QN', 'WN', 'AR1+QN+WN')
new.models = orderModel(models)
new.models

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

A gts object

model

A ts model

n.ahead

An integer indicating number of units of time ahead for which to make forecasts

level

A double or vector indicating confidence level of prediction interval. By default, it uses the levels of 0.50 and 0.95.

xlab

A string for the title of x axis

ylab

A string for the title of y axis

main

A string for the over all title of the plot

...

Additional parameters

Author(s)

Yuming Zhang


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

A gmwm object.

decomp

A boolean that determines whether the contributions of each individual model are plotted.

units

A string that specifies the units of time plotted on the x axis.

xlab

A string that gives a title for the x axis.

ylab

A string that gives a title for the y axis.

main

A string that gives an overall title for the plot.

col_wv

A string that specifies the color of the wavelet variance line.

col_ci

A string that specifies the color of the shaded area covered by the confidence intervals.

nb_ticks_x

An integer that specifies the maximum number of ticks for the x-axis.

nb_ticks_y

An integer that specifies the maximum number of ticks for the y-axis.

legend_position

A string that specifies the position of the legend (use legend_position = NA to remove legend).

ci_wv

A boolean that determines whether to plot the confidence interval shaded area.

point_cex

A double that specifies the size of each symbol to be plotted.

point_pch

A double 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

A gts object

evenly

A boolean indicating whether the time series is evenly spaced or not.

xlab

A string that gives a title for the x axis.

ylab

A string that gives a title for the y axis.

main

A string that gives an overall title for the plot.

couleur

A string 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 an lts object.

Usage

## S3 method for class 'lts'
plot(
  x,
  xlab = NULL,
  ylab = NULL,
  main = NULL,
  color = NULL,
  fixed_range = FALSE,
  ...
)

Arguments

x

A lts object

xlab

A string that gives a title for the x axis.

ylab

A string that gives a title for the y axis.

main

A string that gives an overall title for the plot.

color

A string 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 Partial Auto-Covariance and Correlation Functions

Description

The function plots the output of the theo_pacf and auto_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 from theo_pacf or auto_corr.

xlab

A string indicating the label of the x axis: the default name is 'Lags'.

ylab

A string indicating the label of the y axis: the default name is 'PACF'.

show.ci

A bool indicating whether to show the confidence region. Defaults to TRUE.

alpha

A double indicating the level of significance for the confidence interval. By default alpha = 0.05 which gives a 1 - alpha = 0.95 confidence interval.

col_ci

A string that specifies the color of the region covered by the confidence intervals (confidence region).

transparency

A double between 0 and 1 indicating the transparency level of the color defined in col_ci. Defaults to 0.25.

main

A string indicating the title of the plot. Default name is "Variable name PACF plot'.

parValue

A vector defining the margins for the plot.

...

Additional parameters

Author(s)

Yunxiang Zhang and Yuming Zhang

Examples

# Plot the Partial Autocorrelation
m = auto_corr(datasets::AirPassengers, pacf = TRUE)
plot(m)

# More customized CI
plot(m, xlab = "my xlab", ylab = "my ylab", show.ci = TRUE, 
alpha = NULL, col_ci = "grey", transparency = 0.5, main = "my main")

Plot Auto-Covariance and Correlation Functions

Description

The function plots the output of the theo_acf and auto_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 from theo_acf and auto_corr.

xlab

A string indicating the label of the x axis: the default name is 'Lags'.

ylab

A string indicating the label of the y axis: the default name is 'ACF'.

show.ci

A bool indicating whether to show the confidence region. Defaults to TRUE.

alpha

A double indicating the level of significance for the confidence interval. By default alpha = 0.05 which gives a 1 - alpha = 0.95 confidence interval.

col_ci

A string that specifies the color of the region covered by the confidence intervals (confidence region).

transparency

A double between 0 and 1 indicating the transparency level of the color defined in col_ci. Defaults to 0.25.

main

A string indicating the title of the plot. Default name is "Variable name ACF plot'.

parValue

A vector defining the margins for the plot.

...

Additional parameters

Author(s)

Yunxiang Zhang, Stéphane Guerrier and Yuming Zhang

Examples

# Calculate the Autocorrelation
m = auto_corr(datasets::AirPassengers)

# Plot with 95% CI
plot(m) 

# Plot with 90% CI
plot(m, alpha = 0.1) 

# Plot without 95% CI
plot(m, show.ci = FALSE)

# More customized CI
plot(m, xlab = "my xlab", ylab = "my ylab", show.ci = TRUE,
alpha = NULL, col_ci = "grey", transparency = 0.5, main = "my main")

Definition of a Power Law Process

Description

Definition of a Power Law Process

Usage

PLP(sigma2 = 1, d = 0.4)

Arguments

sigma2

A double.

d

A double.

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)

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

A fitsimts object obtained from estimate function.

n.ahead

An integer indicating number of units of time ahead for which to make forecasts.

show_last

A integer indicating the number of last observations to show in the forecast plot.

level

A double or vector indicating confidence level of prediction interval. By default, it uses the levels of 0.50 and 0.95.

xlab

A string for the title of x axis.

ylab

A string for the title of y axis.

main

A string for the over all title of the plot.

plot

A logical value. logical. If TRUE(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 the Generalized Method of Wavelet Moments

Description

Creates a prediction using the estimated values of GMWM through the ARIMA function within R.

Usage

## S3 method for class 'gmwm'
predict(object, data.in.gmwm, n.ahead = 1, ...)

Arguments

object

A gmwm 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

A predict.gmwm object with:


Print fitsimts object

Description

This function displays the information of a fitsimts object.

Usage

## S3 method for class 'fitsimts'
print(x, ...)

Arguments

x

A fitsimts 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

A GMWM object

...

Other arguments passed to specific methods

Value

Text output via print

Author(s)

JJB


Print simts Objects

Description

Pretty formatting for gts, imu, and lts 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

A gts, imu, lts object.

obs

A integer the specifies how many from the beginning and end of the data set to show.

row.names

A boolean that indicates whether row names should be displayed or surpressed.

...

Further arguments passed to or from other methods.

Value

A logical 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

A GMWM 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

A numeric 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 guessing
QN() + DR() + WN() + RW() + AR1() + ARMA(1,2)

# Creates a user-specified starting value model
AR1(phi = .9, sigma2 = .1) + WN(sigma2 = 1) 

# Similarly, with the addition of a generic ARMA
RW(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

A vec containing probabilities (e.g. 0 <= x <= 1)

Value

A vec 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

A vec containing real numbers.

Value

A vec 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

A vector that contains the filter constants.

inverse

A bool that indicates whether the inverse quadrature mirror filter is computed. By default, the inverse quadrature mirror is computed.

Value

A vector that contains either the forward QMF (evalute in order) or the inverse QMF (reverse order).

Author(s)

JJB


Create an Quantisation Noise (QN) Process

Description

Sets up the necessary backend for the QN process.

Usage

QN(q2 = NULL)

Arguments

q2

A double value for the Q^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)

Quantisation Noise (QN) to WV

Description

This function compute the Haar WV of a Quantisation Noise (QN) process

Usage

qn_to_wv(q2, tau)

Arguments

q2

A double corresponding to variance of drift

tau

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

Value

A vec containing the wavelet variance of the QN.

Process Haar Wavelet Variance Formula

The Quantization Noise (QN) process has a Haar Wavelet Variance given by:

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


Find Quantiles

Description

Attempts to find quantiles

Usage

quantile_cpp(x, probs)

Arguments

x

A vec of data

probs

A vec of the quantiles to find.

Value

A vector 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

A vec of data.

model_str

A vector<vector<string>> that gives a list of models to test.

full_model

A vector<string> that contains the largest / full model.

alpha

A double that indicates the alpha level for CIs.

compute_v

A string indicating the type of V matrix to generate

model_type

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

K

A int that controls how many times the GMWM is run.

H

A int that controls how many bootstraps occur.

G

A int that controls how many guesses occur.

robust

A bool that indicates whether to use classical or robust wavelet variance.

eff

A double that indicates the efficiency to use.

bs_optimism

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

seed

A unsigned int that is the seed one wishes to use.

Value

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


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

A vec of data.

params

A vec of the ARMA parameters

Value

A vec containing the CSS of the ARMA parameters.


Read an IMU Binary File into R

Description

The function will take a file location in addition to the type of sensor it came from and read the data into R.

Usage

read_imu(file_path, imu_type)

Arguments

file_path

A string that contains the full file path.

imu_type

A string 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 55 for providing a matlab function that reads in IMUs. The function below is a heavily modified port of MATLAB code into Armadillo/C++.


Read an IMU Binary File into R

Description

Process binary files within the

Usage

read.imu(file, type, unit = NULL, name = NULL)

Arguments

file

A string containing file names or paths.

type

A string that contains a supported IMU type given below.

unit

A string that contains the unit expression of the frequency. Default value is NULL.

name

A string that provides an identifier to the data. Default value is NULL.

Details

Currently supports the following IMUs:

Value

An imu object that contains 3 gyroscopes and 3 accelerometers in that order.

Author(s)

James Balamuta We 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 55 for providing a matlab function that reads in IMUs. This function is a heavily modified port of MATLAB code into Armadillo/C++.

Examples

## Not run: 
# Relative
setwd("F:/")

a = read.imu(file = "Documents/James/short_test_data.imu", type = "IXSEA")

# Fixed path
b = read.imu(file = "F:/Desktop/short_test_data.imu", type = "IXSEA")

## End(Not run)

Plot the Distribution of (Standardized) Residuals

Description

This function plots a histogram (with kernel density function and normal distribution) of the standardized residuals or a basic plot the (standardized) residuals, or both.

Usage

resid_plot(res, std = FALSE, type = "hist", ...)

Arguments

res

A vector of residuals.

std

A boolean indicating whether the residuals plot is for standardized residuals or original residuals.

type

A string 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

A matrix of dimensions M x N

start

A unsigned int that indicates the starting column.

end

A unsigned int that indicates the ending column.

Details

Consider a vector x=[[1,2],[3,4]]. By setting start=1 and end=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 A matrix 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

A matrix of dimensions M x N

start

A unsigned int that indicates the starting row.

end

A unsigned 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 A matrix 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

A column 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 A column 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

A column vector of length T

filter

A column vector of length f

init

A column 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 A column vector with its contents reversed.

Author(s)

JJB


GMWM for Robust/Classical Comparison

Description

Creates a rgmwm object to compare the results generated by robust/classical method.

Usage

rgmwm(model, data, eff = c(0.9, 0.8, 0.6), ...)

Arguments

model

A ts.model object containing one of the allowed models.

data

A matrix or data.frame object with only one column (e.g. N \times 1), or a lts object, or a gts object.

eff

A double vector between 0 and 1 that indicates the efficiency.

...

Other arguments passed to the main gmwm function.

Details

By default, the rgmwm function will fit a classical gmwm object. From there, the user has the ability to specify any eff that is less than or equal to 0.99.

Value

A rgmwm object


Truncated Normal Distribution Sampling Algorithm

Description

Enables sampling from a truncated normal

Usage

rtruncated_normal(n, mu, sigma, a, b)

Arguments

n

An unsigned int indicating the number of observations to generate.

mu

A double indicating the mean of the normal.

sigma

A double indicating the standard deviation of the normal.

a

A double that is the lower bound of the truncated normal.

b

A double that is the upper bound of the truncated normal.


Create an Random Walk (RW) Process

Description

Sets up the necessary backend for the RW process.

Usage

RW(gamma2 = NULL)

Arguments

gamma2

A double 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

where Z_t is iid and follows a standard normal distribution.

Author(s)

James Balamuta

Examples

RW()
RW(gamma2=3.4)

Random Walk to WV

Description

This function compute the WV (haar) of a Random Walk process

Usage

rw_to_wv(gamma2, tau)

Arguments

gamma2

A double corresponding to variance of RW

tau

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

Value

A vec containing the wavelet variance of the random walk.

Process Haar Wavelet Variance Formula

The Random Walk (RW) process has a Haar Wavelet Variance given by:

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


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

An integer that counts the number of steps of the random walk.

probs

A vector of double 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))

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

A vector or integer containing either the coefficients for \phi's or the process number p for the Autoregressive (AR) term.

i

An integer containing the number of differences to be done.

ma

A vector or integer containing either the coefficients for \theta's or the process number q for the Moving Average (MA) term.

sar

A vector or integer containing either the coefficients for \Phi's or the process number P for the Seasonal Autoregressive (SAR) term.

si

An integer containing the number of seasonal differences to be done.

sma

A vector or integer containing either the coefficients for \Theta's or the process number Q for the Seasonal Moving Average (SMA) term.

s

An integer containing the seasonality.

sigma2

A double 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) process
SARIMA(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

A vector or integer containing either the coefficients for \phi's or the process number p for the Autoregressive (AR) term.

ma

A vector or integer containing either the coefficients for \theta's or the process number q for the Moving Average (MA) term.

sar

A vector or integer containing either the coefficients for \Phi's or the process number P for the Seasonal Autoregressive (SAR) term.

sma

A vector or integer containing either the coefficients for \Theta's or the process number Q for the Seasonal Moving Average (SMA) term.

s

A integer indicating the seasonal value of the data.

sigma2

A double 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) process
SARMA(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)

Calculates Length of Seasonal Padding

Description

Computes the total phi and total theta vector length.

Usage

sarma_calculate_spadding(np, nq, nsp, nsq, ns)

Arguments

np

An unsigned int containing the number of non-seasonal phi parameters.

nq

An unsigned int containing the number of non-seasonal theta parameters.

nsp

An unsigned int containing the number of seasonal phi parameters.

nsq

An unsigned int containing the number of seasonal theta parameters.

Value

A vec 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 vectors for seasonal terms.

Usage

sarma_components(objdesc)

Arguments

objdesc

A vec with the appropriate sarima object description

Value

A vec with the structure:

np

Number of Non-Seasonal AR Terms

nq

Number of Non-Seasonal MA Terms

nsp

Number of Seasonal AR Terms

nsq

Number of Seasonal MA Terms

ns

Number of Seasons (e.g. 12 is year)

p

Total number of phi terms

q

Total number of theta terms


Expand Parameters for an SARMA object

Description

Creates an expanded PHI and THETA vector for use in other objects.

Usage

sarma_expand(params, objdesc)

Arguments

params

A vec containing the theta values of the parameters.

objdesc

A vec containing the model term information.

Details

The objdesc is assumed to have the structure of:

Value

A field<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

A vec containing the theta values of the parameters.

np

An unsigned int containing the number of non-seasonal phi parameters.

nq

An unsigned int containing the number of non-seasonal theta parameters.

nsp

An unsigned int containing the number of seasonal phi parameters.

nsq

An unsigned int containing the number of seasonal theta parameters.

p

An unsigned int that is the total size of the phi vector.

q

An unsigned int that is the total size of the theta vector.

Value

A field<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 personal income (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 going to 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

A integer that contains the level of decomposition J.

Details

Used in wvar object.

Value

A vec 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

A vector of time series data.

include.mean

A boolean indicating whether to fit ARIMA with the mean or not.

criterion

A string indicating which model selection criterion should be used (possible values: "aic" (default), "bic", "hq").

plot

A boolean 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 in best_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

A vector of univariate time series.

p.min

An integer indicating the lowest order of AR(p) process to search.

p.max

An integer indicating the highest order of AR(p) process to search.

d

An integer indicating the differencing order for the data.

q.min

An integer indicating the lowest order of MA(q) process to search.

q.max

An integer indicating the highest order of MA(q) process to search.

include.mean

A bool indicating whether to fit ARIMA with the mean or not.

plot

A logical. If TRUE (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

A String 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 A field<vec> that contains:

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

An int, that denotes the starting point.

b

An int, that denotes the ending point.

Value

A vector containing values moving from a to b. There are no restrictions on A's range.

Author(s)

James J Balamuta


Generate a sequence of values based on supplied number

Description

Creates a vector containing a sequence of values starting at 1 and going to the terminal point.

Usage

seq_len_cpp(n)

Arguments

n

An int that denotes the length of the vector.

Value

A vector 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 triggering the CRAN rng modifier check.

Usage

set_seed(seed)

Arguments

seed

A unsigned 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

The arima model fit to the data.

std

A boolean 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

An integer denoting the length of ar.

i

An integer containing the number of differences to be done.

q

An integer denoting the length of ma.

P

An integer denoting the length of sma.

si

An integer containing the number of seasonal differences to be done.

Q

An integer denoting the length of sar.

s

An integer 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


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

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

beta

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

U

A double value for the phase parameter U (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)

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

Author(s)

Lionel Voirol

Examples

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

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

A matrix to sort

col

A int 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

A field<vec>.

Value

An mat 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

A fitsimts 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

A GMWM 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

An int that indicates how many bootstraps should be performed.

...

Other arguments passed to specific methods

Value

A summary.gmwm object with:

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

A vector containing the AR coefficients.

ma

A vector containing the MA coefficients.

lagmax

An integer 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

A vector containing the AR coefficients.

ma

A vector containing the MA coefficients.

lagmax

An integer 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

A vec containing the list of estimated parameters.

desc

A vector<string> containing a list of descriptors.

objdesc

A field<vec> containing a list of object descriptors.

tau

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

Value

A vec 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

A vec containing the estimates

A

A mat that is the first derivative matrix.

v_hat

A mat that is the bootstrapped V matrix

omega

A mat that is the inverse of the diagonal V matrix.

alpha

A double that contains the confidence level.

Value

A mat 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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that contains the model type: "imu" or "ssm"

Value

A vec 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

A vector containing the values on x-axis.

from.unit

A string indicating the unit which the data is converted from.

to.unit

A string 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 sure from.unit and to.unit are not NULL before it is passed to this function.

Value

A list with the following structure:

x

Data

converted

A boolean indicating whether conversion is made

Examples

x = seq(60, 3600, 60)
unitConversion(x, 'sec', 'min')
y = 1:10
unitConversion(y, 'hour', 'sec')

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

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

desc

A vector<string> indicating the models that should be considered.

objdesc

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

model_type

A string that contains the model type: "imu" or "ssm"

Value

A vec containing the undone transformation of parameters.

Author(s)

James Joseph Balamuta (JJB)


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

A lts, gts or imu object

type

A string that contains the attribute to be updated

new

The updated value for the attribute

keep.start

A boolean value that indicates whether 'start' or 'end' should remain the same when 'freq' is updated

Value

An object with the updated attribute.


Update (Robust) GMWM object for IMU or SSM

Description

Provides a way to estimate different models over the previously estimated wavelet variance values and covariance matrix.

Usage

## S3 method for class 'gmwm'
update(object, model, ...)

Arguments

object

A gmwm object.

model

A ts.model object containing one of the allowed models

...

Additional parameters (not used)

Value

A gmwm object with the structure:


Update Object Attribute

Description

Update the attributes of lts, gts and imu 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

A lts, gts or imu object

type

A string that contains the attribute to be updated

new

The updated value for the attribute

keep.start

A boolean 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 for gts, lts and imu objects. For lts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit_time', 'name_ts' and 'process'. For gts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit_time' and 'name_ts'. For imu 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, since end-start == (N-1)/freq must be TRUE, where N is 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')

Obtain the value of an object's properties

Description

Used to access different properties of the gts, imu, or lts object.

Usage

value(x, type)

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

Arguments

x

A gts, imu, or lts object.

type

A string indicating the field to be retrieved.

Details

To access information about imu 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 the slot 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

A double corresponding to variance of drift.

n_ts

An int indicating the length of the time series.

Value

A vec 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

A set<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

A field<vec> that contains:

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

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

robust

A boolean to determine the type of wave estimation.

eff

A double that indicates the efficiency.

Value

A vec that contains the wave variance.


Create an White Noise (WN) Process

Description

Sets up the necessary backend for the WN process.

Usage

WN(sigma2 = NULL)

Arguments

sigma2

A double 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)

Gaussian White Noise to WV

Description

This function compute the Haar WV of a Gaussian White Noise process

Usage

wn_to_wv(sigma2, tau)

Arguments

sigma2

A double corresponding to variance of WN

tau

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

Value

A vec containing the wavelet variance of the white noise.

Process Haar Wavelet Variance Formula

The Gaussian White Noise (WN) process has a Haar Wavelet Variance given by:

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


Computes the (MODWT) wavelet variance

Description

Calculates the (MODWT) wavelet variance

Usage

wvar_cpp(signal_modwt_bw, robust, eff, alpha, ci_type)

Arguments

signal_modwt_bw

A field<vec> that contains the modwt decomposition after it has been brick walled.

robust

A boolean that triggers the use of the robust estimate.

eff

A double that indicates the efficiency as it relates to an MLE.

alpha

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

ci_type

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

Details

This function does the heavy lifting with the signal_modwt_bw

Value

A mat with the structure: