Skip to content

Commit

Permalink
changed api for pscore specification
Browse files Browse the repository at this point in the history
  • Loading branch information
gperrett committed Apr 9, 2024
1 parent 5574a33 commit ab52feb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions thinkCausal/R/fct_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
)
}
Expand Down
2 changes: 1 addition & 1 deletion thinkCausal/R/mod_analysis_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion thinkCausal/tests/testthat/test-fct_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ab52feb

Please sign in to comment.