# under the null
rv <- sr_equality_test(matrix(rnorm(500*5),ncol=5))
# under the alternative (but with identity covariance)
ope <- 253
nyr <- 10
nco <- 5
rets <- 0.01 * sapply(seq(0,1.7/sqrt(ope),length.out=nco),
function(mu) { rnorm(ope*nyr,mean=mu,sd=1) })
rv <- sr_equality_test(rets)
# using real data
if (require(quantmod)) {
get.ret <- function(sym,...) {
OHLCV <- getSymbols(sym,auto.assign=FALSE,...)
lrets <- diff(log(OHLCV[,paste(c(sym,"Adjusted"),collapse=".",sep="")]))
lrets[-1,]
}
get.rets <- function(syms,...) { some.rets <- do.call("cbind",lapply(syms,get.ret,...)) }
some.rets <- get.rets(c("IBM","AAPL","NFLX","SPY"))
pvs <- sr_equality_test(some.rets)
}
# test for uniformity
pvs <- replicate(1024,{ x <- sr_equality_test(matrix(rnorm(400*5),400,5),type="chisq")
x$p.value })
plot(ecdf(pvs))
abline(0,1,col='red')Run the code above in your browser using DataLab