R/QT1.r

Defines functions QT1

Documented in QT1

#' Calculating p-value for bootstrap-adjusted likelihood ratio statistic
#'
#' Calculating p-value for bootstrap-adjusted likelihood ratio statistic
#'
#' Please see Noma et al. (2017) for details.
#'
#' @param x A vector of bootstrap samples of likelihood ratio statistic.
#' @param x0 The value of the ordinary likelihood ratio statistic.
#' @return Caluculated p-value for the adjusted test.
#' @references
#' Noma, H., Nagashima, K., Maruo, K., Gosho, M., Furukawa, T. A. (2017).
#' Bartlett-type corrections and bootstrap adjustments of likelihood-based inference methods for network meta-analysis.
#' \emph{ISM Research Memorandum} 1205.
#' @examples
#' dae <- data.aug.edit(smoking)
#' y <- dae$y
#' S <- dae$S
#'
#' beta1e <- 0.80
#'
#' C <- 0.95
#' alpha <- 1 - C
#'
#' ml1 <- ML(y, S)
#'
#' a1 <- ml1$Coefficients[, 1]
#' a2 <- (ml1$`Between-studies_SD`)^2
#' a3 <- a2*(ml1$`Between-studies_COR`)
#' a4 <- c(a1, a2, a3)
#'
#' mu13 <- ml1$Coefficients[1, 1]
#' ci3 <- ml1$Coefficients[1, 3:4]
#'
#' R <- qchisq(C, df=1)
#'
#' beta1 <- log(beta1e)
#' mlike0 <- .5*ml1$Loglikelihood
#'
#' bcb1 <- PBS0.LR(y, S, ml0 = a4, mu0 = beta1, B = 400)
#'
#' mlike1 <- .5*RML(y, S, ml0 = a4, mu0 = beta1)
#' LR0 <- -2*(mlike1 - mlike0)
#'
#' QT1(bcb1, LR0)  # adjusted p-value
#' @export
QT1 <- function(x, x0){

  x1 <- sort(c(x, x0))
  w1 <- which(x1 == as.numeric(x0))
  qt <- 1 - w1/(length(x) + 1)
  return(qt)

}
nshi-stat/netiim3 documentation built on May 6, 2019, 10:51 p.m.