Skip to content

Instantly share code, notes, and snippets.

@StuartGordonReid
Last active July 26, 2019 07:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save StuartGordonReid/a91c5a15148354f31c20 to your computer and use it in GitHub Desktop.
Save StuartGordonReid/a91c5a15148354f31c20 to your computer and use it in GitHub Desktop.
#' @title Compute the Mr statistic.
#'
#' @description Compute the Mr statistic. The Md statistic is the ratio between
#' two estimate values for Sigma computed using the calibrateSigma function for
#' sampling intervals 1 and the estimate value for Sima computed using the
#' CalibrateSigmaOverlapping function for sampling inveral q minus 1.
#' This statistic should converge to zero.
#'
#' @inheritParams calibrateSigma
#' @return Mr double :: The Mr statistic defined by Lo and MacKinlay.
#'
mRatio <- function(X, q, annualize = FALSE, unbiased = TRUE) {
# Estimate the value of sigma at sampling intervals 1 and q.
sigmaA <- calibrateSigma(X, q = 1, annualize, unbiased)
sigmaB <- calibrateSigmaOverlapping(X, q = q, annualize, unbiased)
Mr <- (sigmaB / sigmaA) - 1
return(Mr)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment