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 |
This function performs autocorrelation frequency analysis in a time series.
Analyze_Fre_Acf(ts, max_frequency = 0.5)
Analyze_Fre_Acf(ts, max_frequency = 0.5)
ts |
a numeric vector of time series data. |
max_frequency |
the maximum frequency under consideration. |
A data frame.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) Analyze_Fre_Acf(co2)
data(co2) Analyze_Fre_Acf(co2)
This function calculates the bandwidth of autocorrelation in a time series.
Astimate_Acf_Band(ts, confidence_level = 0.95)
Astimate_Acf_Band(ts, confidence_level = 0.95)
ts |
a numeric vector of time series data. |
confidence_level |
confidence level for bandwidth calculation. |
A number.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) Astimate_Acf_Band(co2)
data(co2) Astimate_Acf_Band(co2)
This function calculates the cross correlation between two time series.
Cal_Cross_Corr(ts1, ts2, max_lag)
Cal_Cross_Corr(ts1, ts2, max_lag)
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. |
A data frame.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) data(sunspots) Cal_Cross_Corr(co2,sunspots,4)
data(co2) data(sunspots) Cal_Cross_Corr(co2,sunspots,4)
This function calculates partial autocorrelations utilizing the Durbin-Levinson algorithm.
Der_Lev_Pac(x)
Der_Lev_Pac(x)
x |
a vector of autocorrelations. |
a vector of partial autocorrelations.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) Der_Lev_Pac(co2)
data(co2) Der_Lev_Pac(co2)
This function is used to estimate the autocorrelation power spectrum (ACPS) of the data.
Estimate_Acps(ts, method = "periodogram")
Estimate_Acps(ts, method = "periodogram")
ts |
a vector of time series data. |
method |
periodogram method for power spectrum estimation. |
A vector.
Hossein hassani, Masoud yarmohammdi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) Estimate_Acps(co2)
data(co2) Estimate_Acps(co2)
This function calculates the acceleration for the bias and acceleration corrected intervals
get.ahat(x)
get.ahat(x)
x |
vector of resampling estimates to compute the acceleration. |
The accelaration estimate.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
x = rnorm(100) get.ahat(x)
x = rnorm(100) get.ahat(x)
This function calculates the acceleration constant for the alternative data method. This is done by sequentially removing one observation from the sample data points.
JN_ACSDM(ts, lgmx)
JN_ACSDM(ts, lgmx)
ts |
a vector of time series data. |
lgmx |
maximum lag at which to compute autocorrelations. |
A vector of accelerations for autocorrelations up to lagmax.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) JN_ACSDM(co2,4)
data(co2) JN_ACSDM(co2,4)
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.
JN_VMBBA(ts, lgmx, bs)
JN_VMBBA(ts, lgmx, bs)
ts |
a vector of time series data. |
lgmx |
maximum lag at which to compute autocorrelations. |
bs |
block size of the vectorized moving block bootstrap. |
a vector of the acceleration constants for autocorrelations up to lagmax.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) JN_VMBBA(co2, lgmx=5, bs = 2)
data(co2) JN_VMBBA(co2, lgmx=5, bs = 2)
This function calculates autocorrelations for vectorized moving block bootstrap samples based on the position indices of pairs of observations.
MB_Ac(pair_mat, ts)
MB_Ac(pair_mat, ts)
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. |
If there are missing values, this function estimates autocorrelations assuming complete data. Therefore, in such cases, the result is not valid.
a vector of estimated autocorrelations.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
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)
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)
The first function P_CI creats percentile intervals. The second function B_CI builds Bias-corrected and accelerated intervals.
P_CI(e.b,a1,a2) B_CI(e.b,e,B,ahat,a1,a2)
P_CI(e.b,a1,a2) B_CI(e.b,e,B,ahat,a1,a2)
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. |
a matrix of the obtained confidence intervals for (partial) autocorrelations.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
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)
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)
This function yields index positions of pairs of observations for the vectorized moving block bootstrap.
pairwise_MBL(mat, lgmx, l_ts)
pairwise_MBL(mat, lgmx, l_ts)
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. |
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.
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.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
mat <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2) lgmx <- 2 l_ts <- 5 pairwise_MBL(mat, lgmx, l_ts)
mat <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2) lgmx <- 2 l_ts <- 5 pairwise_MBL(mat, lgmx, l_ts)
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.
Period_ts(ts)
Period_ts(ts)
ts |
a vector of time series data. |
A number.
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
data(co2) Period_ts(co2)
data(co2) Period_ts(co2)
This function performs the surrogate data method for testing auto (partial) correlations.
Sug_dm(ahat, ts, a1, a2, boot, lgmx)
Sug_dm(ahat, ts, a1, a2, boot, lgmx)
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. |
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
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
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)
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 VMB function tests for (partial) autocorrelations using the Vectorized Moving Block (VMB) launcher.
VMBB(acf.est, pacf.est, ahat, ts, bs, a1, a2, boot, lgmx)
VMBB(acf.est, pacf.est, ahat, ts, bs, a1, a2, boot, lgmx)
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. |
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
Hossein hassani, Masoud yarmohammadi, Mohammad reza yeganegi and Leila Marvian Mashhad.
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)
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)