diff --git a/DESCRIPTION b/DESCRIPTION index ebe2e55..2e09161 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,4 @@ -Package: ModStanR +Package: outstandR Title: Model-based Standardisation Version: 0.0.0.9000 Authors@R: c( @@ -39,5 +39,5 @@ Suggests: VignetteBuilder: knitr Config/testthat/edition: 3 RdMacros: Rdpack -URL: https://github.com/StatisticsHealthEconomics/ModStanR/ -BugReports: https://github.com/StatisticsHealthEconomics/ModStanR/issues/ +URL: https://github.com/StatisticsHealthEconomics/outstandR/ +BugReports: https://github.com/StatisticsHealthEconomics/outstandR/issues/ diff --git a/NAMESPACE b/NAMESPACE index b7d8deb..d3a1ac4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,10 +7,10 @@ S3method(IPD_stats,maic) S3method(IPD_stats,stc) export(ALD_stats) export(IPD_stats) -export(ModStanR) export(marginal_treatment_effect) export(marginal_variance) export(new_strategy) +export(outstandR) export(strategy_gcomp_ml) export(strategy_gcomp_stan) export(strategy_maic) diff --git a/NEWS.md b/NEWS.md index 163d2b3..ebd4cb6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,3 @@ -# ModStanR (development version) +# outstandR (development version) * Initial CRAN submission. diff --git a/R/ModStanR.R b/R/ModStanR.R index cffe13c..eb98dd4 100644 --- a/R/ModStanR.R +++ b/R/ModStanR.R @@ -2,9 +2,9 @@ #' @title Calculate the difference between treatments using all evidence #' #' @description -#' This is the main, top-level wrapper for `{ModStanR}`. +#' This is the main, top-level wrapper for `{outstandR}`. #' Methods taken from -#' \insertCite{RemiroAzocar2022}{ModStanR}. +#' \insertCite{RemiroAzocar2022}{outstandR}. #' #' @param AC.IPD Individual-level patient data. Suppose between studies _A_ and _C_. #' @param BC.ALD Aggregate-level data. Suppose between studies _B_ and _C_. @@ -12,14 +12,14 @@ #' `strategy_maic()`, `strategy_stc()`, `strategy_gcomp_ml()` and `strategy_gcomp_stan()` #' @param CI Confidence interval; between 0,1 #' @param ... Additional arguments -#' @return List of length 3 of statistics as a `ModStanR` class object. +#' @return List of length 3 of statistics as a `outstandR` class object. #' Containing statistics between each pair of treatments. #' These are the mean contrasts, variances and confidence intervals, #' respectively. #' @importFrom Rdpack reprompt #' #' @references -#' \insertRef{RemiroAzocar2022}{ModStanR} +#' \insertRef{RemiroAzocar2022}{outstandR} #' #' @export #' @examples @@ -29,18 +29,18 @@ #' lin_form <- as.formula("y ~ X3 + X4 + trt*X1 + trt*X2") #' #' # matching-adjusted indirect comparison -#' ModStanR_maic <- ModStanR(AC_IPD, BC_ALD, strategy = strategy_maic(formula = lin_form)) +#' outstandR_maic <- outstandR(AC_IPD, BC_ALD, strategy = strategy_maic(formula = lin_form)) #' #' # simulated treatment comparison -#' ModStanR_stc <- ModStanR(AC_IPD, BC_ALD, strategy = strategy_stc(lin_form)) +#' outstandR_stc <- outstandR(AC_IPD, BC_ALD, strategy = strategy_stc(lin_form)) #' #' # G-computation with maximum likelihood -#' # ModStanR_gcomp_ml <- ModStanR(AC_IPD, BC_ALD, strategy = strategy_gcomp_ml(lin_form)) +#' # outstandR_gcomp_ml <- outstandR(AC_IPD, BC_ALD, strategy = strategy_gcomp_ml(lin_form)) #' #' # G-computation with Bayesian inference -#' ModStanR_gcomp_stan <- ModStanR(AC_IPD, BC_ALD, strategy = strategy_gcomp_stan(lin_form)) +#' outstandR_gcomp_stan <- outstandR(AC_IPD, BC_ALD, strategy = strategy_gcomp_stan(lin_form)) #' -ModStanR <- function(AC.IPD, BC.ALD, strategy, CI = 0.95, ...) { +outstandR <- function(AC.IPD, BC.ALD, strategy, CI = 0.95, ...) { if (CI <= 0 || CI >= 1) stop("CI argument must be between 0 and 1.") ##TODO: as method instead? @@ -67,21 +67,21 @@ ModStanR <- function(AC.IPD, BC.ALD, strategy, CI = 0.95, ...) { ald <- BC.ALD[keep_names] - AC_ModStanR <- IPD_stats(strategy, ipd = ipd, ald = ald, ...) - BC_ModStanR <- ALD_stats(ald = ald) + AC_outstandR <- IPD_stats(strategy, ipd = ipd, ald = ald, ...) + BC_outstandR <- ALD_stats(ald = ald) upper <- 0.5 + CI/2 ci_range <- c(1-upper, upper) contrasts <- list( - AB = AC_ModStanR$mean - BC_ModStanR$mean, - AC = AC_ModStanR$mean, - BC = BC_ModStanR$mean) + AB = AC_outstandR$mean - BC_outstandR$mean, + AC = AC_outstandR$mean, + BC = BC_outstandR$mean) contrast_variances <- list( - AB = AC_ModStanR$var + BC_ModStanR$var, - AC = AC_ModStanR$var, - BC = BC_ModStanR$var) + AB = AC_outstandR$var + BC_outstandR$var, + AC = AC_outstandR$var, + BC = BC_outstandR$var) contrast_ci <- list( AB = contrasts$AB + qnorm(ci_range)*as.vector(sqrt(contrast_variances$AB)), @@ -94,5 +94,5 @@ ModStanR <- function(AC.IPD, BC.ALD, strategy, CI = 0.95, ...) { structure(stats, CI = CI, - class = c("ModStanR", class(stats))) + class = c("outstandR", class(stats))) } diff --git a/R/data.R b/R/data.R index 7c76df1..b5d9a2d 100644 --- a/R/data.R +++ b/R/data.R @@ -5,7 +5,7 @@ #' #' @name AC_IPD #' @docType data -#' @format A data list including the variables needed for the ModStanR basic example. The variables are as follows: +#' @format A data list including the variables needed for the outstandR basic example. The variables are as follows: #' \describe{ #' \item{list("X1")}{Numeric covariate} #' \item{list("X2")}{Numeric covariate} @@ -25,7 +25,7 @@ NULL #' #' @name BC_ALD #' @docType data -#' @format A data list including the variables needed for the ModStanR basic example. The variables are as follows: +#' @format A data list including the variables needed for the outstandR basic example. The variables are as follows: #' \describe{ #' \item{list("mean.X1")}{Numeric value} #' \item{list("mean.X2")}{Numeric value} diff --git a/R/maic.R b/R/maic.R index d7370af..27edc63 100644 --- a/R/maic.R +++ b/R/maic.R @@ -3,13 +3,13 @@ #' #' Matching-adjusted indirect comparison weights. #' Method is taken from -#' \insertCite{Signorovitch2010}{ModStanR}. +#' \insertCite{Signorovitch2010}{outstandR}. #' #' @param X_EM Centred \eqn{S=1} effect modifiers; matrix or data frame #' @return Estimated weights for each individual; vector #' #' @references -#' \insertRef{Signorovitch2010}{ModStanR} +#' \insertRef{Signorovitch2010}{outstandR} #' @keywords internal #' maic_weights <- function(X_EM) { diff --git a/R/performance_measures.R b/R/performance_measures.R index 815df5a..e4b7053 100644 --- a/R/performance_measures.R +++ b/R/performance_measures.R @@ -149,7 +149,7 @@ var.ratio <- function(theta.hat, std.err) { #' Variability ratio MCSE #' #' Approximation of ratio variance based on independence of avg. se and emp.se -#' see \insertCite{wolter2007}{ModStanR} +#' see \insertCite{wolter2007}{outstandR} #' #' @param avg.se Average SE #' @param emp.se Emp SE @@ -157,7 +157,7 @@ var.ratio <- function(theta.hat, std.err) { #' @param var.emp.se Variance of Emp SE #' #' @references -#' \insertRef{wolter2007}{ModStanR} +#' \insertRef{wolter2007}{outstandR} #' #' @keywords internal #' diff --git a/R/print.R b/R/print.R index 681c421..c19cdd0 100644 --- a/R/print.R +++ b/R/print.R @@ -1,6 +1,6 @@ #' -print.ModStanR <- function(x, newline = TRUE) { +print.outstandR <- function(x, newline = TRUE) { cat("\nContrasts:", x$contrasts, "\n") cat("\nVariances:", x$contrasts_variances, "\n") diff --git a/R/summary.R b/R/summary.R index 0db09e3..9a04996 100644 --- a/R/summary.R +++ b/R/summary.R @@ -1,8 +1,8 @@ # -summary.ModStanR <- function(object, ...) { +summary.outstandR <- function(object, ...) { ans <- NULL - class(ans) <- "summary.ModStanR" + class(ans) <- "summary.outstandR" ans } diff --git a/README.md b/README.md index 0fd1715..01390f8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ -[![R-CMD-check](https://github.com/StatisticsHealthEconomics/ModStanR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/StatisticsHealthEconomics/ModStanR/actions/workflows/R-CMD-check.yaml) +[![R-CMD-check](https://github.com/StatisticsHealthEconomics/outstandR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/StatisticsHealthEconomics/outstandR/actions/workflows/R-CMD-check.yaml) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) @@ -24,7 +24,7 @@ and Install the [development version from GitHub](https://github.com/StatisticsHealthEconomics/) using `remotes`: ```r -remotes::install_github("StatisticsHealthEconomics/ModStanR") +remotes::install_github("StatisticsHealthEconomics/outstandR") ``` ## License @@ -33,6 +33,6 @@ remotes::install_github("StatisticsHealthEconomics/ModStanR") ## Contributing Please submit contributions through `Pull Requests`, following the [contributing guidelines](https://github.com/n8thangreen/BCEA/blob/dev/CONTRIBUTING.md). To report issues and/or seek support, please file a new ticket in the -[issue](https://github.com/StatisticsHealthEconomics/ModStanR/issues) tracker. +[issue](https://github.com/StatisticsHealthEconomics/outstandR/issues) tracker. Please note that this project is released with a [Contributor Code of Conduct](https://github.com/n8thangreen/BCEA/blob/dev/CONDUCT.md). By participating in this project you agree to abide by its terms. diff --git a/_pkgdown.yml b/_pkgdown.yml index 3c9a598..dc67e4f 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,4 @@ -url: https://StatisticsHealthEconomics.github.io/ModStanR/ +url: https://StatisticsHealthEconomics.github.io/outstandR/ news: cran_dates: false @@ -18,8 +18,8 @@ reference: - title: "Main" desc: "Main analysis functions." contents: - # - ModStanR-package - - starts_with("ModStanR") + # - outstandR-package + - starts_with("outstandR") - strategy - title: "Constituent statistics" desc: "Helper functions used by the main functions." @@ -34,4 +34,4 @@ reference: contents: - AC_IPD - BC_ALD - \ No newline at end of file + diff --git a/doc/Basic_example.R b/doc/Basic_example.R index 1a69a84..c9848cc 100644 --- a/doc/Basic_example.R +++ b/doc/Basic_example.R @@ -8,7 +8,7 @@ knitr::opts_chunk$set( library(boot) # non-parametric bootstrap in MAIC and ML G-computation library(copula) # simulating BC covariates from Gaussian copula library(rstanarm) # fit outcome regression, draw outcomes in Bayesian G-computation -library(ModStanR) +library(outstandR) ## ----load-data---------------------------------------------------------------- set.seed(555) @@ -25,20 +25,20 @@ BC.ALD ## ----------------------------------------------------------------------------- lin_form <- as.formula("y ~ X3 + X4 + trt*X1 + trt*X2") -## ----ModStanR_maic------------------------------------------------------------ -ModStanR_maic <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_maic(formula = lin_form)) +## ----outstandR_maic------------------------------------------------------------ +outstandR_maic <- outstandR(AC.IPD, BC.ALD, strategy = strategy_maic(formula = lin_form)) -## ----ModStanR_maic-print------------------------------------------------------ -ModStanR_maic +## ----outstandR_maic-print------------------------------------------------------ +outstandR_maic -## ----ModStanR_stc------------------------------------------------------------- -ModStanR_stc <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_stc(formula = lin_form)) -ModStanR_stc +## ----outstandR_stc------------------------------------------------------------- +outstandR_stc <- outstandR(AC.IPD, BC.ALD, strategy = strategy_stc(formula = lin_form)) +outstandR_stc -## ----ModStanR_gcomp_ml-------------------------------------------------------- -# ModStanR_gcomp_ml <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_gcomp_ml(formula = lin_form)) +## ----outstandR_gcomp_ml-------------------------------------------------------- +# outstandR_gcomp_ml <- outstandR(AC.IPD, BC.ALD, strategy = strategy_gcomp_ml(formula = lin_form)) -## ----ModStanR_gcomp_stan------------------------------------------------------ -ModStanR_gcomp_stan <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_gcomp_stan(formula = lin_form)) -ModStanR_gcomp_stan +## ----outstandR_gcomp_stan------------------------------------------------------ +outstandR_gcomp_stan <- outstandR(AC.IPD, BC.ALD, strategy = strategy_gcomp_stan(formula = lin_form)) +outstandR_gcomp_stan diff --git a/doc/Basic_example.Rmd b/doc/Basic_example.Rmd index 978c82c..3fca391 100644 --- a/doc/Basic_example.Rmd +++ b/doc/Basic_example.Rmd @@ -41,7 +41,7 @@ First, let us load necessary packages. library(boot) # non-parametric bootstrap in MAIC and ML G-computation library(copula) # simulating BC covariates from Gaussian copula library(rstanarm) # fit outcome regression, draw outcomes in Bayesian G-computation -library(ModStanR) +library(outstandR) ``` ### Data @@ -110,10 +110,10 @@ where $\bar{C}$ is the compliment of $C$ so e.g. $n_{\bar{C}} = N_C - n_c$. ## Model fitting in R -The `{ModStanR}` package has been written to be easy to use and essential consists of a single function, `ModStanR()`. -This can be used to run all of the different types of model, which we will call _strategies_. The first two arguments of `ModStanR()` are the individual and aggregate-level data, respectively. +The `{outstandR}` package has been written to be easy to use and essential consists of a single function, `outstandR()`. +This can be used to run all of the different types of model, which we will call _strategies_. The first two arguments of `outstandR()` are the individual and aggregate-level data, respectively. -A `strategy` argument of `ModStanR` takes functions called `strategy_*()`, where the wildcard `*` is replaced by the name of the particular method required, e.g. `strategy_maic()` for MAIC. Each specific example is provided below. +A `strategy` argument of `outstandR` takes functions called `strategy_*()`, where the wildcard `*` is replaced by the name of the particular method required, e.g. `strategy_maic()` for MAIC. Each specific example is provided below. ### MAIC @@ -133,20 +133,20 @@ lin_form <- as.formula("y ~ X3 + X4 + trt*X1 + trt*X2") ``` -```{r ModStanR_maic} -ModStanR_maic <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_maic(formula = lin_form)) +```{r outstandR_maic} +outstandR_maic <- outstandR(AC.IPD, BC.ALD, strategy = strategy_maic(formula = lin_form)) ``` -The returned object is of class `ModStanR`. +The returned object is of class `outstandR`. -```{r ModStanR_maic-print} -ModStanR_maic +```{r outstandR_maic-print} +outstandR_maic ``` We see that this is a list object with 3 parts, each containing statistics between each pair of treatments. These are the mean contrasts, variances and confidence intervals (CI), respectively. -The default CI is for 95% but can be altered in `ModStanR` with the `CI` argument. +The default CI is for 95% but can be altered in `outstandR` with the `CI` argument. ### STC @@ -166,11 +166,11 @@ As already mentioned, running the STC analysis is almost identical to the previo $$ y = X_3 + X_4 + \beta_t(X_1 - \bar{X_1}) + \beta_t(X_2 - \bar{X_2}) $$ -However, `ModStanR()` knows how to handle this so we can simply pass the same (uncentred) formula as before. +However, `outstandR()` knows how to handle this so we can simply pass the same (uncentred) formula as before. -```{r ModStanR_stc} -ModStanR_stc <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_stc(formula = lin_form)) -ModStanR_stc +```{r outstandR_stc} +outstandR_stc <- outstandR(AC.IPD, BC.ALD, strategy = strategy_stc(formula = lin_form)) +outstandR_stc ``` For the last two approaches, we perform G-computation firstly with a frequentist MLE approach and then a Bayesian approach. @@ -199,8 +199,8 @@ $$ $$ -```{r ModStanR_gcomp_ml} -# ModStanR_gcomp_ml <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_gcomp_ml(formula = lin_form)) +```{r outstandR_gcomp_ml} +# outstandR_gcomp_ml <- outstandR(AC.IPD, BC.ALD, strategy = strategy_gcomp_ml(formula = lin_form)) ``` @@ -223,8 +223,8 @@ The average, variance and interval estimates of the marginal treatment effect ca We can draw a vector of size $N^*$ of predicted outcomes $y^*_z$ under each set intervention $z^*$ from its posterior predictive distribution under the specific treatment. -```{r ModStanR_gcomp_stan} -ModStanR_gcomp_stan <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_gcomp_stan(formula = lin_form)) -ModStanR_gcomp_stan +```{r outstandR_gcomp_stan} +outstandR_gcomp_stan <- outstandR(AC.IPD, BC.ALD, strategy = strategy_gcomp_stan(formula = lin_form)) +outstandR_gcomp_stan ``` diff --git a/doc/Basic_example.html b/doc/Basic_example.html index 3da2547..60a4f47 100644 --- a/doc/Basic_example.html +++ b/doc/Basic_example.html @@ -399,7 +399,7 @@
library(boot) # non-parametric bootstrap in MAIC and ML G-computation
library(copula) # simulating BC covariates from Gaussian copula
library(rstanarm) # fit outcome regression, draw outcomes in Bayesian G-computation
-library(ModStanR)
Next, we load the data to use in the analysis. The data comes from a @@ -480,13 +480,13 @@
The {ModStanR}
package has been written to be easy to
+
The {outstandR}
package has been written to be easy to
use and essential consists of a single function,
-ModStanR()
. This can be used to run all of the different
+outstandR()
. This can be used to run all of the different
types of model, which we will call strategies. The first two
-arguments of ModStanR()
are the individual and
+arguments of outstandR()
are the individual and
aggregate-level data, respectively.
A strategy
argument of ModStanR
takes
+
A strategy
argument of outstandR
takes
functions called strategy_*()
, where the wildcard
*
is replaced by the name of the particular method
required, e.g. strategy_maic()
for MAIC. Each specific
@@ -507,10 +507,10 @@
formula
object passed as an argument to the strategy
function.
-
-The returned object is of class ModStanR
.
The returned object is of class outstandR
.
ModStanR_maic
+outstandR_maic
#> $contrasts
#> $contrasts$AB
#> [1] 0.5008915
@@ -549,11 +549,11 @@ MAIC
#> attr(,"CI")
#> [1] 0.95
#> attr(,"class")
-#> [1] "ModStanR" "list"
+#> [1] "outstandR" "list"
We see that this is a list object with 3 parts, each containing
statistics between each pair of treatments. These are the mean
contrasts, variances and confidence intervals (CI), respectively. The
-default CI is for 95% but can be altered in ModStanR
with
+default CI is for 95% but can be altered in outstandR
with
the CI
argument.
\[
y = X_3 + X_4 + \beta_t(X_1 - \bar{X_1}) + \beta_t(X_2 - \bar{X_2})
-\] However, ModStanR()
knows how to handle this so
+\] However, outstandR()
knows how to handle this so
we can simply pass the same (uncentred) formula as before.
ModStanR_stc <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_stc(formula = lin_form))
-ModStanR_stc
+outstandR_stc <- outstandR(AC.IPD, BC.ALD, strategy = strategy_stc(formula = lin_form))
+outstandR_stc
#> $contrasts
#> $contrasts$AB
#> trt
@@ -619,7 +619,7 @@ STC
#> attr(,"CI")
#> [1] 0.95
#> attr(,"class")
-#> [1] "ModStanR" "list"
+#> [1] "outstandR" "list"
For the last two approaches, we perform G-computation firstly with a frequentist MLE approach and then a Bayesian approach.
\[ \hat{\Delta}^{(2)}_{10} = g(\hat{\mu}_1) - g(\hat{\mu}_0) \]
- +ModStanR_gcomp_stan <- ModStanR(AC.IPD, BC.ALD, strategy = strategy_gcomp_stan(formula = lin_form))
+outstandR_gcomp_stan <- outstandR(AC.IPD, BC.ALD, strategy = strategy_gcomp_stan(formula = lin_form))
#>
#> SAMPLING FOR MODEL 'bernoulli' NOW (CHAIN 1).
#> Chain 1:
@@ -745,7 +745,7 @@ Bayesian G-computation with MCMC
#> Chain 2: 0.746 seconds (Sampling)
#> Chain 2: 1.422 seconds (Total)
#> Chain 2:
-