Package 'vrtest'

Title: Variance Ratio Tests and Other Tests for Martingale Difference Hypothesis
Description: A collection of statistical tests for martingale difference hypothesis, including automatic portmanteau test (Escansiano and Lobato, 2009) <doi:10.1016/j.jeconom.2009.03.001> and automatic variance ratio test (Kim, 2009) <doi:10.1016/j.frl.2009.04.003>.
Authors: Jae H. Kim
Maintainer: Jae H. Kim <[email protected]>
License: GPL-2
Version: 1.2
Built: 2025-02-25 03:44:38 UTC
Source: https://github.com/cran/vrtest

Help Index


Variance Ratio tests and other tests for Martingale Difference Hypothesis

Description

A collection of variance ratio and spectral shapte tests

Details

Package: vrtest
Type: Package
Version: 1.2
Date: 2023-08-31
License: GPL-2

Author(s)

Jae H. Kim

Maintainer: Jae H. Kim <[email protected]>


Adjustment for thinly-traded returns

Description

The adjustment based on AR(1) fitting as proposed by Miller et al. (1994)

Usage

Adjust.thin(y)

Arguments

y

financial return time series

Value

Adjusted return

Author(s)

Jae H. Kim

References

Miller et al. (1994), Mean Reversion of Standard & Poor's 500 Index Base Changes: Arbitrage Induced or Statistical Illusion Journal of Finance, XLIX, 479-513.

Examples

data(exrates)
y <- exrates$ca                           
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)]) 
Adjust.thin(r)

Automatic Portmanteau Test

Description

A robustified portmanteau test with automatic lag selection

Usage

Auto.Q(y,lags)

Arguments

y

financial return time series

lags

maximum lag value, the default is 10

Value

Stat

Automatic portmanteau test statistic

Pvalue

p-value of the test

Author(s)

Jae H. Kim

References

Escanciano, J.C., Lobato, I.N. 2009a. An automatic portmanteau test for serial correlation. Journal of Econometrics 151, 140-149.

Charles, A. Darne, O. Kim, J.H. 2011, Small Sample Proeprties of Alternative Tests for Martingale Difference Hypothesis, Economics Letters, 110(2), 151-154.

Examples

data(exrates)
y <- exrates$ca                          
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])    
Auto.Q(r)

Automatic Variance Ratio Test

Description

A variance ratio test with holding period value chosen by a data dependent procedure

Usage

Auto.VR(y)

Arguments

y

financial return time series

Value

stat

Automatic variance ratio test statistic

sum

1+ weighted sum of autocorrelation up to the optimal order

Note

R code translated from Choi's GAUSS code

Author(s)

Jae H. Kim

References

Choi, I. 1999, Testing the random walk hypothesis for real exchange rates Journal of Applied Econometrics, 14, 293-308.

Examples

data(exrates)
y <- exrates$ca                           
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])      
Auto.VR(r)

Wild Bootstrapping of Automatic Variance Ratio Test

Description

This function returns wild bootstrap test results for the Automatic Variance Ratio Test of Choi (1999)

Usage

AutoBoot.test(y, nboot, wild,prob=c(0.025,0.975))

Arguments

y

a vector of time series, typically financial return

nboot

the number of bootstrap iterations

wild

"Normal" for the wild bootstrap using the standard normal distribution, "Mammen" for the wild bootstrap using Mammen's two point distribution, "Rademacher" for the wild bootstrap using Rademacher's two point distribution

prob

probability limits for confidence intervals

Value

test.stat

Automatic variance ratio test statistic

VRsum

1+ weighted sum of autocorrelation up to the optimal order

pval

Wild Bootstrap p-value for the test

CI

Confidence Intervals for the test statistic from Bootstrap distribution

CI.VRsum

Confidence Intervals for the VRsum from Bootstrap distribution

Author(s)

Jae H. Kim

References

Kim, J. H., 2009, Automatic Variance Ratio Test under Conditional Heteroskedascity, Finance Research Letters, 6(3), 179-185.

Charles, A. Darne, O. Kim, J.H. 2011, Small Sample Proeprties of Alternative Tests for Martingale Difference Hypothesis, Economics Letters, 110(2), 151-154.

Examples

r <- rnorm(100)          
AutoBoot.test(r,nboot=500,wild="Normal")

Average Exponential Tests

Description

Average exponential tests of Andrews and Ploberger (1996)

Usage

Ave.Ex(y)

Arguments

y

financial return time series

Value

Ex.LM

LM test

Ex.LR

LR test

Note

Traslated from Choi's Gauss codes

Author(s)

Jae H. Kim

References

Choi, I. 1999, Testing the random walk hypothesis for real exchange rates, Journal of Applied Econometrics, 14, 293-308.

Examples

data(exrates)
y <- exrates$ca                      
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])   
Ave.Ex(r)

Bootstrap Variance Ratio Tests

Description

This function returns bootstrap p-values of the Lo-MacKilay (1988) and Chow-Denning (1993) tests.

Users can choose between iid bootstrap and wild bootstrap

Usage

Boot.test(y, kvec, nboot, wild, prob=c(0.025,0.975))

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

nboot

the number of bootstrap iterations

wild

"No" for iid bootstrap, "Normal" for the wild bootstrap using the standard normal distribution, "Mammen" for the wild bootstrap using Mammen's two point distribution, "Rademacher" for the wild bootstrap using Rademacher's two point distribution

prob

probability limits for confidence intervals

Value

Holding.Period

holding periods used

LM.pval

Bootstrap p-values for the Lo-MacKinlay tests

CD.pval

Bootstrap p-value for the Chow-Denning test

CI

Confidence Intervals for Lo-Mackinlay tests from Bootstrap distribution

Author(s)

Jae H. Kim

References

Kim, J.H., 2006, Wild Bootstrapping Variance Ratio Tests. Economics Letters, 92, 38-43.

Examples

data(exrates)
y <- exrates$ca                   
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])    
kvec <- c(2,5,10)
Boot.test(r,kvec,nboot=500,wild="Normal")

Power Transformed Joint Variance Ratio Test

Description

See equation (15) of Chen and Deo (2006)

Usage

Chen.Deo(x, kvec)

Arguments

x

a vector of time series, typically financial return

kvec

a vector of holding periods

Value

Holding.Period

holding periods used

VRsum

the sum of (power transformed individual VR - 1)

QPn

QPn statistic

ChiSQ.Quantiles_1_2_5_10_20_percent

Chi-square critical values

Author(s)

Jae H. Kim

References

Chen, W. W., and Deo, R.S., 2006, The Variance Ratio Statistic at Large Horizons, Econometric Theory, 22, 206-234.

Examples

data(exrates)
y <- exrates$ca                         
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])    
kvec <- c(2,5,10)
Chen.Deo(r,kvec)

Chow-Denning Multiple Variance Ratio Tests

Description

This function returns Chow-Denning test statistics.

CD1: test for iid series; CD2: test for uncorrelated series with possible heteroskedasticity.

Usage

Chow.Denning(y, kvec)

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

Value

Holding.Periods

holding periods used

CD1

CD1 statistic

CD2

CD2 statistic

Critical.Values_10_5_1_percent

10 5 1 percent critical values

Note

See Chow and Denning (1993) for the details of critical value calculation

Author(s)

Jae H. Kim

References

Chow,K. V., K. C. DENNING, 1993, A Simple Multiple Variance Ratio Test, Journal of Econometrics, 58, 385-401.

Examples

data(exrates)
y <- exrates$ca                  
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])      
kvec <- c(2,5,10)
Chow.Denning(r,kvec)

Dominguez-Lobato Test for Martingale Difference Hypothesis

Description

Dominguez-Lobato Test

Usage

DL.test(y,B,p)

Arguments

y

financial return time series

B

the number of bootstrap iterations, the default is 300

p

the lag value, the default is 1

Value

Cp

Cramer von Mises test statistic

Kp

Kolmogorov-Smirnov test statistic

Cp_pval

wild bootstrap p-value of the Cp test

Kp_pval

wild bootstrap p-value of the Kp test

Author(s)

Jae H. Kim

References

Domingues M.A. and Lobato, I. N., 2003, Testing the Martingale Difference Hypothesis, Econometrics Reviews, 22, p351-377.

Charles, A. Darne, O. Kim, J.H. 2011, Small Sample Proeprties of Alternative Tests for Martingale Difference Hypothesis, Economics Letters, 110(2), 151-154.

Examples

r <- rnorm(50)           
DL.test(r,B=100)
# B=100 is used for fast execution in the example. 
# Use a higher number in actual application

wright's Exchange Rates Data

Description

The data set used in Wright (2001) as an application, weekly from August, 7, 1974 to May 29 1996

Usage

data(exrates)

Format

A data frame with 1139 observations on the following 5 variables.

ca

a numeric vector, Canadian Dollar

dm

a numeric vector, Deutch Mark

ff

a numeric vector, French Franc

uk

a numeric vector, UK Pound

jp

a numeric vector, Japanese Yen

References

WRIGHT,J.H.,2000,Alternative Variance-Ratio Tests Using Ranks and Signs, Journal of Business & Economic Statistics, 18, 1-9.

Examples

data(exrates)

Generalized spectral Test

Description

Generalized spectral Test

Usage

Gen.Spec.Test(y,B)

Arguments

y

financial return time series

B

the number of bootstrap iterations, the default is 300

Value

Pboot

wild bootstrap p-value of the test

Author(s)

Jae H. Kim

References

Escanciano, J.C. and Velasco, C., 2006, Generalized Spectral Tests for the martigale Difference Hypothesis, Journal of Econometrics, 134, p151-185.

Charles, A. Darne, O. Kim, J.H. 2011, Small Sample Proeprties of Alternative Tests for Martingale Difference Hypothesis, Economics Letters, 110(2), 151-154.

Examples

r <- rnorm(100)        
Gen.Spec.Test(r)

A Joint Version of Wight's Rank and Sign Test

Description

This function returns joint or multiple version of Wright's rank and sign tests. The test takes the maximum value of the individual rank or sign tests, in the same manner as Chow-Denning test

Usage

Joint.Wright(y, kvec)

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

Value

Holding.Period

holding periods used

JR1

Joint test based on R1 statistics

JR2

Joint test based on R2 statistics

JS1

Joint test based on S1 statistics

Author(s)

Jae H. Kim

References

Belaire-Franch G, Contreras D. Ranks and signs-based multiple variance ratio tests, Working paper, University of Valencia 2004.

Kim, J. H. and Shamsuddin, A., 2008, Are Asian Stock Markets Efficient? Evidence from New Multiple Variance Ratio Tests, Journal of Empirical Fiance 15(8), 518-532.

Examples

data(exrates)
y <- exrates$ca                           
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])    
kvec <- c(2,5,10)
Joint.Wright(r,kvec)

Critical Values for the joint versions of Wright's rank and sign tests

Description

This function runs a simulation to calculate the critical values of the joint versions of Wright's tests.

Usage

JWright.crit(n, kvec, nit)

Arguments

n

sample size

kvec

holding period vector

nit

number of iterations

Value

Holding.Period

holding period used

JR1.crit

Critical values for the joint R1 statistic

JR2.crit

Critical values for the joint R2 statistic

JS1.crit

Critical values for the joint S1 statistic

Author(s)

Jae H. Kim

References

Belaire-Franch G, Contreras D. Ranks and signs-based multiple variance ratio tests, Working paper, University of Valencia 2004.

Kim, J. H. and Shamsuddin, A., 2008, Are Asian Stock Markets Efficient? Evidence from New Multiple Variance Ratio Tests, Journal of Empirical Fiance 15(8), 518-532.

Examples

kvec <- c(2,5,10)
JWright.crit(n=100,kvec,nit=50)

# nit is set to 50 for fast execution in the example. 
# nit=10000 is recommended as in Wright (2000)

Lo-MacKinlay variance Ratio Tests

Description

The function returns M1 and M2 statistics of Lo and MacKinlay (1998).

M1: tests for iid series; M2: for uncorrelated series with possible heteroskedasticity.

Usage

Lo.Mac(y, kvec)

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

Value

Stats

M1 and M2 statistics

Author(s)

Jae H. Kim

References

LO, A. W., and A. C. MACKINLAY (1988): "Stock Market Prices Do Not Follow Random Walks: Evidence from a Simple Specification Test," The Review of Financial Studies, 1, 41-66.

Examples

data(exrates)
y <- exrates$ca                 
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])       
kvec <- c(2,5,10)
Lo.Mac(r,kvec)

Panel Variance Ratio Tests

Description

Panel variance tatio tests based on Maximum Absloute Value, Sum of Squares, and Mean of each cross-sectional units

Usage

Panel.VR(dat, nboot = 500)

Arguments

dat

a T by K matrix of asset returns, K is the munber of cross sectional units and T is length of time series

nboot

the number of wild bootstrap iterations, the default is set to 500

Details

The component statistics are based on the automatic variance ratio test The set of returns are wild bootstrapped to conserve cross-sectional dependency

Value

MaxAbs.stat

the statistic based on the maximum absolute value of individual statistics

SumSquare.stat

the statistic based on the sum of squared value of individual statistics

Mean.stat

the statistic based on the mean value of individual statistics

MaxAbs.pval

the wild bootstrap pvalue based on the maximum absolute value of individual statistics

SumSquare.pval

the wild bootstrap pvalue based on the sum of squared value of individual statistics

Mean.pval

the wild bootstrap pvalue based on the mean value of individual statistics

Author(s)

Jae H. Kim

References

Kim, J. H., & Shamsuddin, A. (2015). A closer look at return predictability of the US stock market: evidence from new panel variance ratio tests. Quantitative Finance, 15(9), 1501-1514.

Examples

ret=matrix(rnorm(200),nrow=100)
Panel.VR(ret)

Spectral shape tests for random walk

Description

Spectral Shape tests proposed by Durlauf (1991) and Choi (1999)

Usage

Spec.shape(x)

Arguments

x

financial return time series

Value

AD

Anderson-Darling statistic

CVM

Cramer-von Mises statistic

M

Mellows statistic

Note

Traslated from Choi's Gauss codes

Author(s)

Jae H. Kim

References

Choi, I. 1999, Testing the random walk hypothesis for real exchange rates, Journal of Applied Econometrics, 14, 293-308. Durlauf, S. N., 1991, Spectral based testing of the martingale hypothesis, Journal of Econometrics, 50, 355-376.

Examples

data(exrates)
y <- exrates$ca                   
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])     
Spec.shape(r)

Subsampling test of Whang and Kim (2003)

Description

The function returns the p-values of the subsampling test.

Usage

Subsample.test(y, kvec)

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

Details

The block lengths are chosen internally using the rule proposed in Whang and Kim (2003)

Value

Holding.Period

holding periods used

Block.Length

block lengths chosen

pval

p-values of the test for each block length used

Author(s)

Jae H. Kim

References

WHANG,Y.-J., J. KIM, 2003, A Multiple Variance Ratio Test Using Subsampling, Economics Letters, 79, 225-230.

Examples

data(exrates)
y <- exrates$ca                  
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])   
kvec <- c(2,5,10)
Subsample.test(r,kvec)

Absolute Value of (VR - 1)

Description

This value is sometimes used to measure the degree of market efficiency

Usage

VR.minus.1(y, kvec)

Arguments

y

financial return time series

kvec

a vector of holding periods

Value

VR.auto

the value of VR-1 with automatic selection of holding vectors

Holding.Peiods

the vector of holding periods

VR.kvec

the values of VR-1 for the chosen holding periods

Note

see Auto.VR function for automatic selection of holding periods

Author(s)

Jae H. Kim

Examples

data(exrates)
y <- exrates$ca             
nob <- length(y)
kvec <- c(2,5,10)
r <- log(y[2:nob])-log(y[1:(nob-1)])          
VR.minus.1(r,kvec)

Variance Ratio Plot

Description

Plotting unstandadized variance ratios against holding periods with 95percent confidence band

Standard errors under iid returns are used.

Usage

VR.plot(y, kvec)

Arguments

y

financial return

kvec

holding period vector

Value

VR

vector of variance ratio values plotted

Author(s)

Jae H. Kim & Alexios Ghalanos

Examples

data(exrates)
y <- exrates$ca                                 
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])
kvec <- c(2,5,10)
VR.plot(r,kvec)

Wald Test of Richardson and Smith (1991)

Description

This function returns the Wald test statistic with critical values

Usage

Wald(y, kvec)

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

Value

Holding.Periods

holding periods used

Wald.stat

Wald test statistic

Critical.Values_10_5_1_percent

10 5 and 1 percent critical values

Note

The statistic asymptotically follows the chi-squared distribution with the degrees of freedom same as the number of holding periods used

Author(s)

Jae H. Kim

References

Richardson, M., T. Smith, 1991, "Tests of Financial Models in the Presence of Overlapping Observations," The Review Financial Studies, 4, 227-254.

Examples

data(exrates)
y <- exrates$ca                        
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])     
kvec <- c(2,5,10)
Wald(r,kvec)

Wright's Rank and Sign Tests

Description

The function returns R1, R2 and S1 tests statistics detailed in Wright (2000)

Usage

Wright(y, kvec)

Arguments

y

a vector of time series, typically financial return

kvec

a vector of holding periods

Details

Nonparametric tests

Value

Holding.Period

holding periods used

R1.test

rank test R1

R2.test

rank test R2

S1.test

sign test S1

Author(s)

Jae H. Kim

References

WRIGHT,J.H.,2000,Alternative Variance-Ratio Tests Using Ranks and Signs, Journal of Business & Economic Statistics, 18, 1-9.

Examples

data(exrates)
y <- exrates$ca                    
nob <- length(y)
r <- log(y[2:nob])-log(y[1:(nob-1)])  
kvec <- c(2,5,10)
Wright(r,kvec)

Critical Values for Wright's rank and sign tests

Description

This function returns critical values of Wright's tests based on the simulation method detailed in Wright (2000)

Usage

Wright.crit(n, k, nit)

Arguments

n

sample size

k

holding period, a scalar

nit

number of iterations

Value

Holding.Period

holding period used

R1.crit

Critical values for the R1 statistic

R2.crit

Critical values for the R2 statistic

S1.crit

Critical values for the S1 statistic

Author(s)

Jae H. Kim

References

WRIGHT,J.H.,2000,Alternative Variance-Ratio Tests Using Ranks and Signs, Journal of Business & Economic Statistics, 18, 1-9.

Examples

Wright.crit(n=10,k=2,nit=50)  

# nit is set to 50 for fast execution in the example. 
# nit=10000 is recommended as in Wright (2000)