Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
istallworthy authored Sep 28, 2023
2 parents dfdfa8d + 3073a44 commit eadb9e7
Show file tree
Hide file tree
Showing 21 changed files with 1,164 additions and 586 deletions.
Binary file modified .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Imports:
dplyr,
WeightIt,
marginaleffects,
stats,
Expand All @@ -38,8 +37,9 @@ Imports:
gtools,
cobalt,
stringr,
mitml,
psych
huxtable,
officer,
flextable
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Expand Down
10 changes: 1 addition & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,4 @@ export(get_reference_values)
export(make_love_plot)
export(perform_multiple_comparison_correction)
export(trimWeights)
import(ggplot2)
import(stats)
import(utils)
importFrom(WeightIt,weightitMSM)
importFrom(dplyr,"%>%")
importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(gtools,permutations)
importFrom(stringr,str_count)
importFrom(survey,svyglm)
261 changes: 162 additions & 99 deletions R/assessBalance.R

Large diffs are not rendered by default.

348 changes: 223 additions & 125 deletions R/calcBalStats.R

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions R/compareHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
#' reference = "h-h-h" )

get_reference_values <- function(d, reference) {

ref_vals <- sapply(seq_len(length(unlist(strsplit(reference, "-")))), function(x) {
d[x, unlist(strsplit(reference, "-"))[x]]
})

ref_vals
}

Expand All @@ -41,11 +43,13 @@ get_reference_values <- function(d, reference) {
#' r <- get_comparison_values(d = d,
#' comp_histories = c("h-h-h", "h-h-l"))
get_comparison_values <- function(d, comp_histories) {

comp_vals <- sapply(comp_histories, function(comp) {
sapply(seq_len(length(unlist(strsplit(comp, "-")))), function(x) {
d[x, unlist(strsplit(comp, "-"))[x]]
})
})

t(comp_vals)
}

Expand All @@ -60,6 +64,7 @@ get_comparison_values <- function(d, comp_histories) {
#' @return contrasts
#' @export
create_custom_contrasts <- function(d, reference, comp_histories, exposure, preds) {

if (is.na(reference) | is.null(comp_histories)) {
return(NULL) # Invalid input, return early
}
Expand Down Expand Up @@ -121,7 +126,8 @@ create_custom_comparisons <- function(preds, ref_vals, comp_vals, exposure) {
#' @export

add_histories <- function(p, d) {
if((is.list(p)) & length(p) == 1){

if((is.list(p)) && length(p) == 1){
history <- matrix(data = NA, nrow = nrow(p[[1]]), ncol = 1) # Get histories from the first element
p <- p[[1]]
}
Expand Down Expand Up @@ -150,6 +156,7 @@ add_histories <- function(p, d) {
}
else { #comps
for (i in seq_len(nrow(p))) {

temp <- as.character(p$term[i])
pair <- lapply(1:2, function(y) {
a <- sapply(strsplit(temp, " - "), "[", y)
Expand Down Expand Up @@ -209,7 +216,7 @@ perform_multiple_comparison_correction <- function(comps, reference, comp_histor
cat("\n")
cat(paste0("Conducting multiple comparison correction using the ", method, " method."), "\n")
cat("\n")
corr_p <-stats::p.adjust(comps$p.value, method = method)
corr_p <- stats::p.adjust(comps$p.value, method = method)
comps <- cbind(comps, p.value_corr = corr_p)
}
else {
Expand Down
Loading

0 comments on commit eadb9e7

Please sign in to comment.