Skip to content

Instantly share code, notes, and snippets.

@StuartGordonReid
Last active July 26, 2019 07:32
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/6b0785adf814df27b50f to your computer and use it in GitHub Desktop.
Save StuartGordonReid/6b0785adf814df27b50f to your computer and use it in GitHub Desktop.
#' @title Compute the Md statistic.
#'
#' @description Compute the Md statistic. The Md statistic is the difference
#' 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.
#' This statistic should converge to zero.
#'
#' @inheritParams calibrateSigma
#' @return Md double :: The Md statistic defined by Lo and MacKinlay.
#'
mDifferences <- 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)
Md <- sigmaB - sigmaA
return(Md)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment