Skip to content

Commit

Permalink
Standardise rbmi References (#450)
Browse files Browse the repository at this point in the history
Closes #448
  • Loading branch information
gowerc authored Oct 16, 2024
1 parent 1ac248e commit 8566c7c
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# rbmi 1.2.3

* Minor internal tweaks to ensure compatibility with the packages rbmi depends on
* Minor internal tweaks to ensure compatibility with the packages `rbmi` depends on

# rbmi 1.2.1

Expand Down
6 changes: 3 additions & 3 deletions R/analyse.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
#'
#' @section Parallelisation:
#' To speed up the evaluation of `analyse()` you can use the `ncores` argument to enable parallelisation.
#' Simply providing an integer will get rbmi to automatically spawn that many background processes
#' Simply providing an integer will get `rbmi` to automatically spawn that many background processes
#' to parallelise across. If you are using a custom analysis function then you need to ensure
#' that any libraries or global objects required by your function are available in the
#' sub-processes. To do this you need to use the [`make_rbmi_cluster()`] function for example:
Expand Down Expand Up @@ -127,8 +127,8 @@
#' a temporary file on the local disk from which it is then read into each sub-process. This is
#' done to avoid the overhead of transferring the data over the network. Our assumption is that
#' if you are at the stage where you need to be parallelising your analysis over a remote cluster
#' then you would likely be better off parallelising across multiple rbmi runs rather than within
#' a single rbmi run.
#' then you would likely be better off parallelising across multiple `rbmi` runs rather than within
#' a single `rbmi` run.
#'
#' Finally, if you are doing a tipping point analysis you can get a reasonable performance
#' improvement by re-using the cluster between each call to `analyse()` e.g.
Expand Down
2 changes: 1 addition & 1 deletion R/lsmeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' ```
#' emmeans::emmeans(model, specs = "<treatment>", counterfactual = "<treatment>")
#' ```
#' Note that to ensure backwards compatibility with previous versions of rbmi
#' Note that to ensure backwards compatibility with previous versions of `rbmi`
#' `weights = "proportional"` is an alias for `weights = "counterfactual"`.
#' To get results consistent with `emmeans`'s `weights = "proportional"`
#' please use `weights = "proportional_em"`.
Expand Down
12 changes: 6 additions & 6 deletions R/parallel.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

#' Create a rbmi ready cluster
#' Create a `rbmi` ready cluster
#'
#' @param ncores Number of parallel processes to use or an existing cluster to make use of
#' @param objects a named list of objects to export into the sub-processes
#' @param packages a character vector of libraries to load in the sub-processes
#'
#' This function is a wrapper around `parallel::makePSOCKcluster()` but takes
#' care of configuring rbmi to be used in the sub-processes as well as loading
#' care of configuring `rbmi` to be used in the sub-processes as well as loading
#' user defined objects and libraries and setting the seed for reproducibility.
#'
#' If `ncores` is `1` this function will return `NULL`.
#'
#' If `ncores` is a cluster created via `parallel::makeCluster()` then this function
#' just takes care of inserting the relevant rbmi objects into the existing cluster.
#' just takes care of inserting the relevant `rbmi` objects into the existing cluster.
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -54,7 +54,7 @@ make_rbmi_cluster <- function(ncores = 1, objects = NULL, packages = NULL) {

# Load user defined packages
packages <- c(packages, "assertthat")
# Remove attempts to load rbmi as this will be covered later
# Remove attempts to load `rbmi` as this will be covered later
packages <- setdiff(packages, "rbmi")
devnull <- parallel::clusterCall(
cl,
Expand All @@ -65,7 +65,7 @@ make_rbmi_cluster <- function(ncores = 1, objects = NULL, packages = NULL) {
# Ensure reproducibility
parallel::clusterSetRNGStream(cl, sample.int(1))

# If user has previously configured rbmi sub-processes then early exit
# If user has previously configured `rbmi` sub-processes then early exit
exported_rbmi <- unlist(parallel::clusterEvalQ(cl, exists("..exported..parallel..rbmi")))
if (all(exported_rbmi)) {
return(cl)
Expand All @@ -87,7 +87,7 @@ make_rbmi_cluster <- function(ncores = 1, objects = NULL, packages = NULL) {
)
}

# Set variable to signify rbmi has been configured
# Set variable to signify `rbmi` has been configured
devnull <- parallel::clusterEvalQ(cl, {
..exported..parallel..rbmi <- TRUE
})
Expand Down
4 changes: 2 additions & 2 deletions R/rbmi.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#' @description
#'
#' The rbmi package is used to perform reference based multiple imputation. The package
#' The `rbmi` package is used to perform reference based multiple imputation. The package
#' provides implementations for common, patient-specific imputation strategies whilst allowing the user to
#' select between various standard Bayesian and frequentist approaches.
#'
Expand All @@ -11,7 +11,7 @@
#' - [analyse()] - Analyses multiple datasets
#' - [pool()] - Pools multiple results into a single statistic
#'
#' To learn more about rbmi, please see the quickstart vignette:
#' To learn more about `rbmi`, please see the quickstart vignette:
#'
#' `vignette(topic= "quickstart", package = "rbmi")`
#'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ status](https://www.r-pkg.org/badges/version/rbmi)](https://cran.r-project.org/p

## Overview

rbmi is a R package for imputation of missing data in clinical trials with continuous multivariate normal longitudinal outcomes.
The `rbmi` package is used for the imputation of missing data in clinical trials with continuous multivariate normal longitudinal outcomes.
It supports imputation under a missing at random (MAR) assumption, reference-based imputation methods,
and delta adjustments (as required for sensitivity analysis such as tipping point analyses). The package implements both Bayesian and
approximate Bayesian multiple imputation combined with Rubin's rules for inference, and frequentist conditional mean imputation combined with
Expand Down Expand Up @@ -46,7 +46,7 @@ vignette(topic = "quickstart", package = "rbmi")

## Validation

For clarification on the current validation status of rbmi please see the FAQ vignette.
For clarification on the current validation status of `rbmi` please see the FAQ vignette.


## Support
Expand Down
6 changes: 3 additions & 3 deletions man/analyse.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/ancova.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/ancova_single.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/lsmeans.Rd

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

8 changes: 4 additions & 4 deletions man/make_rbmi_cluster.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/rbmi-package.Rd

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

2 changes: 1 addition & 1 deletion misc/do_not_delete.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DO NOT DELETE

This is a flag file whose existance indicates to rbmi that it is running in development mode.
This is a flag file whose existance indicates to `rbmi` that it is running in development mode.
Relevant code can be found in R/parallel.R
8 changes: 4 additions & 4 deletions vignettes/CondMean_Inference.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Once the datasets have been imputed, we can call the `analyse()` function to app

```{r}
# Set analysis variables using rbmi function "set_vars"
# Set analysis variables using `rbmi` function "set_vars"
vars_an <- set_vars(
group = vars$group,
visit = vars$visit,
Expand Down Expand Up @@ -237,7 +237,7 @@ get_delta_match_refBased <- function(draws, data_ice, references) {
cmi <- cmi[, c(vars$subjid, vars$visit, vars$outcome)]
colnames(cmi)[colnames(cmi) == vars$outcome] <- "y_imp"
# Map back original patients id since rbmi re-code ids to ensure id uniqueness
# Map back original patients id since `rbmi` re-code ids to ensure id uniqueness
cmi[[vars$subjid]] <- idmap[match(cmi[[vars$subjid]], names(idmap))]
Expand Down Expand Up @@ -269,7 +269,7 @@ get_delta_match_refBased <- function(draws, data_ice, references) {
cmi_MAR <- cmi_MAR[, c(vars$subjid, vars$visit, vars$outcome)]
colnames(cmi_MAR)[colnames(cmi_MAR) == vars$outcome] <- "y_MAR"
# Map back original patients id since rbmi re-code ids to ensure id uniqueness
# Map back original patients id since `rbmi` re-code ids to ensure id uniqueness
cmi_MAR[[vars$subjid]] <- idmap[match(cmi_MAR[[vars$subjid]], names(idmap))]
# Derive delta adjustment "aligned with ref-based imputation",
Expand Down Expand Up @@ -300,7 +300,7 @@ The argument `delta` can be used to add a delta-adjustment prior to the analysis

```{r}
# Set analysis variables using rbmi function "set_vars"
# Set analysis variables using `rbmi` function "set_vars"
vars_an <- set_vars(
group = vars$group,
visit = vars$visit,
Expand Down
8 changes: 4 additions & 4 deletions vignettes/CondMean_Inference.html
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ <h2><span class="header-section-number">3.2</span> Impute</h2>
<h2><span class="header-section-number">3.3</span> Analyse</h2>
<p>Once the datasets have been imputed, we can call the <code>analyse()</code> function to apply the complete-data analysis model (here ANCOVA) to each imputed dataset.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a></span>
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a><span class="co"># Set analysis variables using rbmi function &quot;set_vars&quot;</span></span>
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a><span class="co"># Set analysis variables using `rbmi` function &quot;set_vars&quot;</span></span>
<span id="cb3-3"><a href="#cb3-3" tabindex="-1"></a>vars_an <span class="ot">&lt;-</span> <span class="fu">set_vars</span>(</span>
<span id="cb3-4"><a href="#cb3-4" tabindex="-1"></a> <span class="at">group =</span> vars<span class="sc">$</span>group,</span>
<span id="cb3-5"><a href="#cb3-5" tabindex="-1"></a> <span class="at">visit =</span> vars<span class="sc">$</span>visit,</span>
Expand Down Expand Up @@ -682,7 +682,7 @@ <h2><span class="header-section-number">4.2</span> Imputation step including cal
<span id="cb6-31"><a href="#cb6-31" tabindex="-1"></a> cmi <span class="ot">&lt;-</span> cmi[, <span class="fu">c</span>(vars<span class="sc">$</span>subjid, vars<span class="sc">$</span>visit, vars<span class="sc">$</span>outcome)]</span>
<span id="cb6-32"><a href="#cb6-32" tabindex="-1"></a> <span class="fu">colnames</span>(cmi)[<span class="fu">colnames</span>(cmi) <span class="sc">==</span> vars<span class="sc">$</span>outcome] <span class="ot">&lt;-</span> <span class="st">&quot;y_imp&quot;</span></span>
<span id="cb6-33"><a href="#cb6-33" tabindex="-1"></a> </span>
<span id="cb6-34"><a href="#cb6-34" tabindex="-1"></a> <span class="co"># Map back original patients id since rbmi re-code ids to ensure id uniqueness</span></span>
<span id="cb6-34"><a href="#cb6-34" tabindex="-1"></a> <span class="co"># Map back original patients id since `rbmi` re-code ids to ensure id uniqueness</span></span>
<span id="cb6-35"><a href="#cb6-35" tabindex="-1"></a> </span>
<span id="cb6-36"><a href="#cb6-36" tabindex="-1"></a> cmi[[vars<span class="sc">$</span>subjid]] <span class="ot">&lt;-</span> idmap[<span class="fu">match</span>(cmi[[vars<span class="sc">$</span>subjid]], <span class="fu">names</span>(idmap))]</span>
<span id="cb6-37"><a href="#cb6-37" tabindex="-1"></a> </span>
Expand Down Expand Up @@ -714,7 +714,7 @@ <h2><span class="header-section-number">4.2</span> Imputation step including cal
<span id="cb6-63"><a href="#cb6-63" tabindex="-1"></a> cmi_MAR <span class="ot">&lt;-</span> cmi_MAR[, <span class="fu">c</span>(vars<span class="sc">$</span>subjid, vars<span class="sc">$</span>visit, vars<span class="sc">$</span>outcome)]</span>
<span id="cb6-64"><a href="#cb6-64" tabindex="-1"></a> <span class="fu">colnames</span>(cmi_MAR)[<span class="fu">colnames</span>(cmi_MAR) <span class="sc">==</span> vars<span class="sc">$</span>outcome] <span class="ot">&lt;-</span> <span class="st">&quot;y_MAR&quot;</span></span>
<span id="cb6-65"><a href="#cb6-65" tabindex="-1"></a> </span>
<span id="cb6-66"><a href="#cb6-66" tabindex="-1"></a> <span class="co"># Map back original patients id since rbmi re-code ids to ensure id uniqueness</span></span>
<span id="cb6-66"><a href="#cb6-66" tabindex="-1"></a> <span class="co"># Map back original patients id since `rbmi` re-code ids to ensure id uniqueness</span></span>
<span id="cb6-67"><a href="#cb6-67" tabindex="-1"></a> cmi_MAR[[vars<span class="sc">$</span>subjid]] <span class="ot">&lt;-</span> idmap[<span class="fu">match</span>(cmi_MAR[[vars<span class="sc">$</span>subjid]], <span class="fu">names</span>(idmap))]</span>
<span id="cb6-68"><a href="#cb6-68" tabindex="-1"></a> </span>
<span id="cb6-69"><a href="#cb6-69" tabindex="-1"></a> <span class="co"># Derive delta adjustment &quot;aligned with ref-based imputation&quot;,</span></span>
Expand All @@ -741,7 +741,7 @@ <h2><span class="header-section-number">4.3</span> Analyse</h2>
<code>analyse()</code> will take as the input argument <code>imputations = res_delta_adjust$imputeObj_MAR</code>, i.e. the imputation object corresponding to the MAR imputation (and not the JR imputation).
The argument <code>delta</code> can be used to add a delta-adjustment prior to the analysis and we set this to the delta-adjustment obtained in the previous step: <code>delta = res_delta_adjust$delta_adjust</code>.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a></span>
<span id="cb7-2"><a href="#cb7-2" tabindex="-1"></a><span class="co"># Set analysis variables using rbmi function &quot;set_vars&quot;</span></span>
<span id="cb7-2"><a href="#cb7-2" tabindex="-1"></a><span class="co"># Set analysis variables using `rbmi` function &quot;set_vars&quot;</span></span>
<span id="cb7-3"><a href="#cb7-3" tabindex="-1"></a>vars_an <span class="ot">&lt;-</span> <span class="fu">set_vars</span>(</span>
<span id="cb7-4"><a href="#cb7-4" tabindex="-1"></a> <span class="at">group =</span> vars<span class="sc">$</span>group,</span>
<span id="cb7-5"><a href="#cb7-5" tabindex="-1"></a> <span class="at">visit =</span> vars<span class="sc">$</span>visit,</span>
Expand Down
6 changes: 3 additions & 3 deletions vignettes/FAQ.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ It is intended to be read after the `rbmi: Quickstart` vignette.
<br>


## Is rbmi validated?
## Is `rbmi` validated?

With regards to software in the pharmaceutical industry, validation is the act of ensuring that the software meets the needs and
requirements of users given the conditions of actual use. The FDA provides general principles and
Expand All @@ -44,12 +44,12 @@ validation depends on the entire software stack and the specific processes of ea

That being said, some of the core components of any validation process are the design specification
(what is the software supposed to do) as well as the testing / test results that demonstrate that
the design specification has been met. For rbmi, the design specification is documented extensively,
the design specification has been met. For `rbmi`, the design specification is documented extensively,
both at a macro level in vignettes and literature publications, and at a micro level in detailed
function manuals. This is supported by our extensive suite of unit and integration tests, which
ensure the software consistently produces correct output across a wide range of input scenarios.

This documentation and test coverage enable rbmi to be easily installed and integrated into any
This documentation and test coverage enable `rbmi` to be easily installed and integrated into any
R system, in alignment with the system's broader validation process.


Expand Down
Loading

0 comments on commit 8566c7c

Please sign in to comment.