From b42f8e6ec8784ec946a4e420cbaf07df357dcdb8 Mon Sep 17 00:00:00 2001 From: jtimonen Date: Mon, 24 Nov 2025 21:28:40 +0200 Subject: [PATCH 1/4] Increment version number to 0.2.7.9000 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3f0fb8a..0e3be8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bmstate Type: Package Title: Bayesian multistate modeling -Version: 0.2.7 +Version: 0.2.7.9000 Authors@R: c(person(given = "Juho", family = "Timonen", From 0198915a382042b5bf56d7a28d4732ac3819c21a Mon Sep 17 00:00:00 2001 From: jtimonen Date: Tue, 25 Nov 2025 00:29:08 +0200 Subject: [PATCH 2/4] store all true pk params --- R/PKModel.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/PKModel.R b/R/PKModel.R index dbfed9e..78e4d1d 100644 --- a/R/PKModel.R +++ b/R/PKModel.R @@ -131,6 +131,7 @@ 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 @@ -138,7 +139,7 @@ PKModel <- R6::R6Class("PKModel", 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)) ) @@ -162,7 +163,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 From 5d4615e5157e66814869d090af50c94f07af8631 Mon Sep 17 00:00:00 2001 From: jtimonen Date: Tue, 25 Nov 2025 02:09:28 +0200 Subject: [PATCH 3/4] improve docs --- R/DosingData.R | 6 ++++++ R/JointData.R | 3 +++ R/MultistateModel.R | 2 ++ R/MultistateModelFit.R | 2 ++ R/MultistateSystem.R | 1 + R/PKModel.R | 2 ++ R/PathData.R | 3 ++- R/TransitionMatrix.R | 1 + man/DosingData.Rd | 4 +--- man/JointData.Rd | 4 +--- man/MultiStateModel.Rd | 4 +--- man/MultistateModelFit.Rd | 5 ++--- man/MultistateSystem.Rd | 4 +--- man/PKModel.Rd | 5 ++--- man/PSSDosingData.Rd | 4 +--- man/PathData.Rd | 3 +++ man/TransitionMatrix.Rd | 4 +--- 17 files changed, 32 insertions(+), 25 deletions(-) diff --git a/R/DosingData.R b/R/DosingData.R index f54c592..835f9df 100644 --- a/R/DosingData.R +++ b/R/DosingData.R @@ -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( @@ -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). diff --git a/R/JointData.R b/R/JointData.R index c0cceb3..ad84152 100644 --- a/R/JointData.R +++ b/R/JointData.R @@ -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( diff --git a/R/MultistateModel.R b/R/MultistateModel.R index a738be8..245b054 100644 --- a/R/MultistateModel.R +++ b/R/MultistateModel.R @@ -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. diff --git a/R/MultistateModelFit.R b/R/MultistateModelFit.R index 14cfcda..78f1862 100644 --- a/R/MultistateModelFit.R +++ b/R/MultistateModelFit.R @@ -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 diff --git a/R/MultistateSystem.R b/R/MultistateSystem.R index 6253f21..3078bf0 100644 --- a/R/MultistateSystem.R +++ b/R/MultistateSystem.R @@ -1,5 +1,6 @@ #' A multistate system with proportional spline hazards #' +#' @description Class that represents a multistate system. #' @export MultistateSystem <- R6::R6Class("MultistateSystem", diff --git a/R/PKModel.R b/R/PKModel.R index 78e4d1d..997156d 100644 --- a/R/PKModel.R +++ b/R/PKModel.R @@ -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", diff --git a/R/PathData.R b/R/PathData.R index fe691ee..428ac83 100644 --- a/R/PathData.R +++ b/R/PathData.R @@ -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 diff --git a/R/TransitionMatrix.R b/R/TransitionMatrix.R index 8ab6a90..fba740a 100644 --- a/R/TransitionMatrix.R +++ b/R/TransitionMatrix.R @@ -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 diff --git a/man/DosingData.Rd b/man/DosingData.Rd index 22138ff..c448a9c 100644 --- a/man/DosingData.Rd +++ b/man/DosingData.Rd @@ -4,9 +4,7 @@ \alias{DosingData} \title{Dosing data class (R6 class)} \description{ -Dosing data class (R6 class) - -Dosing data class (R6 class) +Contains information about taken doses and dose times. } \section{Public fields}{ \if{html}{\out{
}} diff --git a/man/JointData.Rd b/man/JointData.Rd index 8262a35..f191aaf 100644 --- a/man/JointData.Rd +++ b/man/JointData.Rd @@ -4,9 +4,7 @@ \alias{JointData} \title{Joint data class (R6 class)} \description{ -Joint data class (R6 class) - -Joint data class (R6 class) +Contains data about both the state paths and dosing. } \section{Public fields}{ \if{html}{\out{
}} diff --git a/man/MultiStateModel.Rd b/man/MultiStateModel.Rd index 97d0a6b..0a2b4ae 100644 --- a/man/MultiStateModel.Rd +++ b/man/MultiStateModel.Rd @@ -4,9 +4,7 @@ \alias{MultistateModel} \title{Main model class} \description{ -Main model class - -Main model class +Class that represents a multistate model. } \section{Public fields}{ \if{html}{\out{
}} diff --git a/man/MultistateModelFit.Rd b/man/MultistateModelFit.Rd index ecef503..b574e52 100644 --- a/man/MultistateModelFit.Rd +++ b/man/MultistateModelFit.Rd @@ -4,9 +4,8 @@ \alias{MultistateModelFit} \title{Minimal fit class} \description{ -Minimal fit class - -Minimal fit class +Class that represents a multistate model with certain parameters +or parameter draws. } \section{Public fields}{ \if{html}{\out{
}} diff --git a/man/MultistateSystem.Rd b/man/MultistateSystem.Rd index 529ec81..9e550af 100644 --- a/man/MultistateSystem.Rd +++ b/man/MultistateSystem.Rd @@ -4,9 +4,7 @@ \alias{MultistateSystem} \title{A multistate system with proportional spline hazards} \description{ -A multistate system with proportional spline hazards - -A multistate system with proportional spline hazards +Class that represents a multistate system. } \section{Methods}{ \subsection{Public methods}{ diff --git a/man/PKModel.Rd b/man/PKModel.Rd index e0eaeed..e035db1 100644 --- a/man/PKModel.Rd +++ b/man/PKModel.Rd @@ -4,9 +4,8 @@ \alias{PKModel} \title{One-compartment PK Model} \description{ -One-compartment PK Model - -One-compartment PK Model +Class that represents a one-compartment PK model with linear +oral absorption. } \section{Methods}{ \subsection{Public methods}{ diff --git a/man/PSSDosingData.Rd b/man/PSSDosingData.Rd index 178d8f6..4811553 100644 --- a/man/PSSDosingData.Rd +++ b/man/PSSDosingData.Rd @@ -4,9 +4,7 @@ \alias{PSSDosingData} \title{Partially steady-state dosing data class (R6 class)} \description{ -Partially steady-state dosing data class (R6 class) - -Partially steady-state dosing data class (R6 class) +Contains information about taken doses and dose times. } \section{Super class}{ \code{\link[bmstate:DosingData]{bmstate::DosingData}} -> \code{PSSDosingData} diff --git a/man/PathData.Rd b/man/PathData.Rd index abeea68..c2f8dfd 100644 --- a/man/PathData.Rd +++ b/man/PathData.Rd @@ -4,6 +4,9 @@ \alias{PathData} \title{Path data class (R6 class)} \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}}. } diff --git a/man/TransitionMatrix.Rd b/man/TransitionMatrix.Rd index 522227a..b804fd3 100644 --- a/man/TransitionMatrix.Rd +++ b/man/TransitionMatrix.Rd @@ -4,9 +4,7 @@ \alias{TransitionMatrix} \title{Defines states and possible transitions} \description{ -Defines states and possible transitions - -Defines states and possible transitions +Class that represents a transition matrix. } \section{Public fields}{ \if{html}{\out{
}} From 3453db0c5aa18c19ed8a37ffa89cadad91ea3dae Mon Sep 17 00:00:00 2001 From: jtimonen Date: Tue, 25 Nov 2025 02:17:56 +0200 Subject: [PATCH 4/4] Increment version number to 0.2.8 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0e3be8c..9775d40 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bmstate Type: Package Title: Bayesian multistate modeling -Version: 0.2.7.9000 +Version: 0.2.8 Authors@R: c(person(given = "Juho", family = "Timonen",