Title: | Time Series Analysis Tools |
---|---|
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. |
Authors: | 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] |
Maintainer: | Stéphane Guerrier <[email protected]> |
License: | AGPL-3 | file LICENSE |
Version: | 0.2.2 |
Built: | 2024-11-23 06:54:42 UTC |
Source: | CRAN |
Enables the IMU object to be subsettable. That is, you can load all the data in and then select certain properties.
## S3 method for class 'imu' x[i, j, drop = FALSE]
## S3 method for class 'imu' x[i, j, drop = FALSE]
x |
A |
i |
A |
j |
A |
drop |
A |
When using the subset operator, note that all the Gyroscopes are placed at the front of object and, then, the Accelerometers are placed.
An imu
object class.
## 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)
## 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)
This function calculates AIC, BIC or HQ for a fitsimts object. This function currently only supports models estimated by the MLE.
## S3 method for class 'fitsimts' AIC(object, k = 2, ...)
## S3 method for class 'fitsimts' AIC(object, k = 2, ...)
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. |
AIC, BIC or HQ
Stéphane Guerrier
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)))
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)))
Sets up the necessary backend for the AR(P) process.
AR(phi = NULL, sigma2 = 1)
AR(phi = NULL, sigma2 = 1)
phi |
A |
sigma2 |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "AR-1","AR-2", ..., "AR-P", "SIGMA2"
,
, ...,
,
Number of Parameters
"AR"
String containing simplified model
Depth of Parameters e.g. list(p,1)
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
AR(1) # Slower version of AR1() AR(phi=.32, sigma=1.3) # Slower version of AR1() AR(2) # Equivalent to ARMA(2,0).
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
AR1(phi = NULL, sigma2 = 1)
AR1(phi = NULL, sigma2 = 1)
phi |
A |
sigma2 |
A |
An S3 object containing the specified ts.model with the following structure:
Used in summary: "AR1","SIGMA2"
Parameter vector including ,
Number of parameters
String containing simplified model
"AR1"
Depth of Parameters e.g. list(1,1)
Find starting values? TRUE or FALSE (e.g. specified value)
We consider the following AR(1) model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
AR1() AR1(phi=.32, sigma2 = 1.3)
AR1() AR1(phi=.32, sigma2 = 1.3)
This function computes the Haar WV of an AR(1) process
ar1_to_wv(phi, sigma2, tau)
ar1_to_wv(phi, sigma2, tau)
phi |
A |
sigma2 |
A |
tau |
A |
This function is significantly faster than its generalized counter part
arma_to_wv
.
A vec
containing the wavelet variance of the AR(1) process.
The Autoregressive Order (AR(
)) process has a Haar Wavelet Variance given by:
Sets up the necessary backend for the ARIMA process.
ARIMA(ar = 1, i = 0, ma = 1, sigma2 = 1)
ARIMA(ar = 1, i = 0, ma = 1, sigma2 = 1)
ar |
A |
i |
An |
ma |
A |
sigma2 |
A |
A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation like R.
An S3 object with called ts.model with the following structure:
,
Number of parameters
String containing simplified model
y desc replicated x times
Depth of parameters e.g. list(c(length(ar),length(ma),1) )
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
# 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 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)
Sets up the necessary backend for the ARMA process.
ARMA(ar = 1, ma = 1, sigma2 = 1)
ARMA(ar = 1, ma = 1, sigma2 = 1)
ar |
A |
ma |
A |
sigma2 |
A |
A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation like R.
An S3 object with called ts.model with the following structure:
,
Number of Parameters
String containing simplified model
y desc replicated x times
Depth of Parameters e.g. list(c(length(ar),length(ma),1) )
Guess Starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
# 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)
# 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)
This function computes the Haar Wavelet Variance of an ARMA process
arma_to_wv(ar, ma, sigma2, tau)
arma_to_wv(ar, ma, sigma2, tau)
ar |
A |
ma |
A |
sigma2 |
A |
tau |
A |
The function is a generic implementation that requires a stationary theoretical autocorrelation function (ACF)
and the ability to transform an ARMA(,
) process into an MA(
) (e.g. infinite MA process).
A vec
containing the wavelet variance of the ARMA process.
The Autoregressive Order and Moving Average Order
(ARMA(
,
)) process has a Haar Wavelet Variance given by:
where 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)
ARMA11(phi = NULL, theta = NULL, sigma2 = 1)
ARMA11(phi = NULL, theta = NULL, sigma2 = 1)
phi |
A |
theta |
A |
sigma2 |
A |
A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation like R.
An S3 object with called ts.model with the following structure:
,
,
,
,
Number of Parameters: 3
String containing simplified model
Depth of Parameters e.g. list(c(1,1,1))
Guess Starting values? TRUE
or FALSE
(e.g. specified value)
We consider the following model:
where is iid from a zero
mean normal distribution with variance
.
James Balamuta
# 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()
# 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()
This function computes the WV (haar) of an Autoregressive Order 1 - Moving Average Order 1 (ARMA(1,1)) process.
arma11_to_wv(phi, theta, sigma2, tau)
arma11_to_wv(phi, theta, sigma2, tau)
phi |
A |
theta |
A |
sigma2 |
A |
tau |
A |
This function is significantly faster than its generalized counter part
arma_to_wv
A vec
containing the wavelet variance of the ARMA(1,1) process.
The Autoregressive Order and Moving Average Order
(ARMA(
,
)) process has a Haar Wavelet Variance given by:
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.
australia
australia
A data frame with 127 rows and 2 variables:
year and quarter
quarterly increase in stocks non-farm total
Time Series Data Library (citing: Australian Bureau of Statistics) datamarket
This function can estimate either the autocovariance / autocorrelation for univariate time series, or the partial autocovariance / autocorrelation for univariate time series.
auto_corr( x, lag.max = NULL, pacf = FALSE, type = "correlation", demean = TRUE, robust = FALSE )
auto_corr( x, lag.max = NULL, pacf = FALSE, type = "correlation", demean = TRUE, robust = FALSE )
x |
A |
lag.max |
An |
pacf |
A |
type |
A |
demean |
A |
robust |
A |
lagmax
default is where
is the number of
observations and
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).
An array
of dimensions .
Yuming Zhang
m = auto_corr(datasets::AirPassengers) m = auto_corr(datasets::AirPassengers, pacf = TRUE)
m = auto_corr(datasets::AirPassengers) m = auto_corr(datasets::AirPassengers, pacf = TRUE)
This function retrieves the best model from a selection procedure.
best_model(x, ic = "aic")
best_model(x, ic = "aic")
x |
An object of class
|
ic |
A |
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")
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")
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.
check(model = NULL, resids = NULL, simple = FALSE)
check(model = NULL, resids = NULL, simple = FALSE)
model |
A |
resids |
A |
simple |
A |
Stéphane Guerrier and Yuming Zhang
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)
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)
Compare classical and robust ACF of univariate time series.
compare_acf( x, lag.max = NULL, demean = TRUE, show.ci = TRUE, alpha = 0.05, plot = TRUE, ... )
compare_acf( x, lag.max = NULL, demean = TRUE, show.ci = TRUE, alpha = 0.05, plot = TRUE, ... )
x |
A |
lag.max |
A |
demean |
A |
show.ci |
A |
alpha |
A |
plot |
A |
... |
Additional parameters. |
Yunxiang Zhang
# Estimate both the ACF and PACF functions compare_acf(datasets::AirPassengers)
# Estimate both the ACF and PACF functions compare_acf(datasets::AirPassengers)
Correlation Analysis function computes and plots both empirical ACF and PACF of univariate time series.
corr_analysis( x, lag.max = NULL, type = "correlation", demean = TRUE, show.ci = TRUE, alpha = 0.05, plot = TRUE, ... )
corr_analysis( x, lag.max = NULL, type = "correlation", demean = TRUE, show.ci = TRUE, alpha = 0.05, plot = TRUE, ... )
x |
A |
lag.max |
A |
type |
A |
demean |
A |
show.ci |
A |
alpha |
A |
plot |
A |
... |
Additional parameters. |
Two array
objects (ACF and PACF) of dimension .
Yunxiang Zhang
# Estimate both the ACF and PACF functions corr_analysis(datasets::AirPassengers)
# Estimate both the ACF and PACF functions corr_analysis(datasets::AirPassengers)
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.
deriv_2nd_ar1(phi, sigma2, tau)
deriv_2nd_ar1(phi, sigma2, tau)
phi |
A |
sigma2 |
A |
tau |
A |
A matrix
with the first column containing the
second partial derivative with respect to and
the second column contains the second partial derivative with
respect to
Taking the second derivative with respect to yields:
Taking the second derivative with respect to yields:
Taking the derivative with respect to and
yields:
James Joseph Balamuta (JJB)
Obtain the second derivative of the ARMA(1,1) process.
deriv_2nd_arma11(phi, theta, sigma2, tau)
deriv_2nd_arma11(phi, theta, sigma2, tau)
phi |
A |
theta |
A |
sigma2 |
A |
tau |
A |
A matrix
with:
The first column containing the second partial derivative with respect to ;
The second column containing the second partial derivative with respect to ;
The third column contains the second partial derivative with respect to .
The fourth column contains the partial derivative with respect to and
.
The fiveth column contains the partial derivative with respect to and
.
The sixth column contains the partial derivative with respect to and
.
Taking the second derivative with respect to yields:
Taking the second derivative with respect to yields:
Taking the second derivative with respect to yields:
Taking the derivative with respect to and
yields:
Taking the derivative with respect to and
yields:
Taking the derivative with respect to and
yields:
James Joseph Balamuta (JJB)
To ease a later calculation, we place the result into a matrix structure.
deriv_2nd_dr(tau)
deriv_2nd_dr(tau)
tau |
A |
A matrix
with the first column containing
the second partial derivative with respect to .
James Joseph Balamuta (JJB)
To ease a later calculation, we place the result into a matrix structure.
deriv_2nd_ma1(theta, sigma2, tau)
deriv_2nd_ma1(theta, sigma2, tau)
theta |
A |
sigma2 |
A |
tau |
A |
A matrix
with the first column containing the second partial derivative with respect to ,
the second column contains the partial derivative with respect to
and
,
and lastly we have the second partial derivative with respect to
.
Taking the second derivative with respect to yields:
Taking the second derivative with respect to yields:
Taking the first derivative with respect to and
yields:
James Joseph Balamuta (JJB)
Obtain the first derivative of the AR(1) process.
deriv_ar1(phi, sigma2, tau)
deriv_ar1(phi, sigma2, tau)
phi |
A |
sigma2 |
A |
tau |
A |
A matrix
with the first column containing the partial derivative with respect to
and the second column contains the partial derivative with respect to
Taking the derivative with respect to yields:
Taking the derivative with respect to yields:
James Joseph Balamuta (JJB)
Obtain the first derivative of the ARMA(1,1) process.
deriv_arma11(phi, theta, sigma2, tau)
deriv_arma11(phi, theta, sigma2, tau)
phi |
A |
theta |
A |
sigma2 |
A |
tau |
A |
A matrix
with:
The first column containing the partial derivative with respect to ;
The second column containing the partial derivative with respect to ;
The third column contains the partial derivative with respect to .
Taking the derivative with respect to yields:
Taking the derivative with respect to yields:
Taking the derivative with respect to yields:
James Joseph Balamuta (JJB)
Obtain the first derivative of the Drift (DR) process.
deriv_dr(omega, tau)
deriv_dr(omega, tau)
omega |
A |
tau |
A |
A matrix
with the first column containing the partial derivative
with respect to .
Taking the derivative with respect to yields:
Note: We are taking the derivative with respect to and not
as the
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.
James Joseph Balamuta (JJB)
Obtain the first derivative of the MA(1) process.
deriv_ma1(theta, sigma2, tau)
deriv_ma1(theta, sigma2, tau)
theta |
A |
sigma2 |
A |
tau |
A |
A matrix
with the first column containing the partial derivative with respect to
and the second column contains the partial derivative with respect to
Taking the derivative with respect to yields:
Taking the derivative with respect to yields:
James Joseph Balamuta (JJB)
Obtain the first derivative of the Quantization Noise (QN) process.
deriv_qn(tau)
deriv_qn(tau)
tau |
A |
A matrix
with the first column containing
the partial derivative with respect to .
Taking the derivative with respect to yields:
James Joseph Balamuta (JJB)
Obtain the first derivative of the Random Walk (RW) process.
deriv_rw(tau)
deriv_rw(tau)
tau |
A |
A matrix
with the first column containing
the partial derivative with respect to .
Taking the derivative with respect to yields:
James Joseph Balamuta (JJB)
Obtain the first derivative of the Gaussian White Noise (WN) process.
deriv_wn(tau)
deriv_wn(tau)
tau |
A |
A matrix
with the first column containing
the partial derivative with respect to .
Taking the derivative with respect to yields:
James Joseph Balamuta (JJB)
This function computes each process to WV (haar) in a given model.
derivative_first_matrix(theta, desc, objdesc, tau)
derivative_first_matrix(theta, desc, objdesc, tau)
theta |
A |
desc |
A |
objdesc |
A |
tau |
A |
Function returns the matrix effectively known as "D"
A matrix
with the process derivatives going down the column
James Joseph Balamuta (JJB)
Performs the Box-Pierce test to assess the Null Hypothesis of Independence in a Time Series
diag_boxpierce(x, order = NULL, stop_lag = 20, stdres = FALSE, plot = TRUE)
diag_boxpierce(x, order = NULL, stop_lag = 20, stdres = FALSE, plot = TRUE)
x |
An |
order |
An |
stop_lag |
An |
stdres |
A |
plot |
A logical. If |
James Balamuta, Stéphane Guerrier, Yuming Zhang
Performs the Ljung-Box test to assess the Null Hypothesis of Independence in a Time Series
diag_ljungbox(x, order = NULL, stop_lag = 20, stdres = FALSE, plot = TRUE)
diag_ljungbox(x, order = NULL, stop_lag = 20, stdres = FALSE, plot = TRUE)
x |
An |
order |
An |
stop_lag |
An |
stdres |
A |
plot |
A logical. If |
James Balamuta, Stéphane Guerrier, Yuming Zhang
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.
diag_plot(Xt = NULL, model = NULL, resids = NULL, std = FALSE)
diag_plot(Xt = NULL, model = NULL, resids = NULL, std = FALSE)
Xt |
The data used to construct said model. |
model |
A |
resids |
A |
std |
A |
Yuming Zhang
Performs the Portmanteau test to assess the Null Hypothesis of Independence in a Time Series
diag_portmanteau_( x, order = NULL, stop_lag = 20, stdres = FALSE, test = "Ljung-Box", plot = TRUE )
diag_portmanteau_( x, order = NULL, stop_lag = 20, stdres = FALSE, test = "Ljung-Box", plot = TRUE )
x |
An |
order |
An |
stop_lag |
An |
stdres |
A |
test |
A |
plot |
A logical. If |
James Balamuta, Stéphane Guerrier, Yuming Zhang
Sets up the necessary backend for the DR process.
DR(omega = NULL)
DR(omega = NULL)
omega |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "DR"
slope
String containing simplified model
Number of parameters
y desc replicated x times
Depth of parameters e.g. list(1)
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
James Balamuta
DR() DR(omega=3.4)
DR() DR(omega=3.4)
This function compute the WV (haar) of a Drift process
dr_to_wv(omega, tau)
dr_to_wv(omega, tau)
omega |
A |
tau |
A |
A vec
containing the wavelet variance of the drift.
The Drift (DR) process has a Haar Wavelet Variance given by:
This function can fit a time series model to data using different methods.
estimate(model, Xt, method = "mle", demean = TRUE)
estimate(model, Xt, method = "mle", demean = TRUE)
model |
A time series model. |
Xt |
A |
method |
A |
demean |
A |
Stéphane Guerrier and Yuming Zhang
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")
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")
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.
evaluate( models, Xt, criterion = "IC", start = 0.8, demean = TRUE, print = TRUE )
evaluate( models, Xt, criterion = "IC", start = 0.8, demean = TRUE, print = TRUE )
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 |
demean |
A |
print |
logical. If |
AIC, BIC and HQ or MAPE
Stéphane Guerrier
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")
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")
Definition of a Fractional Gaussian Noise (FGN) Process
FGN(sigma2 = 1, H = 0.9999)
FGN(sigma2 = 1, H = 0.9999)
sigma2 |
A |
H |
A |
An S3 object containing the specified ts.model with the following structure:
Used in summary: "SIGMA2","H"
Parameter vector including ,
Number of parameters
String containing simplified model
"FGN"
Depth of Parameters e.g. list(1,1)
Find starting values? TRUE or FALSE (e.g. specified value)
Lionel Voirol, Davide Cucci
FGN() FGN(sigma2 = 1, H = 0.9999)
FGN() FGN(sigma2 = 1, H = 0.9999)
This function allows us to generate a non-stationary AR(1) block process.
gen_ar1blocks(phi, sigma2, n_total, n_block, scale = 10, title = NULL, seed = 135, ...)
gen_ar1blocks(phi, sigma2, n_total, n_block, scale = 10, title = NULL, seed = 135, ...)
phi |
A |
sigma2 |
A |
n_total |
An |
n_block |
An |
scale |
An |
title |
A |
seed |
An |
... |
Additional parameters. |
A vector
containing the AR(1) block process.
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.
Yuming Zhang and Haotian Xu
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)
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)
This function allows to generate a non-stationary bias-instability process.
gen_bi(sigma2, n_total, n_block, title = NULL, seed = 135, ...)
gen_bi(sigma2, n_total, n_block, title = NULL, seed = 135, ...)
sigma2 |
A |
n_total |
An |
n_block |
An |
title |
A |
seed |
An |
... |
Additional parameters. |
A vector
containing the bias-instability process.
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.
Yuming Zhang
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)
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)
Create a gts
object based on a time series model.
gen_gts( n, model, start = 0, end = NULL, freq = 1, unit_ts = NULL, unit_time = NULL, name_ts = NULL, name_time = NULL )
gen_gts( n, model, start = 0, end = NULL, freq = 1, unit_ts = NULL, unit_time = NULL, name_ts = NULL, name_time = NULL )
n |
An |
model |
A |
start |
A |
end |
A |
freq |
A |
unit_ts |
A |
unit_time |
A |
name_ts |
A |
name_time |
A |
This function accepts either a ts.model
object (e.g. AR1(phi = .3, sigma2 =1) + WN(sigma2 = 1)) or a simts
object.
A gts
object
James Balamuta and Wenchao Yang
# 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)
# 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)
Simulate a lts
object based on a supplied time series model.
gen_lts( n, model, start = 0, end = NULL, freq = 1, unit_ts = NULL, unit_time = NULL, name_ts = NULL, name_time = NULL, process = NULL )
gen_lts( n, model, start = 0, end = NULL, freq = 1, unit_ts = NULL, unit_time = NULL, name_ts = NULL, name_time = NULL, process = NULL )
n |
An |
model |
A |
start |
A |
end |
A |
freq |
A |
unit_ts |
A |
unit_time |
A |
name_ts |
A |
name_time |
A |
process |
A |
This function accepts either a ts.model
object (e.g. AR1(phi = .3, sigma2 =1) + WN(sigma2 = 1)) or a simts
object.
A lts
object with the following attributes:
The time of the first observation.
The time of the last observation.
Numeric representation of the sampling frequency/rate.
A string reporting the unit of measurement.
Name of the generated dataset.
A vector
that contains model names of decomposed and combined processes
James Balamuta, Wenchao Yang, and Justin Lee
# AR set.seed(1336) model = AR1(phi = .99, sigma2 = 1) + WN(sigma2 = 1) test = gen_lts(1000, model) plot(test)
# AR set.seed(1336) model = AR1(phi = .99, sigma2 = 1) + WN(sigma2 = 1) test = gen_lts(1000, model) plot(test)
This function allows to generate a non-stationary white noise process.
gen_nswn(n_total, title = NULL, seed = 135, ...)
gen_nswn(n_total, title = NULL, seed = 135, ...)
n_total |
An |
title |
A |
seed |
An |
... |
Additional parameters. |
A vector
containing the non-stationary white noise process.
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.
Yuming Zhang
Xt = gen_nswn(n_total = 1000) plot(Xt) Yt = gen_nswn(n_total = 2000, title = "non-stationary white noise process", seed = 1960) plot(Yt)
Xt = gen_nswn(n_total = 1000) plot(Xt) Yt = gen_nswn(n_total = 2000, title = "non-stationary white noise process", seed = 1960) plot(Yt)
Sets up the necessary backend for the GM process.
GM(beta = NULL, sigma2_gm = 1)
GM(beta = NULL, sigma2_gm = 1)
beta |
A |
sigma2_gm |
A |
When supplying values for and
,
these parameters should be of a GM process and NOT of an AR1. That is,
do not supply AR1 parameters such as
,
.
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.
An S3 object with called ts.model with the following structure:
Used in summary: "BETA","SIGMA2"
,
Number of parameters
String containing simplified model
"GM"
Depth of parameters e.g. list(1,1)
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
GM() GM(beta=.32, sigma2_gm=1.3)
GM() GM(beta=.32, sigma2_gm=1.3)
Performs estimation of time series models by using the GMWM estimator.
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 )
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 )
model |
A |
data |
A |
model.type |
A |
compute.v |
A |
robust |
A |
eff |
A |
alpha |
A |
seed |
An |
G |
An |
K |
An |
H |
An |
freq |
A |
This function is under work. Some of the features are active. Others... Not so much.
The V matrix is calculated by:
.
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
6. If FAST = TRUE, return these results. Else, continue.
Loop k = 1 to K
Loop h = 1 to H
7. Simulate xt under
8. Compute WV Empirical
END
9. Calculate the covariance matrix
10. Optimize the values to obtain
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:
"AR1": a first order autoregressive process with parameters
"GM": a guass-markov process
"ARMA": an autoregressive moving average process with parameters
"DR": a drift with parameter
"QN": a quantization noise process with parameter
"RW": a random walk process with parameter
"WN": a white noise process with parameter
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.
A gmwm
object with the structure:
estimate: Estimated Parameters Values from the GMWM Procedure
init.guess: Initial Starting Values given to the Optimization Algorithm
wv.empir: The data's empirical wavelet variance
ci_low: Lower Confidence Interval
ci_high: Upper Confidence Interval
orgV: Original V matrix
V: Updated V matrix (if bootstrapped)
omega: The V matrix inversed
obj.fun: Value of the objective function at Estimated Parameter Values
theo: Summed Theoretical Wavelet Variance
decomp.theo: Decomposed Theoretical Wavelet Variance by Process
scales: Scales of the GMWM Object
robust: Indicates if parameter estimation was done under robust or classical
eff: Level of efficiency of robust estimation
model.type: Models being guessed
compute.v: Type of V matrix computation
augmented: Indicates moments have been augmented
alpha: Alpha level used to generate confidence intervals
expect.diff: Mean of the First Difference of the Signal
N: Length of the Signal
G: Number of Guesses Performed
H: Number of Bootstrap replications
K: Number of V matrix bootstraps
model: ts.model
supplied to gmwm
model.hat: A new value of ts.model
object supplied to gmwm
starting: Indicates whether the procedure used the initial guessing approach
seed: Randomization seed used to generate the guessing values
freq: Frequency of data
Performs the GMWM estimation procedure using a parameter transform and sampling scheme specific to IMUs.
gmwm_imu(model, data, compute.v = "fast", robust = F, eff = 0.6, ...)
gmwm_imu(model, data, compute.v = "fast", robust = F, eff = 0.6, ...)
model |
A |
data |
A |
compute.v |
A |
robust |
A |
eff |
A |
... |
Other arguments passed to the main gmwm function |
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.
A gmwm
object with the structure:
estimateEstimated Parameters Values from the GMWM Procedure
init.guessInitial Starting Values given to the Optimization Algorithm
wv.empirThe data's empirical wavelet variance
ci_lowLower Confidence Interval
ci_highUpper Confidence Interval
orgVOriginal V matrix
VUpdated V matrix (if bootstrapped)
omegaThe V matrix inversed
obj.funValue of the objective function at Estimated Parameter Values
theoSummed Theoretical Wavelet Variance
decomp.theoDecomposed Theoretical Wavelet Variance by Process
scalesScales of the GMWM Object
robustIndicates if parameter estimation was done under robust or classical
effLevel of efficiency of robust estimation
model.typeModels being guessed
compute.vType of V matrix computation
augmentedIndicates moments have been augmented
alphaAlpha level used to generate confidence intervals
expect.diffMean of the First Difference of the Signal
NLength of the Signal
GNumber of Guesses Performed
HNumber of Bootstrap replications
KNumber of V matrix bootstraps
modelts.model
supplied to gmwm
model.hatA new value of ts.model
object supplied to gmwm
startingIndicates whether the procedure used the initial guessing approach
seedRandomization seed used to generate the guessing values
freqFrequency of data
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.
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 )
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 )
data |
A one-column |
start |
A |
end |
A |
freq |
A |
unit_ts |
A |
unit_time |
A |
name_ts |
A |
name_time |
A |
data_name |
A |
Time |
A numeric or character |
time_format |
A |
A gts
object
James Balamuta and Wenchao Yang
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)
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)
Hydrology data that indicates a robust approach may be preferred to a classical approach when estimating time series.
hydro
hydro
A time series object with frequency 12 starting at 1907 and going to 1972 for a total of 781 observations.
datamarket, mean-monthly-precipitation-1907-1972
Builds an IMU object that provides the program with gyroscope, accelerometer, and axis information per column in the dataset.
imu( data, gyros = NULL, accels = NULL, axis = NULL, freq = NULL, unit = NULL, name = NULL )
imu( data, gyros = NULL, accels = NULL, axis = NULL, freq = NULL, unit = NULL, name = NULL )
data |
A |
gyros |
A |
accels |
A |
axis |
A |
freq |
An |
unit |
A |
name |
A |
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.
An imu
object in the following attributes:
A vector
that indicates whether data contains gyroscope sensor, accelerometer sensor, or both.
A vector
that indicates how many columns of data are for gyroscope sensor and accelerometer sensor.
Axis value such as 'X', 'Y', 'Z'.
Observations per second.
String representation of the unit.
Name of the dataset.
James Balamuta and Wenchao Yang
## 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)
## 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)
Helper function for the IMU object to access rownames()
with a numeric conversion.
imu_time(x)
imu_time(x)
x |
A |
A vector
with numeric information.
Is the object a
gts
, imu
, or lts
object?
is.gts(x) is.imu(x) is.lts(x) is.ts.model(x)
is.gts(x) is.imu(x) is.lts(x) is.ts.model(x)
x |
A |
Uses inherits
over is
for speed.
A logical
value that indicates whether the object is of that class (TRUE) or not (FALSE).
James Balamuta
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.
lts( data, start = 0, end = NULL, freq = 1, unit_ts = NULL, unit_time = NULL, name_ts = NULL, name_time = NULL, process = NULL )
lts( data, start = 0, end = NULL, freq = 1, unit_ts = NULL, unit_time = NULL, name_ts = NULL, name_time = NULL, process = NULL )
data |
A multiple-column |
start |
A |
end |
A |
freq |
A |
unit_ts |
A |
unit_time |
A |
name_ts |
A |
name_time |
A |
process |
A |
A lts
object
Wenchao Yang and Justin Lee
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)
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)
and vector
Definition of a Mean deterministic vector returned by the matrix by vector product of matrix and vector
M(X, beta)
M(X, beta)
X |
A |
beta |
A |
An S3 object containing the specified ts.model with the following structure:
Used in summary: "X","BETA"
Matrix X, vector beta
Number of parameters
String containing simplified model
"M"
Depth of Parameters e.g. list(1,1)
Find starting values? TRUE or FALSE (e.g. specified value)
Lionel Voirol, Davide Cucci
X = matrix(rnorm(15*5), nrow = 15, ncol = 5) beta=seq(5) M(X = X, beta = beta)
X = matrix(rnorm(15*5), nrow = 15, ncol = 5) beta=seq(5) M(X = X, beta = beta)
Sets up the necessary backend for the MA(Q) process.
MA(theta = NULL, sigma2 = 1)
MA(theta = NULL, sigma2 = 1)
theta |
A |
sigma2 |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "MA-1","MA-2", ..., "MA-Q", "SIGMA2"
,
, ...,
,
Number of parameters
"MA"
String containing simplified model
Depth of parameters e.g. list(q,1)
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
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(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.
Definition of an Moving Average Process of Order 1
MA1(theta = NULL, sigma2 = 1)
MA1(theta = NULL, sigma2 = 1)
theta |
A |
sigma2 |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "MA1","SIGMA2"
,
Number of parameters
String containing simplified model
"MA1"
Depth of parameters e.g. list(1,1)
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
, where is iid from a zero
mean normal distribution with variance
.
James Balamuta
MA1() MA1(theta = .32, sigma2 = 1.3)
MA1() MA1(theta = .32, sigma2 = 1.3)
This function computes the WV (haar) of a Moving Average order 1 (MA1) process.
ma1_to_wv(theta, sigma2, tau)
ma1_to_wv(theta, sigma2, tau)
theta |
A |
sigma2 |
A |
tau |
A |
This function is significantly faster than its generalized counter part
arma_to_wv
.
A vec
containing the wavelet variance of the MA(1) process.
The Moving Average Order (MA(
)) process has a Haar Wavelet Variance given by:
Adds title, grid, and required x- and y-axes.
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 )
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 )
x_range |
A |
y_range |
A |
xlab |
A |
ylab |
A |
main |
A |
mar |
A |
add_axis_x |
A |
add_axis_y |
A |
col_box |
A |
col_grid |
A |
col_band |
A |
col_title |
A |
add_band |
A |
title_band_width |
A |
grid_lty |
A |
Added title, grid, and axes.
Stephane Guerrier and Justin Lee
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)
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)
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.
MAPE(model, Xt, start = 0.8, plot = TRUE)
MAPE(model, Xt, start = 0.8, plot = TRUE)
model |
A time series model. |
Xt |
A |
start |
A |
plot |
A |
The MAPE calculated based on one-step ahead prediction and reforecasting is returned along with its standard deviation.
Stéphane Guerrier and Yuming Zhang
Definition of a Matérn Process
MAT(sigma2 = 1, lambda = 0.35, alpha = 0.9)
MAT(sigma2 = 1, lambda = 0.35, alpha = 0.9)
sigma2 |
A |
lambda |
A |
alpha |
A |
An S3 object containing the specified ts.model with the following structure:
Used in summary: "SIGMA2","LAMBDA""ALPHA"
Parameter vector including ,
,
Number of parameters
String containing simplified model
"MAT"
Depth of Parameters e.g. list(1,1,1)
Find starting values? TRUE or FALSE (e.g. specified value)
Lionel Voirol, Davide Cucci
MAT() MAT(sigma2 = 1, lambda = 0.35, alpha = 0.9)
MAT() MAT(sigma2 = 1, lambda = 0.35, alpha = 0.9)
Non-parametric bootstrap to obtain the standard of the median of iid data.
np_boot_sd_med(x, B = 5000)
np_boot_sd_med(x, B = 5000)
x |
A |
B |
A |
Bootstrap standard error for the median
This function plots the time series output from a forecast method with approximate 68
plot_pred( x, model, n.ahead, level = NULL, xlab = NULL, ylab = NULL, main = NULL, ... )
plot_pred( x, model, n.ahead, level = NULL, xlab = NULL, ylab = NULL, main = NULL, ... )
x |
A |
model |
A |
n.ahead |
An |
level |
A |
xlab |
A |
ylab |
A |
main |
A |
... |
Additional parameters |
Yuming Zhang
Displays a plot of the Wavelet Variance (WV) with the CI values and the WV implied by the estimated parameters.
## 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, ... )
## 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, ... )
x |
A |
decomp |
A |
units |
A |
xlab |
A |
ylab |
A |
main |
A |
col_wv |
A |
col_ci |
A |
nb_ticks_x |
An |
nb_ticks_y |
An |
legend_position |
A |
ci_wv |
A |
point_cex |
A |
point_pch |
A |
... |
Additional arguments affecting the plot. |
Plot of WV and relative confidence intervals for each scale.
Stephane Guerrier and Yuming Zhang
The function plots the output of the theo_pacf
and auto_corr
functions (partial autocovariance or autocorrelation functions).
## 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, ... )
## 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, ... )
x |
|
xlab |
A |
ylab |
A |
show.ci |
A |
alpha |
A |
col_ci |
A |
transparency |
A |
main |
A |
parValue |
A |
... |
Additional parameters |
Yunxiang Zhang and Yuming Zhang
# 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 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")
The function plots the output of the theo_acf
and auto_corr
functions (autocovariance or autocorrelation functions).
## 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, ... )
## 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, ... )
x |
An |
xlab |
A |
ylab |
A |
show.ci |
A |
alpha |
A |
col_ci |
A |
transparency |
A |
main |
A |
parValue |
A |
... |
Additional parameters |
Yunxiang Zhang, Stéphane Guerrier and Yuming Zhang
# 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")
# 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
PLP(sigma2 = 1, d = 0.4)
PLP(sigma2 = 1, d = 0.4)
sigma2 |
A |
d |
A |
An S3 object containing the specified ts.model with the following structure:
Used in summary: "SIGMA2","d"
Parameter vector including ,
Number of parameters
String containing simplified model
"PLP"
Depth of Parameters e.g. list(1,1)
Find starting values? TRUE or FALSE (e.g. specified value)
Lionel Voirol, Davide Cucci
PLP() PLP(sigma2 = 1, d = 0.4)
PLP() PLP(sigma2 = 1, d = 0.4)
This function plots the time series forecast.
## S3 method for class 'fitsimts' predict( object, n.ahead = 10, show_last = 100, level = NULL, xlab = NULL, ylab = NULL, main = NULL, plot = TRUE, ... )
## S3 method for class 'fitsimts' predict( object, n.ahead = 10, show_last = 100, level = NULL, xlab = NULL, ylab = NULL, main = NULL, plot = TRUE, ... )
object |
A |
n.ahead |
An |
show_last |
A |
level |
A |
xlab |
A |
ylab |
A |
main |
A |
plot |
A |
... |
Additional arguments. |
Stéphane Guerrier and Yuming Zhang
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))
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))
Creates a prediction using the estimated values of GMWM through the ARIMA function within R.
## S3 method for class 'gmwm' predict(object, data.in.gmwm, n.ahead = 1, ...)
## S3 method for class 'gmwm' predict(object, data.in.gmwm, n.ahead = 1, ...)
object |
A |
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 |
A predict.gmwm
object with:
predPredictions
seStandard Errors
residResiduals from ARIMA ML Fit
Sets up the necessary backend for the QN process.
QN(q2 = NULL)
QN(q2 = NULL)
q2 |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "QN"
Number of parameters
String containing simplified model
y desc replicated x times
Depth of parameters e.g. list(1)
Guess starting values? TRUE or FALSE (e.g. specified value)
James Balamuta
QN() QN(q2=3.4)
QN() QN(q2=3.4)
This function compute the Haar WV of a Quantisation Noise (QN) process
qn_to_wv(q2, tau)
qn_to_wv(q2, tau)
q2 |
A |
tau |
A |
A vec
containing the wavelet variance of the QN.
The Quantization Noise (QN) process has a Haar Wavelet Variance given by:
Process binary files within the
read.imu(file, type, unit = NULL, name = NULL)
read.imu(file, type, unit = NULL, name = NULL)
file |
A |
type |
A |
unit |
A |
name |
A |
Currently supports the following IMUs:
IMAR
LN200
LN200IG
IXSEA
NAVCHIP_INT
NAVCHIP_FLT
An imu
object that contains 3 gyroscopes and 3 accelerometers in that order.
James Balamuta We hope to soon be able to support delimited files.
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++.
## 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)
## 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)
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.
resid_plot(res, std = FALSE, type = "hist", ...)
resid_plot(res, std = FALSE, type = "hist", ...)
res |
A |
std |
A |
type |
A |
... |
Additional parameters |
Yuming Zhang
Creates a rgmwm
object to compare the results generated by robust/classical method.
rgmwm(model, data, eff = c(0.9, 0.8, 0.6), ...)
rgmwm(model, data, eff = c(0.9, 0.8, 0.6), ...)
model |
A |
data |
A |
eff |
A |
... |
Other arguments passed to the main |
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.
A rgmwm
object
Enables sampling from a truncated normal
rtruncated_normal(n, mu, sigma, a, b)
rtruncated_normal(n, mu, sigma, a, b)
n |
An |
mu |
A |
sigma |
A |
a |
A |
b |
A |
Sets up the necessary backend for the RW process.
RW(gamma2 = NULL)
RW(gamma2 = NULL)
gamma2 |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "RW"
Number of parameters
String containing simplified model
y desc replicated x times
Depth of parameters e.g. list(1)
Guess starting values? TRUE or FALSE (e.g. specified value)
We consider the following model:
where is iid
and follows a standard normal distribution.
James Balamuta
RW() RW(gamma2=3.4)
RW() RW(gamma2=3.4)
This function compute the WV (haar) of a Random Walk process
rw_to_wv(gamma2, tau)
rw_to_wv(gamma2, tau)
gamma2 |
A |
tau |
A |
A vec
containing the wavelet variance of the random walk.
The Random Walk (RW) process has a Haar Wavelet Variance given by:
The RW2dimension function computes direction random walk moves.
RW2dimension(steps = 100, probs = c(0.25, 0.5, 0.75))
RW2dimension(steps = 100, probs = c(0.25, 0.5, 0.75))
steps |
An |
probs |
A |
Stéphane Guerrier
RW2dimension(steps = 50, probs = c(0.2, 0.5, 0.6))
RW2dimension(steps = 50, probs = c(0.2, 0.5, 0.6))
Sets up the necessary backend for the SARIMA process.
SARIMA(ar = 1, i = 0, ma = 1, sar = 1, si = 0, sma = 1, s = 12, sigma2 = 1)
SARIMA(ar = 1, i = 0, ma = 1, sar = 1, si = 0, sma = 1, s = 12, sigma2 = 1)
ar |
A |
i |
An |
ma |
A |
sar |
A |
si |
An |
sma |
A |
s |
An |
sigma2 |
A |
A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation unlike R.
An S3 object with called ts.model with the following structure:
,
,
,
Number of parameters
Type of model
Type of model (after simplification)
String containing simplified model
y desc replicated x times
Depth of Parameters e.g. list(c(length(ar), length(ma), length(sar), length(sma), 1, i, si) )
Guess Starting values? TRUE or FALSE (e.g. specified value)
James Balamuta
# 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 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)
Sets up the necessary backend for the SARMA process.
SARMA(ar = 1, ma = 1, sar = 1, sma = 1, s = 12, sigma2 = 1)
SARMA(ar = 1, ma = 1, sar = 1, sma = 1, s = 12, sigma2 = 1)
ar |
A |
ma |
A |
sar |
A |
sma |
A |
s |
A |
sigma2 |
A |
A variance is required since the model generation statements utilize randomization functions expecting a variance instead of a standard deviation unlike R.
An S3 object with called ts.model with the following structure:
,
,
,
Number of Parameters
String containing simplified model
y desc replicated x times
Depth of Parameters e.g. list(c(length(ar), length(ma), length(sar), length(sma), 1) )
Guess Starting values? TRUE or FALSE (e.g. specified value)
James Balamuta
# 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)
# 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)
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.
savingrt
savingrt
A gts time series object with frequency 12 starting at 1959 and going to 2016 for a total of 691 observations.
https://fred.stlouisfed.org/series/PSAVERT
This function performs model fitting and calculates the model selection criteria to be plotted.
select(model, Xt, include.mean = TRUE, criterion = "aic", plot = TRUE)
select(model, Xt, include.mean = TRUE, criterion = "aic", plot = TRUE)
model |
A time series model (only ARIMA are currently supported). |
Xt |
A |
include.mean |
A |
criterion |
A |
plot |
A |
Stéphane Guerrier and Yuming Zhang
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)
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)
This function performs model fitting and calculates the model selection criteria to be plotted or used in best_model
function.
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)
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)
xt |
A |
p.min |
An |
p.max |
An |
d |
An |
q.min |
An |
q.max |
An |
include.mean |
A |
plot |
A |
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)
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)
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.
simple_diag_plot(Xt, model, std = FALSE)
simple_diag_plot(Xt, model, std = FALSE)
Xt |
The original time series data. |
model |
The |
std |
A |
Yuming Zhang
Simplify and print SARIMA model
simplified_print_SARIMA(p, i, q, P, si, Q, s)
simplified_print_SARIMA(p, i, q, P, si, Q, s)
p |
An |
i |
An |
q |
An |
P |
An |
si |
An |
Q |
An |
s |
An |
An S3 object with the following structure:
String containing simplified model
Type of model (after simplification)
Stephane Guerrier
Definition of a Sinusoidal (SIN) Process
SIN(alpha2 = 9e-04, beta = 0.06, U = NULL)
SIN(alpha2 = 9e-04, beta = 0.06, U = NULL)
alpha2 |
A |
beta |
A |
U |
A |
An S3 object containing the specified ts.model with the following structure:
Used in summary: "ALPHA2","BETA"
Parameter vector including ,
Number of parameters
String containing simplified model
"SIN"
Depth of Parameters e.g. list(1,1)
Find starting values? TRUE or FALSE (e.g. specified value)
We consider the following sinusoidal process :
, where
and
Lionel Voirol
SIN() SIN(alpha2 = .5, beta = .05)
SIN() SIN(alpha2 = .5, beta = .05)
Displays summary information about fitsimts object
## S3 method for class 'fitsimts' summary(object, ...)
## S3 method for class 'fitsimts' summary(object, ...)
object |
A |
... |
Other arguments passed to specific methods |
Estimated parameters values with confidence intervals and standard errors.
Stéphane Guerrier
Displays summary information about GMWM object
## 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, ... )
## 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, ... )
object |
A |
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 |
... |
Other arguments passed to specific methods |
A summary.gmwm
object with:
estimateEstimated Theta Values
testinfoGoodness of Fit Information
inferenceInference performed? T/F
bs.gofBootstrap GOF? T/F
bs.gof.p.ciBootstrap GOF P-Value CI? T/F
bs.theta.estBootstrap Theta Estimates? T/F
bs.ciBootstrap CI? T/F
startingIndicates if program supplied initial starting values
seedSeed used during guessing / bootstrapping
obj.funValue of obj.fun at minimized theta
NLength of Time Series
JJB
This function computes the theoretical Autocorrelation (ACF) of an ARMA process.
theo_acf(ar, ma = NULL, lagmax = 20)
theo_acf(ar, ma = NULL, lagmax = 20)
ar |
A |
ma |
A |
lagmax |
An |
Yuming Zhang
# 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)
# 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)
This function computes the theoretical Partial Autocorrelation (PACF) of an ARMA process.
theo_pacf(ar, ma = NULL, lagmax = 20)
theo_pacf(ar, ma = NULL, lagmax = 20)
ar |
A |
ma |
A |
lagmax |
An |
Yuming Zhang
# 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)
# 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)
Provides a way to estimate different models over the previously estimated wavelet variance values and covariance matrix.
## S3 method for class 'gmwm' update(object, model, ...)
## S3 method for class 'gmwm' update(object, model, ...)
object |
A |
model |
A |
... |
Additional parameters (not used) |
A gmwm
object with the structure:
estimateEstimated Parameters Values from the GMWM Procedure
init.guessInitial Starting Values given to the Optimization Algorithm
wv.empirThe data's empirical wavelet variance
ci_lowLower Confidence Interval
ci_highUpper Confidence Interval
orgVOriginal V matrix
VUpdated V matrix (if bootstrapped)
omegaThe V matrix inversed
obj.funValue of the objective function at Estimated Parameter Values
theoSummed Theoretical Wavelet Variance
decomp.theoDecomposed Theoretical Wavelet Variance by Process
scalesScales of the GMWM Object
robustIndicates if parameter estimation was done under robust or classical
effLevel of efficiency of robust estimation
model.typeModels being guessed
compute.vType of V matrix computation
augmentedIndicates moments have been augmented
alphaAlpha level used to generate confidence intervals
expect.diffMean of the First Difference of the Signal
NLength of the Signal
GNumber of Guesses Performed
HNumber of Bootstrap replications
KNumber of V matrix bootstraps
modelts.model
supplied to gmwm
model.hatA new value of ts.model
object supplied to gmwm
startingIndicates whether the procedure used the initial guessing approach
seedRandomization seed used to generate the guessing values
freqFrequency of data
Update the attributes of lts
, gts
and imu
object
## 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, ...)
## 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, ...)
object |
A |
type |
A |
new |
The updated value for the attribute |
keep.start |
A |
... |
Further arguments passed to or from other methods. |
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.
An object with the updated attribute.
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')
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')
Used to access different properties of the
gts
, imu
, or lts
object.
value(x, type) ## S3 method for class 'imu' value(x, type)
value(x, type) ## S3 method for class 'imu' value(x, type)
x |
A |
type |
A |
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
The method will return a single numeric or string result depending on the slot being accessed.
value(imu)
: Access imu
object properties
James Balamuta
Sets up the necessary backend for the WN process.
WN(sigma2 = NULL)
WN(sigma2 = NULL)
sigma2 |
A |
An S3 object with called ts.model with the following structure:
Used in summary: "WN"
Number of Parameters
String containing simplified model
y desc replicated x times
Depth of Parameters e.g. list(1)
Guess Starting values? TRUE or FALSE (e.g. specified value)
In this process, is iid from a zero mean normal distribution with variance
James Balamuta
WN() WN(sigma2=3.4)
WN() WN(sigma2=3.4)
This function compute the Haar WV of a Gaussian White Noise process
wn_to_wv(sigma2, tau)
wn_to_wv(sigma2, tau)
sigma2 |
A |
tau |
A |
A vec
containing the wavelet variance of the white noise.
The Gaussian White Noise (WN) process has a Haar Wavelet Variance given by: