R/FindVariances.R

Defines functions FindVariances

Documented in FindVariances

#' Find variances according to problem parameters
#' @param ME_var_ratio (defaults to 1) determines the ratio of diseased/healthy ME variance (a in Ben's notation)
#' @param var_eq if TRUE VX=VY, else VX=2VY (b=1,2 in Ben's notation)
#' @param theta_squared contamination ratio
#' @details Find the variances from the problem parameters as in Reiser, 2000.
#'  The healthy population's variance is always VY=1.
#'  If var_eq = TRUE then VX=VY, else VX=2VY=2.
#' @return a named vector with the variances to be used for the given parameters
#' @export


FindVariances <- function(var_eq,ME_var_ratio,theta_squared){
  VY <- 1 # healthy biomarker variance
  VX <- 2 - as.numeric(var_eq) # diseased variance is 1 or 2
  b <- VX/VY # biomarker variance ratio
  Veta <-  (theta_squared*(b+1))/(ME_var_ratio+1)
  Veps <- Veta * ME_var_ratio

  return(c(VX=VX,VY=VY,Veps=Veps,Veta=Veta))

}
blebedenko/thescript2 documentation built on Dec. 19, 2021, 9:53 a.m.