R/QT2.r

Defines functions QT2

Documented in QT2

#' Calculating p-value for bootstrap-adjusted efficient score statistic
#'
#' Calculating p-value for adjusted efficient score test using parametric bootstrap.
#'
#' Please see Noma et al. (2017) for details.
#'
#' @param x A vector of bootstrap samples of efficient score statistic.
#' @param x0 The value of the ordinary efficient score 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)
#'
#' PBS2 <- PBS0.ES(y, S, ml0 = a4, mu0 = beta1, B = 400)
#'
#' ES0 <- ES(y, S, ml0 = a4, mu0 = beta1)
#'
#' QT2(PBS2, ES0)  # adjusted p-value
#' @export
QT2 <- function(x, x0){

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

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