Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bmstate
Type: Package
Title: Bayesian multistate modeling
Version: 0.2.7
Version: 0.2.8
Authors@R:
c(person(given = "Juho",
family = "Timonen",
Expand Down
6 changes: 6 additions & 0 deletions R/DosingData.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' Dosing data class (R6 class)
#'
#' @description
#' Contains information about taken doses and dose times.
#'
#' @export
#' @field subject_ids Subject ids.
DosingData <- R6::R6Class(
Expand Down Expand Up @@ -31,6 +34,9 @@ DosingData <- R6::R6Class(
#' Partially steady-state dosing data class (R6 class)
#'
#' @export
#' @description
#' Contains information about taken doses and dose times.
#'
#' @field doses Dose amounts (list with length equal to number of subjects).
#' Corresponds to doses after the steady state.
#' @field times Dose times (list with length equal to number of subjects).
Expand Down
3 changes: 3 additions & 0 deletions R/JointData.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pd_to_jointdata <- function(data) {
#' Joint data class (R6 class)
#'
#' @export
#' @description
#' Contains data about both the state paths and dosing.
#'
#' @field paths The events data, an object of class \code{\link{PathData}}.
#' @field dosing The dosing data, an object of class \code{\link{DosingData}}.
JointData <- R6::R6Class(
Expand Down
2 changes: 2 additions & 0 deletions R/MultistateModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ create_msm <- function(tm, hazard_covs = NULL, pk_covs = NULL,

#' Main model class
#'
#' @description Class that represents a multistate model.
#'
#' @export
#' @field system A \code{\link{MultistateSystem}}
#' @field pk_model A \code{\link{PKModel}} or NULL.
Expand Down
2 changes: 2 additions & 0 deletions R/MultistateModelFit.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Minimal fit class
#'
#' @description Class that represents a multistate model with certain parameters
#' or parameter draws.
#' @export
#' @field model The \code{\link{MultistateModel}}
#' @field data A \code{\link{JointData}} object
Expand Down
1 change: 1 addition & 0 deletions R/MultistateSystem.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' A multistate system with proportional spline hazards
#'
#' @description Class that represents a multistate system.
#' @export
MultistateSystem <- R6::R6Class("MultistateSystem",

Expand Down
11 changes: 9 additions & 2 deletions R/PKModel.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' One-compartment PK Model
#'
#' @description Class that represents a one-compartment PK model with linear
#' oral absorption.
#' @export
PKModel <- R6::R6Class("PKModel",

Expand Down Expand Up @@ -131,14 +133,15 @@ PKModel <- R6::R6Class("PKModel",
dd <- simulate_dosing(df_subjects, tau = tau)
THETA <- matrix(0, N, 3)
xu <- unique(c(self$ka_covs(), self$CL_covs(), self$V2_covs()))
check_columns(df_subjects, xu)
x <- data.frame(normalize_columns(as.matrix(df_subjects[, xu])))

# Simulate observation times and parameters
t_obs <- list()
SUB_ID <- rep("s", N)
for (n in seq_len(N)) {
theta_n <- list(
ka = exp(-2 + sum(x[n, self$ka_covs()] * beta_pk$ka) + 0.1 * stats::rnorm(1)),
ka = exp(-3 + sum(x[n, self$ka_covs()] * beta_pk$ka) + 0.1 * stats::rnorm(1)),
CL = exp(-2 + sum(x[n, self$CL_covs()] * beta_pk$CL) + 0.1 * stats::rnorm(1)),
V2 = exp(-2 + sum(x[n, self$V2_covs()] * beta_pk$V2) + 0.1 * stats::rnorm(1))
)
Expand All @@ -162,7 +165,11 @@ PKModel <- R6::R6Class("PKModel",
df_out <- rbind(df_out, out)
}
df_out <- data.frame(df_out)
colnames(df_out) <- c("t_pre", "t_post", "conc_pre", "conc_post", "ss_auc")
df_out <- cbind(df_out, THETA)
colnames(df_out) <- c(
"t_pre", "t_post", "conc_pre", "conc_post", "ss_auc",
"ka", "CL", "V2"
)
rownames(df_out) <- NULL
df_out$pk_lloq <- 0
df_out$subject_id <- df_subjects$subject_id
Expand Down
3 changes: 2 additions & 1 deletion R/PathData.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' Path data class (R6 class)
#'
#' @export
#' @description It is not recommended for users to try to create data using
#' @description Class containing information about state paths and subjects.
#' @details It is not recommended for users to try to create data using
#' the constructor of this class. Rather use \code{\link{df_to_pathdata}}.
#' @field subject_df Data frame with one row per subject. Must have one
#' row for each subject, and
Expand Down
1 change: 1 addition & 0 deletions R/TransitionMatrix.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Defines states and possible transitions
#'
#' @export
#' @description Class that represents a transition matrix.
#' @field matrix a binary \code{N} x \code{N} matrix where
#' \code{matrix[i,j]} is 1 if transition
#' from state \code{i} to \code{j} is possible
Expand Down
4 changes: 1 addition & 3 deletions man/DosingData.Rd

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

4 changes: 1 addition & 3 deletions man/JointData.Rd

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

4 changes: 1 addition & 3 deletions man/MultiStateModel.Rd

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

5 changes: 2 additions & 3 deletions man/MultistateModelFit.Rd

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

4 changes: 1 addition & 3 deletions man/MultistateSystem.Rd

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

5 changes: 2 additions & 3 deletions man/PKModel.Rd

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

4 changes: 1 addition & 3 deletions man/PSSDosingData.Rd

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

3 changes: 3 additions & 0 deletions man/PathData.Rd

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

4 changes: 1 addition & 3 deletions man/TransitionMatrix.Rd

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