Skip to content

Commit de48376

Browse files
format
1 parent 9ace4bc commit de48376

File tree

7 files changed

+53
-14
lines changed

7 files changed

+53
-14
lines changed

R/bal_prognostic_score.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,15 @@ bal_prognostic_fit_model <- function(
280280
data = control_data,
281281
family = family
282282
)
283-
283+
284284
# Add weights if provided
285285
if (!is.null(.weights)) {
286286
glm_args$weights <- .weights
287287
}
288-
288+
289289
# Add any additional arguments
290290
glm_args <- c(glm_args, list(...))
291-
291+
292292
# Use do.call to bypass non-standard evaluation
293293
do.call(stats::glm, glm_args)
294294
},

R/geom_qq2.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#' @inheritParams ggplot2_params
3030
#' @param quantiles Numeric vector of quantiles to compute. Default is
3131
#' `seq(0.01, 0.99, 0.01)` for 99 quantiles.
32-
#' @param .reference_level The reference treatment level to use for comparisons.
33-
#' If `NULL` (default), uses the first level for factors or the minimum value
32+
#' @param .reference_level The reference treatment level to use for comparisons.
33+
#' If `NULL` (default), uses the first level for factors or the minimum value
3434
#' for numeric variables.
3535
#'
3636
#' @return A ggplot2 layer.

tests/testthat/test-check_ess.R

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,24 @@ test_that("check_ess works with binary groups", {
4444
})
4545

4646
test_that("check_ess works with categorical groups", {
47-
result <- check_ess(nhefs_weights, .weights = w_cat_ate, .group = alcoholfreq_cat)
47+
result <- check_ess(
48+
nhefs_weights,
49+
.weights = w_cat_ate,
50+
.group = alcoholfreq_cat
51+
)
4852

4953
expect_s3_class(result, "tbl_df")
5054
expect_true("group" %in% names(result))
5155
expect_true(length(unique(result$group)) > 2)
5256
})
5357

5458
test_that("check_ess works with continuous groups", {
55-
result <- check_ess(nhefs_weights, .weights = w_ate, .group = age, n_tiles = 4)
59+
result <- check_ess(
60+
nhefs_weights,
61+
.weights = w_ate,
62+
.group = age,
63+
n_tiles = 4
64+
)
5665

5766
expect_s3_class(result, "tbl_df")
5867
expect_true("group" %in% names(result))
@@ -123,7 +132,11 @@ test_that("ESS calculation is correct", {
123132
wts2 = c(4, 0, 0, 0) # All weight on one obs -> ESS = 1
124133
)
125134

126-
result <- check_ess(test_df, .weights = c(wts, wts2), include_observed = FALSE)
135+
result <- check_ess(
136+
test_df,
137+
.weights = c(wts, wts2),
138+
include_observed = FALSE
139+
)
127140

128141
expect_equal(result$ess[result$method == "wts"], 4)
129142
expect_equal(result$ess[result$method == "wts2"], 1)

tests/testthat/test-compute_balance.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ test_that("bal_smd handles missing values", {
114114
w_na <- data$w_uniform
115115

116116
# Should return NA when na.rm = FALSE
117-
expect_true(is.na(bal_smd(.covariate = x_na, .exposure = g_na, na.rm = FALSE)))
117+
expect_true(is.na(bal_smd(
118+
.covariate = x_na,
119+
.exposure = g_na,
120+
na.rm = FALSE
121+
)))
118122

119123
# Should work when na.rm = TRUE
120124
smd_na.rm <- bal_smd(.covariate = x_na, .exposure = g_na, na.rm = TRUE)
@@ -612,7 +616,10 @@ test_that("functions handle unbalanced groups", {
612616

613617
# Test with very unbalanced groups
614618
expect_no_error({
615-
smd_unbal <- bal_smd(.covariate = data$x_cont, .exposure = data$g_unbalanced)
619+
smd_unbal <- bal_smd(
620+
.covariate = data$x_cont,
621+
.exposure = data$g_unbalanced
622+
)
616623
vr_unbal <- bal_vr(
617624
.covariate = data$x_cont,
618625
.exposure = data$g_unbalanced

tests/testthat/test-geom_roc.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ test_that("geom_roc and stat_roc work", {
3636
expect_no_error(ggplot_build(p_stat))
3737

3838
# Test with .focal_level parameter
39-
p_treatment <- ggplot(nhefs_weights, aes(estimate = .fitted, exposure = qsmk)) +
39+
p_treatment <- ggplot(
40+
nhefs_weights,
41+
aes(estimate = .fitted, exposure = qsmk)
42+
) +
4043
geom_roc(.focal_level = "1")
4144
expect_s3_class(p_treatment, "gg")
4245
expect_no_error(ggplot_build(p_treatment))

tests/testthat/test-plot_ess.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ test_that("plot_ess includes reference line", {
5959

6060
test_that("plot_ess labels work correctly", {
6161
p_with_labels <- plot_ess(nhefs_weights, .weights = w_ate, show_labels = TRUE)
62-
p_without_labels <- plot_ess(nhefs_weights, .weights = w_ate, show_labels = FALSE)
62+
p_without_labels <- plot_ess(
63+
nhefs_weights,
64+
.weights = w_ate,
65+
show_labels = FALSE
66+
)
6367

6468
# Check for text layer
6569
text_layer_with <- sapply(

tests/testthat/test-plot_qq.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ test_that("plot_qq works with multiple weights", {
3131
})
3232

3333
test_that("plot_qq works without observed", {
34-
p <- plot_qq(nhefs_weights, age, qsmk, .weights = w_ate, include_observed = FALSE)
34+
p <- plot_qq(
35+
nhefs_weights,
36+
age,
37+
qsmk,
38+
.weights = w_ate,
39+
include_observed = FALSE
40+
)
3541

3642
expect_s3_class(p, "ggplot")
3743

@@ -137,7 +143,13 @@ test_that("plot_qq visual regression tests", {
137143
# Without observed
138144
expect_doppelganger(
139145
"qq plot no observed",
140-
plot_qq(nhefs_weights, age, qsmk, .weights = w_ate, include_observed = FALSE)
146+
plot_qq(
147+
nhefs_weights,
148+
age,
149+
qsmk,
150+
.weights = w_ate,
151+
include_observed = FALSE
152+
)
141153
)
142154

143155
# With propensity score

0 commit comments

Comments
 (0)