tests/testthat/test-crimcv.R

context('crimcv')
# skip on CI because crimCV fitting fails at random with error "object 'Frtr' not found"
skip_on_ci()
skip_on_cran()
skip_if_not_installed('crimCV')
rngReset()
tests = setdiff(DEFAULT_LATREND_TESTS, c('data-na', 'data-varlen'))

library(crimCV)

make.crimcv = function(...) {
  lcMethodCrimCV(
    ...,
    dpolyp = 2,
    dpolyl = 1,
    init = 5,
    seed = 1
  )
}

# Create test dataset
data(TO1adj)
subTO1adj = TO1adj[1:99, seq(1, ncol(TO1adj), by = 2)]
testData = tsframe(
  subTO1adj,
  id = 'Id',
  time = 'Time',
  response = 'Value',
  times = seq_len(ncol(subTO1adj)),
  as.data.table = TRUE
) %>%
  .[, Cluster := rep(LETTERS[1:3], each = 33 * ncol(subTO1adj))]

# Tests ####
test_that('zip', {
  expect_true({
    test.latrend(
      'lcMethodCrimCV',
      instantiator = make.crimcv,
      data = testData,
      tests = tests,
      args = list(model = 'ZIP'),
      clusterRecovery = 'skip'
    )
  })
})

test_that('zipt', {
  expect_true({
    test.latrend(
      'lcMethodCrimCV',
      instantiator = make.crimcv,
      data = testData,
      tests = tests,
      args = list(model = 'ZIPt'),
      clusterRecovery = 'skip'
    )
  })
})

Try the latrend package in your browser

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

latrend documentation built on March 31, 2023, 5:45 p.m.