Type: Package
Title: Modified Iterative Cumulative Sum of Squares Algorithm
Version: 0.2.0
Maintainer: Andreu Sansó <andreu.sanso@uib.eu>
Description: Companion package of Carrion-i-Silvestre & Sansó (2023): "Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series". It implements the Modified Iterative Cumulative Sum of Squares Algorithm, which is an extension of the Iterative Cumulative Sum of Squares (ICSS) Algorithm of Inclan and Tiao (1994), and it checks for changes in the unconditional variance of a time series controlling for the tail index of the underlying distribution. The fourth order moment is estimated non-parametrically to avoid the size problems when the innovations are non-Gaussian (see, Sansó et al., 2004). Critical values and p-values are generated using a Generalized Extreme Value distribution approach. References Carrion-i-Silvestre J.J & Sansó A (2023) https://www.ub.edu/irea/working_papers/2023/202309.pdf. Inclan C & Tiao G.C (1994) <doi:10.1080/01621459.1994.10476824>, Sansó A & Aragó V & Carrion-i-Silvestre J.L (2004) https://dspace.uib.es/xmlui/bitstream/handle/11201/152078/524035.pdf.
License: GPL-2
Depends: R (≥ 3.5.0), dplyr
Imports: methods
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2024-08-22 11:00:17 UTC; HP
Author: Josep Lluís Carrion-i-Silvestre [aut], Andreu Sansó [aut, cre]
Repository: CRAN
Date/Publication: 2024-08-22 18:50:02 UTC

Hill's estimator of the tail index

Description

Computes the estimator of the tail index proposed by Hill (1975).

Usage

alpha_hill(x, k)

Arguments

x

A numeric vector.

k

Fraction of the upper tail to be used to estimate of the tail index.

Value

References

B. Hill (1975): A Simple General Approach to Inference About the Tail of a Distribution. The Annals of Mathematical Statistics 3, 1163-1174.

See Also

alpha_nr

Examples

alpha_hill(rnorm(500),k=0.1)

Nicolau & Rodrigues estimator of the tail index

Description

Computes the estimator of the tail index proposed by Nicolau & Rodrigues (2019).

Usage

alpha_nr(y, k)

Arguments

y

A numeric vector.

k

Fraction of the upper tail to be used to estimate of the tail index.

Value

References

J. Nicolau and P.M.M. Rodrigues (2019): A new regression-based tail index estimator. The Review of Economics and Statistics 101, 667-680.

See Also

alpha_hill

Examples

alpha_nr(rnorm(500),k=0.1)

Critical Values

Description

Computes critical values for the kappa_test statistic

Usage

cv.kappa(t, alpha, sig.lev)

Arguments

t

Sample size.

alpha

Value of the tail index between 2 and 4.

sig.lev

Significance level.

Value

Critical value.

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

See Also

p.val.kappa


Data used in the examples

Description

Log returns of the exchange rate South African Rand versus United States Dollar.

Usage

data(logReturnsRandDollar)

Value

Time series with 7705 observations.

Author(s)

J.L. Carrion-i-Silvestre and A. Sansó

Source

Paulo Rodrigues

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

Examples

data(logReturnsRandDollar)
names(data)

estimate.alpha

Description

Computes the estimator of the tail index (alpha) using Hill (1975) or Nicolau & Rodrigues (2019) estimators and tests both the hypothesis that alpha is bigger or equal to 4, and that alpha is lower or equal to 2.

Usage

estimate.alpha(x, sig.lev = 0.05, tail.est = "Hill", k = 0.1)

Arguments

x

A numeric vector.

sig.lev

Significance level. The default value is 0.05.

tail.est

Estimator of the tail index. The default value is "Hill", which uses Hill's (1975) estimator. "NR" uses Nicolau & Rodrigues (2019) estimator.

k

Fraction of the upper tail to be used to estimate of the tail index. The default value is 0.1.

Details

Used internally by micss.

Value

References

B. Hill (1975): A Simple General Approach to Inference About the Tail of a Distribution. The Annals of Mathematical Statistics 3, 1163-1174.

J. Nicolau and P.M.M. Rodrigues (2019): A new regression-based tail index estimator. The Review of Economics and Statistics 101, 667-680.


Iterative Cumulative Sum of Squares Algorithm

Description

Implements the ICSS algorithm of Inclan and Tiao (1994) using the CUMSUMQ test detailed in Carrion-i-Silvestre & Sansó (2023)

Usage

icss(e,sig.lev=0.05,kmax=NULL,alpha=NULL)

Arguments

e

A numeric vector. Stationary variable on which the constancy of unconditional variance is tested.

sig.lev

Significance level. The default value is 0.05

kmax

Maximum lag to be used for the estimation of the long-run fourth order moment. If not reported, an automatic procedure computes it depending on the sample size.

alpha

Tail index. If not reported, it is set at 4, which was the implicit assumption of Inclan & Tiao (1994). Values between 2 and 4 are allowed because this function is used by micss.

Value

nb

Number of breaks found by the algorithm.

tb

Vector with the time breaks.

Author(s)

J.L. Carrion-i-Silvestre and A. Sanso.

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

C. Inclan & G.C. Tiao (1994): Use of Cumulative Sums of Squares for Retrospective Detection of Changes of Variance. Journal of the American Statistical Association 89, 913-923.

See Also

micss print.icss plot.icss

Examples

set.seed(2)
e <- c(stats::rnorm(200),3*stats::rnorm(200))
o <- icss(e)
print.icss(o)

CUMSUMQ test to test for changes in the unconditional variance

Description

Computes the CUMSUMQ test to test for changes in the unconditional variance and reports the p-value adapted to the tail index and sample size

Usage

kappa_test(e,sig.lev=0.05,alpha=NULL,kmax=NULL)

Arguments

e

A numeric vector. Stationary variable on which the constancy of unconditional variance is tested.

sig.lev

Significance level. The default value is 0.05.

alpha

Tail index. Must be a number between 2 and 4. The default value is 4.

kmax

Maximum lag to be used for the estimation of the long-run fourth order moment. If not reported, an automatic procedure computes it depending on the sample size.

Details

It is only computed if the sample size is greater than 25 observations.

Value

kappa

CUMSUMQ test.

tb

Possible time of the break (with maximum value of the statistic).

cv

critical value at the specified significance level.

p.val

p-value.

Author(s)

J.L. Carrion-i-Silvestre and A. Sanso.

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

See Also

micss

Examples

data(logReturnsRandDollar)
e <- whitening(data$rand.dollar)$e # whitening
kappa_test(e)

Data used in the examples

Description

Log returns of the exchange rate South African Rand versus United States Dollar.

Usage

data(logReturnsRandDollar)

Value

Time series with 7705 observations.

Author(s)

J.L. Carrion-i-Silvestre and A. Sansó.

Source

Paulo Rodrigues

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

Examples

data(logReturnsRandDollar)
names(data)

# The following example replicates some of the results of Table 6 in
# Carrion-i-Silvestres & Sanso (2023)
data(logReturnsRandDollar)
e <- whitening(data$rand.dollar)$e  # pre-whitening
m <- micss(e)
print.micss(m)

lrv.spc.bartlett

Description

Estimation of the long-run variance using the Barlett window.

Usage

lrv.spc.bartlett(x, kmax = NULL)

Arguments

x

Stationary variable. A numeric vector.

kmax

Maximum lag to be used for the long-run estimation of the variance.

Details

Estimates the log-run fourth order moment when x are the squares of a variable.

Value

Estimation of the long-run variance.

References

D. Sul, P.C.B. Phillips & C.Y. Choi (2005): Prewhitening Bias in HAC Estimation, Oxford Bulletin of Economics and Statistics 67, 517-546.

D.W.K. Andrews & J.C. Monahan (1992): An Improved Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimator. Econometrica 60, 953-966.

Examples

lrv.spc.bartlett(rnorm(100))

Modiffied Iterative Cumulative Sum of Squares Algorithm

Description

Implements the MICSS algorithm of Carrion-i-Silvestre & Sansó (2023).

Usage

micss(e,sig.lev=0.05,kmax=NULL,alpha=NULL,tail.est="NR",k=0.1)

Arguments

e

A numeric vector. Stationary variable on which the constancy of unconditional variance is tested.

sig.lev

Significance level. The default value is 0.05.

kmax

Maximum lag to be used for the estimation of the long-run fourth order moment. If not reported, an automatic procedure computes it depending on the sample size.

alpha

Tail index. If not reported, it is estimated automatically.

tail.est

Estimator of the tail index. The default value is "NR", which uses Nicolau & Rodrigues (2019) estimator. "Hill" uses the Hill's (1975) estimator.

k

Fraction of the upper tail to be used to estimate of the tail index. The default value is 0.1.

Details

The tail index is estimated using the absolute values.

Value

icss

An object with the output of the icss algorithm.

alpha

An object with the output of the estimate.alpha.

Author(s)

J.L. Carrion-i-Silvestre and A. Sansó.

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

B. Hill (1975): A Simple General Approach to Inference About the Tail of a Distribution. The Annals of Mathematical Statistics 3, 1163-1174.

J. Nicolau & P.M.M. Rodrigues (2019): A new regression-based tail index estimator. The Review of Economics and Statistics 101, 667-680.

See Also

icss estimate.alpha print.micss plot.icss

Examples

set.seed(2)
e <- c(stats::rnorm(200),3*stats::rnorm(200))
o <- micss(e)
print.micss(o)

# The following example replicates some of the results of Table 6 in
# Carrion-i-Silvestres & Sanso (2023)
data(logReturnsRandDollar)
e <- whitening(data$rand.dollar)$e  # pre-whitening
m <- micss(e)
print.micss(m)

P-values

Description

Computes p-values for the kappa_test statistic

Usage

p.val.kappa(x, t, alpha)

Arguments

x

Value of the statistic.

t

Sample size.

alpha

Value of the tail index between 2 and 4.

Value

p-value.

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.

See Also

cv.kappa


plot.icss

Description

Plots the output of the ICSS algorithm.

Usage

## S3 method for class 'icss'
plot(x, type = "std", title = NULL, ...)

Arguments

x

An object with the output of icss or micss.

type

Type of graphic. 3 possibilities: "std", which is the default, plots the absolute value of the variable and the standard deviation; "var" plots the squares of the variable and the variance; "res.std" plots the standardized residuals.

title

Title of the graphic.

...

Further arguments passed to or from other methods.

Value

No return value. It generates a plot the output of micss or icss

Examples

set.seed(2)
e <- c(stats::rnorm(200),3*stats::rnorm(200))
o <- micss(e)
plot.icss(o,title="Example of the MICSS algorithm")

print.icss

Description

Prints the output of icss.

Usage

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

Arguments

x

An object with the output of the icss algorithm.

...

Further arguments passed to or from other methods.

Details

Used internally by icss.

Value

No return value. It prints the output of icss

Examples

set.seed(2)
e <- c(stats::rnorm(200),3*stats::rnorm(200))
o <- icss(e)
print.icss(o)

print.micss

Description

Prints the output of micss.

Usage

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

Arguments

x

An object with the output of the micss algorithm.

...

Further arguments passed to or from other methods.

Value

No return value. It prints the output of micss

Examples

set.seed(2)
e <- c(stats::rnorm(200),3*stats::rnorm(200))
o <- micss(e)
print.micss(o)

sr_loc

Description

Computes the location parameter for the GEV approximation to the distribution of kappa_test statistic

Usage

sr_loc(t, alpha, lmax = NULL)

Arguments

t

Sample size

alpha

Value of the tail index between 2 and 4

lmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations. If not specified it is generated automatically depending on the sample size.

Details

used internally by cv.kappa and p.val.kappa

Value

Location parameter

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.


sr_scale

Description

Computes the scale parameter for the GEV approximation to the distribution of kappa_test statistic

Usage

sr_scale(t, alpha, lmax = NULL)

Arguments

t

Sample size

alpha

Value of the tail index between 2 and 4

lmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations. If not specified it is generated automatically depending on the sample size.

Details

Used internally by cv.kappa and p.val.kappa

Value

Scale parameter

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.


sr_shape

Description

Computes the scale parameter for the GEV approximation to the distribution of kappa_test statistic

Usage

sr_shape(t, alpha, lmax = NULL)

Arguments

t

Sample size

alpha

Value of the tail index between 2 and 4

lmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations. If not specified it is generated automatically depending on the sample size.

Details

Used internally by cv.kappa and p.val.kappa

Value

Shape parameter

References

J.L. Carrion-i-Silvestre & A. Sansó (2023): Generalized Extreme Value Approximation to the CUMSUMQ Test for Constant Unconditional Variance in Heavy-Tailed Time Series.


step2a

Description

Computes step 2a of the icss Algorithm.

Usage

step2a(e, sig.lev, kmax, alpha)

Arguments

e

Stationary variable on which the constancy of unconditional variance is tested.

sig.lev

Significance level.

kmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations.

alpha

Tail index.

Details

Used internally by icss.

Value

References

C. Inclan & G.C. Tiao (1994): Use of Cumulative Sums of Squares for Retrospective Detection of Changes of Variance. Journal of the American Statistical Association 89, 913-923.


step2b

Description

Computes step 2b of the icss Algorithm.

Usage

step2b(e, sig.lev, kmax, alpha)

Arguments

e

Stationary variable on which the constancy of unconditional variance is tested.

sig.lev

Significance level.

kmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations.

alpha

Tail index.

Details

Used internally by icss.

Value

References

C. Inclan & G.C. Tiao (1994): Use of Cumulative Sums of Squares for Retrospective Detection of Changes of Variance. Journal of the American Statistical Association 89, 913-923.


step2c

Description

Computes step 2c of the icss Algorithm.

Usage

step2c(e, bb, sig.lev, kmax, alpha)

Arguments

e

Stationary variable on which the constancy of unconditional variance is tested.

bb

The output of function steps1.to.2b.

sig.lev

Significance level.

kmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations.

alpha

Tail index.

Details

Used internally by icss.

Value

References

C. Inclan & G.C. Tiao (1994): Use of Cumulative Sums of Squares for Retrospective Detection of Changes of Variance. Journal of the American Statistical Association 89, 913-923.


step3

Description

Computes step 3 of the icss Algorithm.

Usage

step3(e, bb, sig.lev, kmax, alpha)

Arguments

e

Stationary variable on which the constancy of unconditional variance is tested.

bb

The output of step2c, A list with the number of break and the time of the breaks.

sig.lev

Significance level.

kmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations.

alpha

Tail index.

Details

Used internally by icss.

Value

References

C. Inclan & G.C. Tiao (1994): Use of Cumulative Sums of Squares for Retrospective Detection of Changes of Variance. Journal of the American Statistical Association 89, 913-923.


steps1.to.2b

Description

Computes steps 1 to 2b of the icss Algorithm.

Usage

steps1.to.2b(e, sig.lev, kmax, alpha)

Arguments

e

Stationary variable on which the constancy of unconditional variance is tested.

sig.lev

Significance level.

kmax

Maximum lag to be used for the long-run estimation of the fourth order moment of the innovations.

alpha

Tail index.

Details

Used internally by icss.

Value

References

C. Inclan & G.C. Tiao (1994): Use of Cumulative Sums of Squares for Retrospective Detection of Changes of Variance. Journal of the American Statistical Association 89, 913-923.


taula.icss

Description

When there are breaks in the unconditional variance, it creates a matrix with the different periods and estimated variances.

Usage

taula.icss(x)

Arguments

x

An object with the output of icss.

Details

Used internally by print.icss. If there are no break returns NA value.

Value

Matrix with the different periods and estimated variances.


taula.micss

Description

When there are breaks in the unconditional variance, it creates a matrix with the different periods, estimated variances, values of kappa_test and p.val.kappa.

Usage

taula.micss(x, alpha)

Arguments

x

An object with the output of icss.

alpha

Value of the tail index between 2 and 4

Details

Used internally by print.micss.

Value

Matrix with the different periods, estimated variances, values of kappa_test and p.val.kappa.


var.est.icss

Description

Computes the variance of each period according to the breaks found with icss or micss.

Usage

var.est.icss(x)

Arguments

x

An object with the output of icss or micss.

Value

A vector with the variances.


Whitening

Description

Eliminates the autocorrelation of a variable using an AR model.

Usage

whitening(y, kmax = NULL)

Arguments

y

A numeric vector. Variable to be whiten.

kmax

Maximum lag to be used for the long-run estimation of the variance. If not specified uses [12*(t/100)^(1/4)].

Details

Selects the model using the Bayes Information Criterium.

Value

Examples

whitening(rnorm(100))