Skip to content

Instantly share code, notes, and snippets.

@StuartGordonReid
Created February 7, 2016 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save StuartGordonReid/e0b89b4fb08b791725f0 to your computer and use it in GitHub Desktop.
Save StuartGordonReid/e0b89b4fb08b791725f0 to your computer and use it in GitHub Desktop.
#' @title Given a log price process, X, compute the Z-score which can be used
#' to accept or reject the hypothesis that the process evolved according to a
#' Brownian Motion model with drift and stochastic volatility.
#'
#' @description Given a log price process, X, and a sampling interval, q, this
#' method returns a Z score indicating the confidence we have that X evolved
#' according to a Brownian Motion mode with drift and stochastic volatility. This
#' heteroskedasticity-consistent variance ratio test essentially checks to see
#' whether or not the observed Mr statistic for the number of observations, is
#' within or out of the limiting distribution defined by the Asymptotic Variance.
#'
#' @param X vector :: A log price process.
#' @param q int :: The sampling interval for the estimator.
#'
VRTestZScore <- function(X, q) {
n <- floor(length(X)/q)
z <- sqrt(n * q) * mRatio(X, q)
z <- z / sqrt(calibrateAsymptoticVariance(X, q))
return(z)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment