Skip to content

Commit

Permalink
add weighted two arm data (#118)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people committed Jul 12, 2024
1 parent 7d9cc65 commit 24e4a02
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1.9000
RoxygenNote: 7.3.2
34 changes: 34 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,40 @@
#' @family anchored datasets
"centered_ipd_twt"

#' Weighted object for two arm trial data
#' @format A `maicplus_estimate_weights` object created by [estimate_weights()] containing
#' \describe{
#' \item{data}{patient level data with weights}
#' \item{centered_colnames}{Columns used in MAIC}
#' \item{nr_missing}{Number of observations with missing data}
#' \item{ess}{Expected sample size}
#' \item{opt}{Information from `optim` from weight calculation}
#' \item{boot}{Parameters and bootstrap sample weights for the 100 samples}
#' }
#' @description
#' The weighted patient data for a two arm trial generated from the centered patient data ([centered_ipd_twt]).
#' It has weights calculated for 100 bootstrap samples.
#'
#' The object is generated using the following code:
#' ```
#' estimate_weights(
#' data = centered_ipd_twt,
#' centered_colnames = c(
#' "AGE_CENTERED",
#' "AGE_MEDIAN_CENTERED",
#' "AGE_SQUARED_CENTERED",
#' "SEX_MALE_CENTERED",
#' "ECOG0_CENTERED",
#' "SMOKE_CENTERED"
#' ),
#' n_boot_iteration = 100
#' )
#' ```
#'
#' @keywords dataset
#' @family anchored datasets
"weighted_twt"


if (FALSE) {
make_roxygen_data <- function(df) {
Expand Down
2 changes: 1 addition & 1 deletion R/plot_km2.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ basic_kmplot2 <- function(kmlist,
ylab = endpoint_name,
legend.title = "Treatment",
legend = c(0.85, 0.82),
title = paste0(main_title, "\nEndpoint:", endpoint_name),
title = paste0(main_title, "\nEndpoint: ", endpoint_name),
legend.labs = kmlist_name,
tables.theme = survminer::theme_cleantable(),
ggtheme = ggplot2::theme_classic(base_size = 10),
Expand Down
5 changes: 4 additions & 1 deletion data-raw/dummy_anchored.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ agd <- process_agd(agd)
adsl_twt <- dummize_ipd(adsl_twt, dummize_cols = c("SEX"), dummize_ref_level = c("Female"))
centered_ipd_twt <- center_ipd(ipd = adsl_twt, agd = agd)

centered_colnames <- paste0(c("AGE", "AGE_MEDIAN", "AGE_SQUARED", "SEX_MALE", "ECOG0", "SMOKE"), "_CENTERED")
weighted_twt <- estimate_weights(data = centered_ipd_twt, centered_colnames = centered_colnames, n_boot_iteration = 100)


### Output
usethis::use_data(adsl_twt, adtte_twt, pseudo_ipd_twt, centered_ipd_twt, adrs_twt,
usethis::use_data(adsl_twt, adtte_twt, pseudo_ipd_twt, centered_ipd_twt, adrs_twt, weighted_twt,
internal = FALSE, overwrite = TRUE
)
Binary file modified data/adrs_twt.rda
Binary file not shown.
Binary file modified data/adsl_twt.rda
Binary file not shown.
Binary file modified data/adtte_twt.rda
Binary file not shown.
Binary file modified data/centered_ipd_twt.rda
Binary file not shown.
Binary file modified data/pseudo_ipd_twt.rda
Binary file not shown.
Binary file added data/weighted_twt.rda
Binary file not shown.
3 changes: 2 additions & 1 deletion man/adsl_twt.Rd

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

3 changes: 2 additions & 1 deletion man/adtte_twt.Rd

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

3 changes: 2 additions & 1 deletion man/agd.Rd

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

3 changes: 2 additions & 1 deletion man/centered_ipd_twt.Rd

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

3 changes: 2 additions & 1 deletion man/pseudo_ipd_twt.Rd

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

50 changes: 50 additions & 0 deletions man/weighted_twt.Rd

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

0 comments on commit 24e4a02

Please sign in to comment.