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 |
A collection of variance ratio and spectral shapte tests
Package: | vrtest |
Type: | Package |
Version: | 1.2 |
Date: | 2023-08-31 |
License: | GPL-2 |
Jae H. Kim
Maintainer: Jae H. Kim <[email protected]>
The adjustment based on AR(1) fitting as proposed by Miller et al. (1994)
Adjust.thin(y)
Adjust.thin(y)
y |
financial return time series |
Adjusted return
Jae H. Kim
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.
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Adjust.thin(r)
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Adjust.thin(r)
A robustified portmanteau test with automatic lag selection
Auto.Q(y,lags)
Auto.Q(y,lags)
y |
financial return time series |
lags |
maximum lag value, the default is 10 |
Stat |
Automatic portmanteau test statistic |
Pvalue |
p-value of the test |
Jae H. Kim
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.
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Auto.Q(r)
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Auto.Q(r)
A variance ratio test with holding period value chosen by a data dependent procedure
Auto.VR(y)
Auto.VR(y)
y |
financial return time series |
stat |
Automatic variance ratio test statistic |
sum |
1+ weighted sum of autocorrelation up to the optimal order |
R code translated from Choi's GAUSS code
Jae H. Kim
Choi, I. 1999, Testing the random walk hypothesis for real exchange rates Journal of Applied Econometrics, 14, 293-308.
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Auto.VR(r)
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Auto.VR(r)
This function returns wild bootstrap test results for the Automatic Variance Ratio Test of Choi (1999)
AutoBoot.test(y, nboot, wild,prob=c(0.025,0.975))
AutoBoot.test(y, nboot, wild,prob=c(0.025,0.975))
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 |
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 |
Jae H. Kim
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.
r <- rnorm(100) AutoBoot.test(r,nboot=500,wild="Normal")
r <- rnorm(100) AutoBoot.test(r,nboot=500,wild="Normal")
Average exponential tests of Andrews and Ploberger (1996)
Ave.Ex(y)
Ave.Ex(y)
y |
financial return time series |
Ex.LM |
LM test |
Ex.LR |
LR test |
Traslated from Choi's Gauss codes
Jae H. Kim
Choi, I. 1999, Testing the random walk hypothesis for real exchange rates, Journal of Applied Econometrics, 14, 293-308.
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Ave.Ex(r)
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Ave.Ex(r)
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
Boot.test(y, kvec, nboot, wild, prob=c(0.025,0.975))
Boot.test(y, kvec, nboot, wild, prob=c(0.025,0.975))
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 |
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 |
Jae H. Kim
Kim, J.H., 2006, Wild Bootstrapping Variance Ratio Tests. Economics Letters, 92, 38-43.
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")
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")
See equation (15) of Chen and Deo (2006)
Chen.Deo(x, kvec)
Chen.Deo(x, kvec)
x |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
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 |
Jae H. Kim
Chen, W. W., and Deo, R.S., 2006, The Variance Ratio Statistic at Large Horizons, Econometric Theory, 22, 206-234.
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)
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)
This function returns Chow-Denning test statistics.
CD1: test for iid series; CD2: test for uncorrelated series with possible heteroskedasticity.
Chow.Denning(y, kvec)
Chow.Denning(y, kvec)
y |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
Holding.Periods |
holding periods used |
CD1 |
CD1 statistic |
CD2 |
CD2 statistic |
Critical.Values_10_5_1_percent |
10 5 1 percent critical values |
See Chow and Denning (1993) for the details of critical value calculation
Jae H. Kim
Chow,K. V., K. C. DENNING, 1993, A Simple Multiple Variance Ratio Test, Journal of Econometrics, 58, 385-401.
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)
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
DL.test(y,B,p)
DL.test(y,B,p)
y |
financial return time series |
B |
the number of bootstrap iterations, the default is 300 |
p |
the lag value, the default is 1 |
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 |
Jae H. Kim
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.
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
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
The data set used in Wright (2001) as an application, weekly from August, 7, 1974 to May 29 1996
data(exrates)
data(exrates)
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
WRIGHT,J.H.,2000,Alternative Variance-Ratio Tests Using Ranks and Signs, Journal of Business & Economic Statistics, 18, 1-9.
data(exrates)
data(exrates)
Generalized spectral Test
Gen.Spec.Test(y,B)
Gen.Spec.Test(y,B)
y |
financial return time series |
B |
the number of bootstrap iterations, the default is 300 |
Pboot |
wild bootstrap p-value of the test |
Jae H. Kim
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.
r <- rnorm(100) Gen.Spec.Test(r)
r <- rnorm(100) Gen.Spec.Test(r)
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
Joint.Wright(y, kvec)
Joint.Wright(y, kvec)
y |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
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 |
Jae H. Kim
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.
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)
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)
This function runs a simulation to calculate the critical values of the joint versions of Wright's tests.
JWright.crit(n, kvec, nit)
JWright.crit(n, kvec, nit)
n |
sample size |
kvec |
holding period vector |
nit |
number of iterations |
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 |
Jae H. Kim
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.
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)
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)
The function returns M1 and M2 statistics of Lo and MacKinlay (1998).
M1: tests for iid series; M2: for uncorrelated series with possible heteroskedasticity.
Lo.Mac(y, kvec)
Lo.Mac(y, kvec)
y |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
Stats |
M1 and M2 statistics |
Jae H. Kim
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.
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)
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 tatio tests based on Maximum Absloute Value, Sum of Squares, and Mean of each cross-sectional units
Panel.VR(dat, nboot = 500)
Panel.VR(dat, nboot = 500)
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 |
The component statistics are based on the automatic variance ratio test The set of returns are wild bootstrapped to conserve cross-sectional dependency
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 |
Jae H. Kim
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.
ret=matrix(rnorm(200),nrow=100) Panel.VR(ret)
ret=matrix(rnorm(200),nrow=100) Panel.VR(ret)
Spectral Shape tests proposed by Durlauf (1991) and Choi (1999)
Spec.shape(x)
Spec.shape(x)
x |
financial return time series |
AD |
Anderson-Darling statistic |
CVM |
Cramer-von Mises statistic |
M |
Mellows statistic |
Traslated from Choi's Gauss codes
Jae H. Kim
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.
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Spec.shape(r)
data(exrates) y <- exrates$ca nob <- length(y) r <- log(y[2:nob])-log(y[1:(nob-1)]) Spec.shape(r)
The function returns the p-values of the subsampling test.
Subsample.test(y, kvec)
Subsample.test(y, kvec)
y |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
The block lengths are chosen internally using the rule proposed in Whang and Kim (2003)
Holding.Period |
holding periods used |
Block.Length |
block lengths chosen |
pval |
p-values of the test for each block length used |
Jae H. Kim
WHANG,Y.-J., J. KIM, 2003, A Multiple Variance Ratio Test Using Subsampling, Economics Letters, 79, 225-230.
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)
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)
This value is sometimes used to measure the degree of market efficiency
VR.minus.1(y, kvec)
VR.minus.1(y, kvec)
y |
financial return time series |
kvec |
a vector of holding periods |
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 |
see Auto.VR function for automatic selection of holding periods
Jae H. Kim
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)
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)
Plotting unstandadized variance ratios against holding periods with 95percent confidence band
Standard errors under iid returns are used.
VR.plot(y, kvec)
VR.plot(y, kvec)
y |
financial return |
kvec |
holding period vector |
VR |
vector of variance ratio values plotted |
Jae H. Kim & Alexios Ghalanos
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)
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)
This function returns the Wald test statistic with critical values
Wald(y, kvec)
Wald(y, kvec)
y |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
Holding.Periods |
holding periods used |
Wald.stat |
Wald test statistic |
Critical.Values_10_5_1_percent |
10 5 and 1 percent critical values |
The statistic asymptotically follows the chi-squared distribution with the degrees of freedom same as the number of holding periods used
Jae H. Kim
Richardson, M., T. Smith, 1991, "Tests of Financial Models in the Presence of Overlapping Observations," The Review Financial Studies, 4, 227-254.
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)
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)
The function returns R1, R2 and S1 tests statistics detailed in Wright (2000)
Wright(y, kvec)
Wright(y, kvec)
y |
a vector of time series, typically financial return |
kvec |
a vector of holding periods |
Nonparametric tests
Holding.Period |
holding periods used |
R1.test |
rank test R1 |
R2.test |
rank test R2 |
S1.test |
sign test S1 |
Jae H. Kim
WRIGHT,J.H.,2000,Alternative Variance-Ratio Tests Using Ranks and Signs, Journal of Business & Economic Statistics, 18, 1-9.
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)
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)
This function returns critical values of Wright's tests based on the simulation method detailed in Wright (2000)
Wright.crit(n, k, nit)
Wright.crit(n, k, nit)
n |
sample size |
k |
holding period, a scalar |
nit |
number of iterations |
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 |
Jae H. Kim
WRIGHT,J.H.,2000,Alternative Variance-Ratio Tests Using Ranks and Signs, Journal of Business & Economic Statistics, 18, 1-9.
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)
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)