Skip to content

Commit

Permalink
79 add binary endpoints to wrapper anchored function (#112)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Isaac Gravestock <83659704+gravesti@users.noreply.github.com>
Co-authored-by: Isaac Gravestock <isaac.gravestock@roche.com>
  • Loading branch information
5 people authored Jul 19, 2024
1 parent 88f7c55 commit 084a0cb
Show file tree
Hide file tree
Showing 20 changed files with 508 additions and 64 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
- lubridate
- DescTools
- lmtest
- sandwich
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
Expand Down Expand Up @@ -50,6 +51,11 @@ repos:
- id: parsable-R
- id: no-browser-statement
- id: deps-in-desc
exclude: >
(?x)^(
data-raw/.*|
(.*/|)\.Rprofile
)$
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Imports:
MASS,
boot,
stringr,
lmtest
lmtest,
sandwich
Suggests:
knitr,
testthat (>= 2.0),
ggplot2,
rmarkdown,
dplyr,
sandwich,
survminer,
flexsurv,
tibble,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ import(lubridate)
import(stats)
import(stringr)
import(survival)
importFrom(boot,boot)
importFrom(boot,boot.ci)
importFrom(grDevices,col2rgb)
importFrom(grDevices,rgb)
importFrom(lmtest,coefci)
importFrom(lmtest,coeftest)
importFrom(sandwich,vcovHC)
importFrom(survival,Surv)
importFrom(survival,coxph)
importFrom(survival,survfit)
importFrom(utils,stack)
35 changes: 32 additions & 3 deletions R/bucher.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,32 @@ find_SE_from_CI <- function(CI_lower = NULL, CI_upper = NULL,

print.maicplus_bucher <- function(x, ci_digits = 2, pval_digits = 3,
exponentiate = FALSE, ...) {
output <- reformat(x, ci_digits, pval_digits,
show_pval = TRUE, exponentiate
)
print(output)
}

#' Reformat `maicplus_bucher` alike object
#'
#' @param x a list, structured like a `maicplus_bucher` object
#' @param ci_digits an integer, number of decimal places for point
#' estimate and derived confidence limits
#' @param pval_digits an integer, number of decimal places to display
#' Z-test p-value
#' @param show_pval a logical value, default is TRUE. If FALSE, p-value will not
#' be output as the second element of the character vector
#' @param exponentiate whether the treatment effect and confidence
#' interval should be exponentiated. This applies to relative
#' treatment effects. Default is set to false.


reformat <- function(x, ci_digits = 2, pval_digits = 3,
show_pval = TRUE, exponentiate = FALSE) {
transform_this <- function(x) {
ifelse(exponentiate, exp(x), x)
}

a <- format(round(transform_this(x$est), ci_digits),
nsmall = ci_digits
)
Expand All @@ -156,7 +179,13 @@ print.maicplus_bucher <- function(x, ci_digits = 2, pval_digits = 3,
format(disp_pval, nsmall = pval_digits)
)

output <- c(res, disp_pval)
names(output) <- c("result", "pvalue")
print(output)
if (show_pval) {
output <- c(res, disp_pval)
names(output) <- c("result", "pvalue")
} else {
output <- res
names(output) <- "result"
}

output
}
Loading

0 comments on commit 084a0cb

Please sign in to comment.