Skip to content

Commit

Permalink
Add CI of Response Rate and Odds Ratio (#9)
Browse files Browse the repository at this point in the history
* add s_propci function for proportion calculation with DescTools

* Add s_odds_ratio for odds ratio calculation and tests

* add print method for prop_ci and or_ci classes
  • Loading branch information
kaigu1990 authored Feb 2, 2024
1 parent 5dcbd13 commit 93904a0
Show file tree
Hide file tree
Showing 12 changed files with 925 additions and 13 deletions.
13 changes: 9 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
Package: stabiot
Type: Package
Title: Common Statistical Analysis for Clinical Trials in Biotech
Title: Common Statistical Analysis for Clinical Trials
Version: 0.0.0.9000
Authors@R: c(
person("Kai", "Gu", , "gukai1212@163.com", role = c("aut", "cre", "cph"))
)
Maintainer: Kai Gu <gukai1212@163.com>
Description: Providing common statistical analysis for oversighting process in
clinical trials of biotech, making the outputs can be compared with SAS results.
Description: Provides common statistical analysis for oversighting process in
clinical trials of biotech, makes the outputs can be compared with SAS results.
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.6)
Imports:
checkmate,
DescTools,
dplyr,
emmeans,
lifecycle,
magrittr,
purrr,
rlang,
stats,
tibble
survival,
tibble,
tidyr
Suggests:
knitr,
mmrm,
Expand Down
17 changes: 17 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# Generated by roxygen2: do not edit by hand

S3method(print,or_ci)
S3method(print,prop_ci)
S3method(print,s_lsmeans)
export("%>%")
export(h_prep_prop)
export(rrPostProb)
export(s_get_lsmeans)
export(s_odds_ratio)
export(s_propci)
import(checkmate)
importFrom(dplyr,add_count)
importFrom(dplyr,count)
importFrom(dplyr,group_by)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(rlang,sym)
importFrom(stats,as.formula)
importFrom(stats,coef)
importFrom(stats,confint)
importFrom(stats,pbeta)
importFrom(stats,rbinom)
importFrom(stats,setNames)
importFrom(survival,Surv)
importFrom(survival,coxph)
importFrom(survival,strata)
5 changes: 4 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

#' @import checkmate
#' @importFrom lifecycle deprecated
#' @importFrom stats pbeta rbinom confint
#' @importFrom stats pbeta rbinom confint as.formula setNames coef
#' @importFrom dplyr count add_count group_by
#' @importFrom rlang sym := .data
#' @importFrom survival coxph Surv strata
NULL

.onLoad <- function(libname, pkgname) {
Expand Down
41 changes: 41 additions & 0 deletions R/pkg-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,44 @@ print.s_lsmeans <- function(x, ...) {

invisible(x)
}

#' @describeIn prop_odds_ratio prints proportion and confidence interval.
#' @exportS3Method
#' @keywords internal
print.prop_ci <- function(x, ...) {
cat(sprintf("Proportion and %s confidence interval:", x$params$method))
cat("\n")
print(x$prop_est)

if (!is.null(x$params$by.level)) {
cat(sprintf("\nProportion Difference and %s confidence interval:", x$params$diff.method))
cat("\n")
print(x$prop_diff)
}

invisible(x)
}

#' @describeIn prop_odds_ratio prints odds ratio and confidence interval.
#' @exportS3Method
#' @keywords internal
print.or_ci <- function(x, ...) {
comp <- paste0(rev(x$params$by.level), collapse = "/")
cat(sprintf("Common Odds Ratio (%s) and %s confidence interval:", comp, x$params$or.method))
cat("\n")
print(x$or)

if (!is.null(x$params$strata)) {
cat(sprintf(
"\nStratified Odds Ratio (%s) using %s", comp,
ifelse(x$params$strata.method == "CMH",
"Cochran-Mantel-Haenszel Chi-Squared Test:",
"Conditional logistic regression:"
)
))
cat("\n")
print(x$strata_or)
}

invisible(x)
}
Loading

0 comments on commit 93904a0

Please sign in to comment.