tests/testthat/test-cs_statistical.R

# Argument Check ----------------------------------------------------------
test_that("All arguments are set correctly", {
  expect_error(cs_statistical(claus_2020))
  expect_error(cs_statistical(claus_2020, id = id))
  expect_error(cs_statistical(claus_2020, id = id, time = time))
  expect_error(cs_statistical(claus_2020, id = id, time = time, reliability = "0.80", cutoff_method = "HA"))
  expect_error(cs_statistical(claus_2020, id = id, time = time, reliability = 1.1, cutoff_method = "HA"))
  expect_error(cs_statistical(claus_2020, id = id, time = time, reliability = -0.8, cutoff_method = "HA"))

  expect_snapshot_error(cs_statistical(claus_2020))
  expect_snapshot_error(cs_statistical(claus_2020, id = id))
  expect_snapshot_error(cs_statistical(claus_2020, id = id, time = time))
  expect_snapshot_error(cs_statistical(claus_2020, id = id, time = time, reliability = "0.80", cutoff_method = "HA"))
  expect_snapshot_error(cs_statistical(claus_2020, id = id, time = time, reliability = 1.1, cutoff_method = "HA"))
  expect_snapshot_error(cs_statistical(claus_2020, id = id, time = time, reliability = -0.8, cutoff_method = "HA"))
})



# Functionality -----------------------------------------------------------
test_that("The function runs smoothly", {
  expect_no_error(cs_statistical(claus_2020, id, time, hamd, pre = 1, post = 4))
  expect_no_error(cs_statistical(claus_2020, id, time, hamd, pre = 1, post = 4, reliability = 0.80, cutoff_method = "HA"))
  expect_no_error(cs_statistical(anxiety, subject, measurement, anxiety, pre = 0, post = 4))
  expect_no_error(cs_statistical(anxiety, subject, measurement, anxiety, pre = 0, post = 4, group = treatment))
  expect_no_error(cs_statistical(anxiety, subject, measurement, anxiety, pre = 0, post = 4, group = treatment, reliability = 0.80, cutoff_method = "HA"))
})

Try the clinicalsignificance package in your browser

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

clinicalsignificance documentation built on April 4, 2025, 12:19 a.m.