Package 'ADTSA'

Title: Time Series Analysis
Description: Analyzes autocorrelation and partial autocorrelation using surrogate methods and bootstrapping, and computes the acceleration constants for the vectorized moving block bootstrap provided by this package. It generates percentile, bias-corrected, and accelerated intervals and estimates partial autocorrelations using Durbin-Levinson. This package calculates the autocorrelation power spectrum, computes cross-correlations between two time series, computes bandwidth for any time series, and performs autocorrelation frequency analysis. It also calculates the periodicity of a time series.
Authors: Hossein Hassani [aut], Masoud Yarmohammadi [aut], Mohammad Reza Yeganegi [aut], Leila Marvian Mashhad [aut, cre]
Maintainer: Leila Marvian Mashhad <[email protected]>
License: GPL-3
Version: 1.0.1
Built: 2025-01-31 05:08:50 UTC
Source: https://github.com/cran/ADTSA

Help Index


Frequency Analysis of Autocorrelation in a Time Series.

Description

This function performs autocorrelation frequency analysis in a time series.

Usage

Analyze_Fre_Acf(ts, max_frequency = 0.5)

Arguments

ts

a numeric vector of time series data.

max_frequency

the maximum frequency under consideration.

Value

A data frame.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
Analyze_Fre_Acf(co2)

Computing Bandwidth of Autococorrelation in Time Series

Description

This function calculates the bandwidth of autocorrelation in a time series.

Usage

Astimate_Acf_Band(ts, confidence_level = 0.95)

Arguments

ts

a numeric vector of time series data.

confidence_level

confidence level for bandwidth calculation.

Value

A number.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
Astimate_Acf_Band(co2)

Calculation of Cross-Correlation

Description

This function calculates the cross correlation between two time series.

Usage

Cal_Cross_Corr(ts1, ts2, max_lag)

Arguments

ts1

a numeric vector of the first time series data.

ts2

a numeric vector of the second time series data.

max_lag

maximum lag at which to compute cross-correlation.

Value

A data frame.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
data(sunspots)
Cal_Cross_Corr(co2,sunspots,4)

Utilizing Durbin-Levinson Algorithm for Estimating Partial Autocorrelations

Description

This function calculates partial autocorrelations utilizing the Durbin-Levinson algorithm.

Usage

Der_Lev_Pac(x)

Arguments

x

a vector of autocorrelations.

Value

a vector of partial autocorrelations.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
Der_Lev_Pac(co2)

Estimation of Autocorrelation Power Spectrum (ACPS)

Description

This function is used to estimate the autocorrelation power spectrum (ACPS) of the data.

Usage

Estimate_Acps(ts, method = "periodogram")

Arguments

ts

a vector of time series data.

method

periodogram method for power spectrum estimation.

Value

A vector.

Author(s)

Hossein hassani, Masoud yarmohammdi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
Estimate_Acps(co2)

Calculating the Acceleration

Description

This function calculates the acceleration for the bias and acceleration corrected intervals

Usage

get.ahat(x)

Arguments

x

vector of resampling estimates to compute the acceleration.

Value

The accelaration estimate.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

x = rnorm(100)
get.ahat(x)

The Acceleration Constant for the Alternative Data Method

Description

This function calculates the acceleration constant for the alternative data method. This is done by sequentially removing one observation from the sample data points.

Usage

JN_ACSDM(ts, lgmx)

Arguments

ts

a vector of time series data.

lgmx

maximum lag at which to compute autocorrelations.

Value

A vector of accelerations for autocorrelations up to lagmax.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
JN_ACSDM(co2,4)

The Acceleration of the Vectorized Moving Block Bootstrap

Description

This function computes the acceleration constants for the vectorized moving block bootstrap, which is a method used to generate a large number of replications of a time series sample in order to estimate the sampling distribution of a statistic.

Usage

JN_VMBBA(ts, lgmx, bs)

Arguments

ts

a vector of time series data.

lgmx

maximum lag at which to compute autocorrelations.

bs

block size of the vectorized moving block bootstrap.

Value

a vector of the acceleration constants for autocorrelations up to lagmax.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
JN_VMBBA(co2, lgmx=5, bs = 2)

Estimating autocorrelations for vectorized moving block

Description

This function calculates autocorrelations for vectorized moving block bootstrap samples based on the position indices of pairs of observations.

Usage

MB_Ac(pair_mat, ts)

Arguments

pair_mat

a list of position indices of pairs of observations to calculate autocorrelations. An object returned by the function pairwise_MBL.

ts

a numeric vector of time series data.

Details

If there are missing values, this function estimates autocorrelations assuming complete data. Therefore, in such cases, the result is not valid.

Value

a vector of estimated autocorrelations.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

mat <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)
ts <- 1:6
lgmx <- 2
l_ts <- 5
pair_mat1 = pairwise_MBL(mat, lgmx, l_ts)
MB_Ac(pair_mat1, ts)

Percentile and Bias-corrected and accelerated intervals

Description

The first function P_CI creats percentile intervals. The second function B_CI builds Bias-corrected and accelerated intervals.

Usage

P_CI(e.b,a1,a2)

B_CI(e.b,e,B,ahat,a1,a2)

Arguments

e.b

a matrix of bootstrap sample estimates for multiple variables. Each column represents one variable.

a1

the percentages for the lower limits of confidence intervals.

a2

the percentages for the upper limits of confidence intervals.

e

the original sample estimates.

B

number of replications.

ahat

estimated acceleration constant.

Value

a matrix of the obtained confidence intervals for (partial) autocorrelations.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

set.seed(123) 
e <- rnorm(1, mean = 5, sd = 1) 
e.b <- matrix(rnorm(1000, mean = 5, sd = 1), ncol = 10) # Bootstrap data

B <- 100 # Number of bootstrap samples
ahat <- 0.4 # Bias correction parameter
a1 <- 0.025 # Low confidence level
a2 <- 0.975 # High level of confidence

P_CI(e.b,a1,a2)
B_CI(e.b, e, B, ahat, a1, a2)

Creating Pairs of Entries for the Vectorized Moving Block

Description

This function yields index positions of pairs of observations for the vectorized moving block bootstrap.

Usage

pairwise_MBL(mat, lgmx, l_ts)

Arguments

mat

a matrix giving position indices for observations in each resampled block. Columns represent different blocks.

lgmx

maximum lag at which to calculate autocorrelations.

l_ts

time series length or the number of time points.

Details

Autocorrelation at lag h is a statistical measure that assesses the similarity between observations in a time series that are h lags apart. pairwise_MBL returns indices for both the observations in id.M, as well as those h lags apart.If some indices exceed the length of the time series, then the corresponding pairs of observations are discarded.

Value

A list of pairs of indices for computing autocorrelations up to lagmax, each containing a matrix of indices for autocorrelation at a lag no greater than lagmax.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

mat <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)
lgmx <- 2
l_ts <- 5
pairwise_MBL(mat, lgmx, l_ts)

Calculation of Time Series Periodicity

Description

One of the uses of spectrum density and periodogram is to detect the periodicity of the series. If the spectral density or periodogram or any estimator has a peak at a frequency, the periodicity of the series can be understood. If we reverse the frequency at which the peak is located, the period of the series is obtained.

Usage

Period_ts(ts)

Arguments

ts

a vector of time series data.

Value

A number.

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

data(co2)
Period_ts(co2)

The Alternative Data Method

Description

This function performs the surrogate data method for testing auto (partial) correlations.

Usage

Sug_dm(ahat, ts, a1, a2, boot, lgmx)

Arguments

ahat

a vector of estimated acceleration constants for autocorrelations up to lagmax.

ts

a vector of time series data.

a1

the percentages for the lower limits of confidence intervals.

a2

the percentages for the upper limits of confidence intervals.

boot

number of bootstrap replications.

lgmx

maximum lag at which to calculate autocorrelations.

Value

A list with two components: acf and pacf.

For acf:

se: standard error estimates for autocorrelations.

CI: a list of estimated confidence intervals for autocorrelations. Contain two elements: per and BCa

For pacf:

se: standard error estimates for partial autocorrelations.

CI: a list of estimated confidence intervals for partial autocorrelations. Contain two elements: per and BCa

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

set.seed(123)
ts <- rnorm(100)

ahat <- list(acf=c() ,pacf=c())
ahat$acf <- acf(ts, lag.max = 19, plot = FALSE)$acf[,,1]
ahat$pacf <- pacf(ts, lag.max = 19, plot = FALSE)$acf[,,1]

a1 <- 0.025
a2 <- 0.975
boot <- 100
lgmx <- 20

Sug_dm(ahat, ts, a1, a2, boot, lgmx)

The vectorized moving block bootstrap.

Description

The VMB function tests for (partial) autocorrelations using the Vectorized Moving Block (VMB) launcher.

Usage

VMBB(acf.est, pacf.est, ahat, ts, bs, a1, a2, boot, lgmx)

Arguments

acf.est

a vector of sample autocorrelation estimates up to lagmax.

pacf.est

a vector of sample partial autocorrelation estimates up to lagmax.

ahat

a vector of estimated acceleration constants for autocorrelations up to lagmax. An object returned by JN_VMBBA.

ts

a vector of time series data.

bs

block size for the VMBB bootstrap.

a1

the percentages for the lower limits of confidence intervals.

a2

the percentages for the upper limits of confidence intervals.

boot

number of bootstrap replications.

lgmx

maximum lag at which to calculate autocorrelations.

Value

A list with two components: acf and pacf.

For acf:

se: standard error estimates for autocorrelations.

CI: a list of estimated confidence intervals for autocorrelations. Contain two elements: per and BCa

For pacf:

se: standard error estimates for partial autocorrelations.

CI: a list of estimated confidence intervals for partial autocorrelations. Contain two elements: per and BCa

Author(s)

Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.

Examples

ts <- rnorm(100)
acf_est <- acf(ts, plot = FALSE)$acf[-21]
pacf_est <- pacf(ts, plot = FALSE)$acf[-21]

ahat <- list(acf=c() ,pacf=c())
ahat$acf <- acf(ts, lag.max = 19, plot = FALSE)$acf[,,1]
ahat$pacf <- pacf(ts, lag.max = 19, plot = FALSE)$acf[,,1]

bs <- 10
a1 <- 0.025
a2 <- 0.975
boot <- 100
lgmx <- 20

VMBB(acf_est, pacf_est, ahat, ts, bs, a1, a2, boot, lgmx)