Skip to content

Commit

Permalink
- eliminated CRAN error related to Unicode character ⁠ (U+2060)
Browse files Browse the repository at this point in the history
- some re-wording & code beautification
  • Loading branch information
wojcieko committed Dec 31, 2023
1 parent e0969b8 commit 1350f33
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 285 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## BayesianMCPMod 0.1.5
## BayesianMCPMod 1.0.0

- Initial release of the 'BayesianMCPMod' package
- Special thanks to Jana Gierse, Bjoern Bornkamp, Chen Yao, Marius Thoma & Mitchell Thomann for their review and valuable comments
- Thanks to Kevin Kunzmann for supporting around the R infrastructure and Frank Fleischer for methodological support
- Thanks to Kevin Kunzmann for supporting around the R infrastructure and Frank Fleischer for methodological support
47 changes: 25 additions & 22 deletions R/BMCPMod.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @param alpha_crit_val (Un-adjusted) Critical value to be used for the MCP testing step. Passed to the getCritProb() function for the calculation of adjusted critical values (on the probability scale). Default is 0.05.

Check warning on line 10 in R/BMCPMod.R

View workflow job for this annotation

GitHub Actions / lint

file=R/BMCPMod.R,line=10,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 220 characters.
#' @param simple Boolean variable defining whether simplified fit will be applied. Passed to the getModelFits function. Default FALSE.

Check warning on line 11 in R/BMCPMod.R

View workflow job for this annotation

GitHub Actions / lint

file=R/BMCPMod.R,line=11,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 134 characters.
#' @param reestimate Boolean variable defining whether critical value should be calculated with re-estimated contrasts (see getCritProb function for more details). Default FALSE

Check warning on line 12 in R/BMCPMod.R

View workflow job for this annotation

GitHub Actions / lint

file=R/BMCPMod.R,line=12,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 177 characters.
#' @param contr Allows specification of a fixed contrasts matrix. Default NULL
#' @param contr An object of class 'optContr' as created by the getContr() function. Allows specification of a fixed contrasts matrix. Default NULL

Check warning on line 13 in R/BMCPMod.R

View workflow job for this annotation

GitHub Actions / lint

file=R/BMCPMod.R,line=13,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 147 characters.
#' @param dr_means A vector, allows specification of individual (not model based) assumed effects per dose group. Default NULL
#'
#' @return Returns success probabilities for the different assumed dose-response shapes, attributes also includes information around average success rate (across all assumed models) and prior Effective sample size
Expand All @@ -37,11 +37,13 @@
#' n_patients = n_patients,
#' mods = mods,
#' prior_list = prior_list,
#' sd = sd)
#' sd = sd,
#' n_sim = 1e2) # speed up exammple run time
#'
#' success_probabilities
#'
#' }
#'
#' @export
assessDesign <- function (

Expand Down Expand Up @@ -158,30 +160,31 @@ assessDesign <- function (
#' 4) Frequentist approach+re-estimation:If only a se_new_trial (i.e. the estimated variability per dose group of a new trial) is provided, optimal contrast vectors are calculated from the
#' regular MCPMod for this specific vector of standard errors. For the actual evaluation this vector of standard errors is translated into a (diagonal) matrix of variances
#'
#' @param mods An object of class "Mods" as specified in the DoseFinding package.
#' @param mods An object of class 'Mods' as created by the function 'DoseFinding::Mods()'
#' @param dose_levels Vector containing the different dosage levels.
#' @param dose_weights Vector specifying weights for the different doses. Please note that in case this information is provided together with a prior (i.e. Option i) is planned) these two inputs should be provided on the same scale (e.g. patient numbers). Default NULL
#' @param prior_list A prior_list object, only required as input for Option i). Default NULL
#' @param sd_posterior A vector of positive values with information about the variability of the posterior distribution, only required for Option iii). Default NULL
#' @param se_new_trial A vector of positive values with information about the observed variability, only required for Option iv). Default NULL
#' @param dose_weights Vector specifying weights for the different doses. Please note that in case this information is provided together with a prior (i.e. Option 1) is planned these two inputs should be provided on the same scale (e.g. patient numbers). Default NULL
#' @param prior_list A list of objects of class 'normMix' as created with 'RBesT::mixnorm()'. Only required as input for Option 1. Default NULL
#' @param sd_posterior A vector of positive values with information about the variability of the posterior distribution, only required for Option 3. Default NULL
#' @param se_new_trial A vector of positive values with information about the observed variability, only required for Option 4. Default NULL

#'
#' @examples
#' # example code
#' mods <- DoseFinding::Mods(linear = NULL,
#' linlog = NULL,
#' emax = c(0.5, 1.2),
#' exponential = 2,
#' doses = c(0, 0.5, 2,4, 8),
#' maxEff = 6)
#' dose_levels <- c(0, 0.5, 2, 4, 8)
#' sd_posterior <- c(2.8,3,2.5,3.5,4)
#' mods <- DoseFinding::Mods(
#' linear = NULL,
#' linlog = NULL,
#' emax = c(0.5, 1.2),
#' exponential = 2,
#' doses = dose_levels,
#' maxEff = 6)
#' sd_posterior <- c(2.8, 3, 2.5, 3.5, 4)
#'
#' contr_mat <- getContr(
#' mods = mods,
#' dose_levels = dose_levels,
#' sd_posterior = sd_posterior)
#' mods = mods,
#' dose_levels = dose_levels,
#' sd_posterior = sd_posterior)
#'
#' @return Object of class ‘⁠optContr⁠ . A list containing entries contMat and muMat, and CorrMat. Specified in the DoseFinding package.
#' @return An object of class 'optContr' as provided by the function 'DoseFinding::optContr()'.
#'
#' @export
getContr <- function (
Expand Down Expand Up @@ -323,8 +326,8 @@ getCritProb <- function (
#'
#' @description Performs Bayesian MCP Test step and modeling in a combined fashion. See performBayesianMCP() function for MCP Test step and getModelFits() for the modelling step
#'
#' @param posterior_list A getPosterior object with information about the (mixture) posterior distribution per dose group
#' @param contr An object of class ‘⁠optContr' as specified by the getContr() function, contrast matrix to be used for the testing step.
#' @param posterior_list An object of class 'postList' as created by getPosterior() containing information about the (mixture) posterior distribution per dose group
#' @param contr An object of class 'optContr' as created by the getContr() function. It contains the contrast matrix to be used for the testing step.
#' @param crit_prob_adj A getCritProb object, specifying the critical value to be used for the testing (on the probability scale).
#' @param simple Boolean variable, defining whether simplified fit will be applied. Passed to the getModelFits() function. Default FALSE.
#' @examples
Expand Down Expand Up @@ -468,7 +471,7 @@ addSignificance <- function (
#' In order to obtain significant test decision we consider the maximum of the posterior probabilities across the different models. This maximum is compared with a (multiplicity adjusted) critical value (on the probability scale).
#' @references Fleischer F, Bossert S, Deng Q, Loley C, Gierse J. 2022. Bayesian MCPMod. Pharmaceutical Statistics. 21(3): 654-670. doi:10.1002/pst.2193
#' @param posterior_list An object derived with getPosterior with information about the (mixture) posterior distribution per dose group
#' @param contr An object of class ‘⁠optContr' as specified by the getContr() function, contrast matrix to be used for the testing step
#' @param contr An object of class 'optContr' as created by the getContr() function. It contains the contrast matrix to be used for the testing step.
#' @param crit_prob_adj A getCritProb object, specifying the critical value to be used for the testing (on the probability scale)
#'
#' @examples
Expand Down
15 changes: 8 additions & 7 deletions R/bootstrapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
#' DG_2 = RBesT::mixnorm(comp1 = c(w = 1, m = 4, s = 1.5), sigma = 2) ,
#' DG_3 = RBesT::mixnorm(comp1 = c(w = 1, m = 6, s = 1.2), sigma = 2) ,
#' DG_4 = RBesT::mixnorm(comp1 = c(w = 1, m = 6.5, s = 1.1), sigma = 2))
#' models <- c("exponential", "linear")
#' dose_levels <- c(0, 1, 2, 4, 8)
#' fit <- getModelFits(models = models,
#' posterior = posterior_list,
#' dose_levels = dose_levels,
#' simple = TRUE)
#' models <- c("exponential", "linear")
#' dose_levels <- c(0, 1, 2, 4, 8)
#' fit <- getModelFits(models = models,
#' posterior = posterior_list,
#' dose_levels = dose_levels,
#' simple = TRUE)
#'
#' getBootstrapQuantiles(model_fits = fit,
#' quantiles = c(0.025, 0.5, 0.975),
#' n_samples = 100, # speeding up example run time
#' n_samples = 10, # speeding up example run time
#' doses = c(0, 6, 8))
#' @return A data frame with entries doses, models, and quantiles
#'
#' @export
getBootstrapQuantiles <- function (

Expand Down
2 changes: 1 addition & 1 deletion R/modelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@ addModelWeights <- function (

return (model_fits_out)

}
}
6 changes: 4 additions & 2 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#' @title plot.modelFits
#'
#' @description Plot function based on the ggplot2 package. Providing visualizations for each model and a average Fit.
#' Black lines show the fitted dose response models and an AIC based average model. Dots indicate the posterior median and vertical lines show corresponding credible intervals (i.e. the variability of the posterior distribution of the respective dose group).
#' To assess the uncertainty of the model fit one can in addition visualize credible bands (default coloring as orange shaded areas). The calculation of these bands is performed via the getBootstrapQuantiles() function.
#' Black lines show the fitted dose response models and an AIC based average model.
#' Dots indicate the posterior median and vertical lines show corresponding credible intervals (i.e. the variability of the posterior distribution of the respective dose group).
#' To assess the uncertainty of the model fit one can in addition visualize credible bands (default coloring as orange shaded areas).
#' The calculation of these bands is performed via the getBootstrapQuantiles() function.
#' The default setting is that these credible bands are not calculated.
#' @param x An object of type modelFits
#' @param gAIC Logical value indicating whether gAIC values are shown in the plot. Default TRUE
Expand Down
11 changes: 5 additions & 6 deletions R/posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ getPosteriorI <- function(
#'
#' @description This function calculates the effective sample size for every dose group via the RBesT function ess().
#'
#' @param post_list A posterior list object, for which the effective sample size (per dose group) should be calculated
#' @param post_list A posterior list object, for which the effective sample size for each dose group should be calculated
#'
#' @return A vector of the effective sample sizes (per dose group)
#' @return A vector of the effective sample sizes for each dose group
#'
#' @export
getESS <- function (

Expand All @@ -156,7 +157,7 @@ getESS <- function (
) {

# make s3 method for postList object
suppressMessages(sapply(post_list, RBesT::ess))
suppressMessages(round(sapply(post_list, RBesT::ess), 1))

}

Expand All @@ -176,6 +177,4 @@ getPostCombsI <- function (

return (post_combs)

}


}
4 changes: 3 additions & 1 deletion R/s3methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ print.BayesianMCP <- function (
}

## ModelFits ----------------------------------------------

#' @title predict.modelFits
#' @description This function performs model predictions based on the provided
#' model and dose specifications
Expand All @@ -101,7 +102,8 @@ print.BayesianMCP <- function (
#'
#' predict(fit, doses = c(0, 1, 3, 4, 6, 8))
#'
#' @return a list with the model predictions for the specified models and doses
#' @return a list with the model predictions for the specified models and doses
#'
#' @export
predict.modelFits <- function (

Expand Down
6 changes: 4 additions & 2 deletions man/assessDesign.Rd

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

14 changes: 7 additions & 7 deletions man/getBootstrapQuantiles.Rd

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

34 changes: 17 additions & 17 deletions man/getContr.Rd

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

4 changes: 2 additions & 2 deletions man/getESS.Rd

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

2 changes: 1 addition & 1 deletion man/performBayesianMCP.Rd

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

4 changes: 2 additions & 2 deletions man/performBayesianMCPMod.Rd

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

6 changes: 4 additions & 2 deletions man/plot.modelFits.Rd

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

Loading

0 comments on commit 1350f33

Please sign in to comment.