tests/testthat/test_hit.R

context("HIT testing")

test_that("hit testing", {
  set.seed(123)
  n <- 100
  p <- 150
  # x with correlated columns
  corMat <- toeplitz((p:1 / p)^3)
  corMatQ <- chol(corMat)
  x <- matrix(rnorm(n * p), nrow = n) %*% corMatQ
  colnames(x) <- paste0("x", 1:p)
  # y
  y <- x[, c(3, 5, 73)] %*% c(2, 5, 3) + rnorm(n)
  # hierarchy
  dend <- as.dendrogram(hclust(dist(t(x))))
  hier <- as.hierarchy(dend)
  # HIT
  fit <- hit(x, y, hier)
  # checks
  expect_equal(class(fit), "hit")
  expect_equal(unname(unlist(lapply(fit, class))), 
               c("numeric", "numeric","hierarchy", 
                 "logical", "numeric"))
  expect_equal(names(fit), 
               c("pValues", "selectFreq", "hierarchy", 
                 "tested", "max.p.esti"))
})

Try the hit package in your browser

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

hit documentation built on May 2, 2019, 10:15 a.m.