tests/new_covariate.R

library(testit)
library(PKPDsim)

## test if remove_negative_times works properly
cov1 <- new_covariate(value = c(1,2,3,4), times = c(-10, -5, 0.5, 3),
              implementation = "interpolate", remove_negative_times = TRUE)
cov2 <- new_covariate(value = c(1,2,3,4), times = c(-10, -5, 0.5, 3),
              implementation = "locf", remove_negative_times = TRUE)
cov3 <- new_covariate(value = c(1,2,3,4), times = c(-10, -5, 0.5, 3),
              implementation = "interpolate", remove_negative_times = FALSE)
cov4 <- new_covariate(value = c(0.8, 1.1), times=c(-0.0167, 0.5))

assert(all(round(cov1$value,1) == c(2.9, 3, 4)))
assert(all(round(cov2$value,1) == c(2, 3, 4)))
assert(all(round(cov3$value,1) == c(1, 2, 3, 4)))
assert(!any(is.na(cov4$value)))
ronkeizer/PKPDsim documentation built on May 27, 2019, 1:50 p.m.