Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Oct 17, 2024
1 parent 75c60f5 commit e7b129e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/biokinetics.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ biokinetics <- R6::R6Class(
},
construct_design_matrix = function() {
var <- pid <- NULL
dt_design_matrix <- as.character(private$data[, .SD, .SDcols = private$all_formula_vars, by = pid]) |>
dt_design_matrix <- private$data[, .SD, .SDcols = private$all_formula_vars, by = pid] |>
unique()

# Build the full design matrix using model.matrix
Expand Down
16 changes: 14 additions & 2 deletions man/biokinetics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/testthat/test-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ test_that("Can handle non-numeric pids", {
stan_data <- mod$get_stan_data()
expect_equivalent(stan_data$id, ids)
})

test_that("Natural scale data is converted to log scale for stan", {
dat <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
mod <- biokinetics$new(data = dat)
stan_data <- mod$get_stan_data()
expect_equivalent(stan_data$value, convert_log_scale(dat, "value")$value)
})

test_that("Log scale data is passed directly to stan", {
dat <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
mod <- biokinetics$new(data = dat, scale = "log")
stan_data <- mod$get_stan_data()
expect_equivalent(stan_data$value, dat$value)
})

0 comments on commit e7b129e

Please sign in to comment.