tests/testthat/test-unit-mtc.nr.comparisons.R

context("mtc.nr.comparisons")

test_that('mtc.nr.comparisons with a single study', {
  data <- data.frame(cbind(c('s02', 's02'), c('A', 'B')))
  colnames(data) <- c('study', 'treatment')
  network <- mtc.network(data)
  comparisons <- mtc.nr.comparisons(network)
  expect_identical(as.matrix(data.frame(t1='A', t2='B', nr=1)), as.matrix(comparisons))
})

test_that('mtc.nr.comparisons with 2 studies', {
  data <- data.frame(cbind(c('s02', 's02'), c('A', 'B')))
  data <- rbind(data, data.frame(cbind(c('s01', 's01'), c('A', 'B'))))  
  colnames(data) <- c('study', 'treatment')
  network <- mtc.network(data)
  comparisons <- mtc.nr.comparisons(network)
  expect_identical(as.matrix(data.frame(t1='A', t2='B', nr=2)), as.matrix(comparisons))
})

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.