R/ll-helper.counts.R

Defines functions correction.counts validate.data.counts required.columns.counts

required.columns.counts <- function() {
  c('r'='responders', 'n'='sampleSize')
}

validate.data.counts <- function(data.ab) {
  stopifnot(all(data.ab[['sampleSize']] >= data.ab[['responders']]))
  stopifnot(all(data.ab[['sampleSize']] > 0))
  stopifnot(all(data.ab[['responders']] >= 0))
}

correction.counts <- function(data, correction.force, correction.type, correction.magnitude) {
  correction.need <-
    data[1,'responders'] == 0 || data[1,'responders'] == data[1,'sampleSize'] ||
    data[2,'responders'] == 0 || data[2,'responders'] == data[2,'sampleSize']

  groupRatio <- if (correction.type == "reciprocal") {
    data[1,'sampleSize'] / data[2,'sampleSize']
  } else {
    1
  }

  if (correction.force || correction.need) {
    correction.magnitude * c(groupRatio/(groupRatio+1), 1/(groupRatio+1))
  } else {
    c(0, 0)
  }
}

Try the gemtc package in your browser

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

gemtc documentation built on July 9, 2023, 5:33 p.m.