From ab52feb0865794929a8e463436a5271e14404567 Mon Sep 17 00:00:00 2001 From: George Perrett Date: Tue, 9 Apr 2024 13:37:35 -0400 Subject: [PATCH] changed api for pscore specification --- thinkCausal/R/fct_model.R | 6 +++--- thinkCausal/R/mod_analysis_model.R | 2 +- thinkCausal/tests/testthat/test-fct_model.R | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/thinkCausal/R/fct_model.R b/thinkCausal/R/fct_model.R index 4ddd7e8..bfbd30a 100644 --- a/thinkCausal/R/fct_model.R +++ b/thinkCausal/R/fct_model.R @@ -4,10 +4,10 @@ #' @param ran.eff if not "None", then the name of the column within .data that represents the random effects #' @param .estimand the causal estimand. See bartCause::bartc #' @param .weights name of the variable corresponding to a vector of survey weights -#' @param design a length 1 character vector indicating whether the study is a completely randomized study, block randomized study or observational study +#' @param random a logical TRUE is completely randomized design FALSE otherwise #' @return an object of class "bartcFit" #' @noRd -fit_bart <- function(.data, .weights, ran_eff, .estimand, design){ +fit_bart <- function(.data, .weights, ran_eff, .estimand, random){ ind <- max(3, 3 + length(.weights) + length(ran_eff)) if(rlang::is_null(.weights)){ tryCatch({ @@ -17,7 +17,7 @@ fit_bart <- function(.data, .weights, ran_eff, .estimand, design){ treatment = .data[, 1], confounders = clean_confounders_for_bart(.data[, ind:length(.data)]), estimand = .estimand, - method.trt = ifelse(design == 'Completely Randomized Experement', 'none', 'bart'), + method.trt = ifelse(random, 'none', 'bart'), seed = 2 ) } diff --git a/thinkCausal/R/mod_analysis_model.R b/thinkCausal/R/mod_analysis_model.R index 780a63f..856bc33 100644 --- a/thinkCausal/R/mod_analysis_model.R +++ b/thinkCausal/R/mod_analysis_model.R @@ -232,7 +232,7 @@ mod_analysis_model_server <- function(id, store){ .weights = store$column_assignments$weight, ran_eff = store$column_assignments$ran_eff, .estimand = base::tolower(input$analysis_model_estimand), - design = store$analysis_select_design + random = store$analysis_select_design == 'Completely Randomized Experement' ) store$analysis$model$model <- bart_model diff --git a/thinkCausal/tests/testthat/test-fct_model.R b/thinkCausal/tests/testthat/test-fct_model.R index a151b34..e84303d 100644 --- a/thinkCausal/tests/testthat/test-fct_model.R +++ b/thinkCausal/tests/testthat/test-fct_model.R @@ -10,7 +10,8 @@ model_results <- fit_bart( .data = .data, ran_eff = NULL, .weights = NULL, - .estimand = "ate" + .estimand = "ate", + rct = T ) model_validation <- validate_model_fit_(model_results)