Skip to content

Commit

Permalink
moved some helper functions to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
n8thangreen committed Dec 15, 2023
1 parent b9de6f3 commit 010d28f
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 36 deletions.
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ S3method(IPD_stats,maic)
S3method(IPD_stats,stc)
export(ALD_stats)
export(IPD_stats)
export(gcomp_ml.boot)
export(gcomp_ml_log_odds_ratio)
export(gcomp_stan)
export(marginal_treatment_effect)
export(marginal_variance)
export(mimR)
Expand Down
31 changes: 15 additions & 16 deletions R/marginal_stats.R → R/ALD_stats.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@

#' Aggregate-level data mean and variance statistics
#'
#' @param ald Aggregate-level trial data
#' @param treatments Treatment labels list; default `B`, `C`
#'
#' @return List of marginal treatment effect mean and variance
#' @seealso [marginal_treatment_effect()], [marginal_variance()]
#' @export
#'
ALD_stats <- function(ald, treatments = list("B", "C")) {
list(mean = marginal_treatment_effect(ald, treatments),
var = marginal_variance(ald, treatments))
}


#' Marginal effect variance using the delta method
#'
#' Calculate
Expand Down Expand Up @@ -67,19 +82,3 @@ trial_treatment_effect <- function(ald, tid) {
var_string <- glue::glue("log(ald$y.{tid}.sum*(ald$N.{tid} - ald$y.{tid}.sum))")
eval(parse(text = var_string))
}


#' Aggregate-level data mean and variance statistics
#'
#' @param ald Aggregate-level trial data
#' @param treatments Treatment labels list; default `B`, `C`
#'
#' @return List of marginal treatment effect mean and variance
#' @seealso [marginal_treatment_effect()], [marginal_variance()]
#' @export
#'
ALD_stats <- function(ald, treatments = list("B", "C")) {
list(mean = marginal_treatment_effect(ald, treatments),
var = marginal_variance(ald, treatments))
}

4 changes: 2 additions & 2 deletions R/gcomp_ml.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @return Mean difference in expected log-odds
#' @seealso [strategy_gcomp_ml()], [gcomp_ml_log_odds_ratio()]
#' @export
#' @keywords internal
#'
gcomp_ml.boot <- function(data, indices,
formula = as.formula("y ~ X3 + X4 + trt*X1 + trt*X2")) {
Expand All @@ -31,7 +31,7 @@ gcomp_ml.boot <- function(data, indices,
#' @return Difference of log-odds
#' @seealso [strategy_gcomp_ml()], [gcomp_ml.boot()]
#' @importFrom copula normalCopula mvdc rMvdc
#' @export
#' @keywords internal
#'
gcomp_ml_log_odds_ratio <- function(formula, dat) {
browser() ## what is type of data?...
Expand Down
2 changes: 1 addition & 1 deletion R/gcomp_stan.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @return A list of \eqn{y^*_A} and \eqn{y^*_C} posterior predictions
#' @importFrom copula normalCopula mvdc rMvdc
#' @importFrom rstanarm stan_glm posterior_predict
#' @export
#' @keywords internal
#'
gcomp_stan <- function(formula = as.formula("y ~ X3 + X4 + trt*X1 + trt*X2"),
ipd, ald) {
Expand Down
2 changes: 2 additions & 0 deletions R/maic.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#'
#' @references
#' \insertRef{Signorovitch2010}{mimR}
#' @keywords internal
#'
maic_weights <- function(X_EM) {
X_EM <- as.matrix(X_EM)
Expand Down Expand Up @@ -43,6 +44,7 @@ maic_weights <- function(X_EM) {
#' @template args-ald
#' @return Fitted treatment coefficient is marginal effect for _A_ vs _C_
#' @seealso [IPD_stats.maic()]
#' @keywords internal
#'
maic.boot <- function(ipd, indices, formula, ald) {

Expand Down
8 changes: 8 additions & 0 deletions R/summary.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#
summary.mimR <- function(object, ...) {

ans <- NULL
class(ans) <- "summary.mimR"
ans
}
13 changes: 4 additions & 9 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@ navbar:

reference:
- title: "Main"
desc: "Main functions"
desc: "Main analysis functions."
contents:
# - mimR-package
- starts_with("mimR")
- title: "Helpers"
desc: "Helper functions"
- strategy
- title: "Constituent statistics"
desc: "Helper functions used by the main functions."
contents:
- ALD_stats
- gcomp_ml.boot
- gcomp_ml_log_odds_ratio
- gcomp_stan
- IPD_stats
- maic.boot
- maic_weights
- marginal_treatment_effect
- marginal_variance
- strategy_maic
- trial_treatment_effect
- trial_variance

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

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

1 change: 1 addition & 0 deletions man/gcomp_ml.boot.Rd

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

1 change: 1 addition & 0 deletions man/gcomp_ml_log_odds_ratio.Rd

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

1 change: 1 addition & 0 deletions man/gcomp_stan.Rd

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

1 change: 1 addition & 0 deletions man/maic.boot.Rd

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

1 change: 1 addition & 0 deletions man/maic_weights.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/marginal_treatment_effect.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/marginal_variance.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/trial_treatment_effect.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/trial_variance.Rd

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

0 comments on commit 010d28f

Please sign in to comment.