R/wald.univariateScore.R

Defines functions wald.univariateScore

Documented in wald.univariateScore

wald.univariateScore <- function(target, dataset, test, wei = NULL, targetID = -1) {
  
  nTests <- dim(dataset)[2];
  univariateModels <- NULL;
  univariateModels$pvalue <- numeric(nTests) 
  univariateModels$stat <- numeric(nTests)
  
  poia <- Rfast::check_data(dataset)
  if ( sum(poia) > 0 )   dataset[, poia] <- rnorm( dim(dataset)[1] ) 
  
  for (i in 1:nTests) {
    #arguments order for any CI test are fixed
    if ( i != targetID ) {
      test_results <- test(target, dataset, xIndex=i, csIndex = 0, wei = wei)
      univariateModels$pvalue[[ i ]] <- test_results$pvalue;
      univariateModels$stat[[ i ]] <- test_results$stat;
    } else {
      univariateModels$pvalue[[ i ]] <- log(1);
      univariateModels$stat[[ i ]] <- 0;
    }
  }
  
  if ( sum(poia>0) > 0 ) {
    univariateModels$stat[poia] <- 0
    univariateModels$pvalue[poia] <- log(1)
  }
  
  univariateModels
}

Try the MXM package in your browser

Any scripts or data that you put into this service are public.

MXM documentation built on Aug. 25, 2022, 9:05 a.m.