Skip to content

Commit

Permalink
fixing conf_int
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Sep 9, 2022
1 parent 7dcf8f4 commit 17fad84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions R/estimate_proportion.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ prop_strat_wilson <- function(rsp,
# Return values
if (do_iter) {
list(
conf.int = c(
conf_int = c(
lower = lower,
upper = upper
),
weights = weights_new
)
} else {
list(
conf.int = c(
conf_int = c(
lower = lower,
upper = upper
)
Expand Down Expand Up @@ -440,11 +440,11 @@ s_proportion <- function(df,
"strat_wilson" = prop_strat_wilson(rsp, strata, weights,
conf_level, max_iterations,
correct = FALSE
)$conf.int,
)$conf_int,
"strat_wilsonc" = prop_strat_wilson(rsp, strata, weights,
conf_level, max_iterations,
correct = TRUE
)$conf.int,
)$conf_int,
"wald" = prop_wald(rsp, conf_level),
"waldcc" = prop_wald(rsp, conf_level, correct = TRUE),
"agresti-coull" = prop_agresti_coull(rsp, conf_level),
Expand Down
8 changes: 4 additions & 4 deletions R/prop_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ prop_diff_strat_nc <- function(rsp,

ci_ref <- strat_wilson_by_grp[[1]]
ci_trt <- strat_wilson_by_grp[[2]]
l_ref <- as.numeric(ci_ref$conf.int[1])
u_ref <- as.numeric(ci_ref$conf.int[2])
l_trt <- as.numeric(ci_trt$conf.int[1])
u_trt <- as.numeric(ci_trt$conf.int[2])
l_ref <- as.numeric(ci_ref$conf_int[1])
u_ref <- as.numeric(ci_ref$conf_int[2])
l_trt <- as.numeric(ci_trt$conf_int[1])
u_trt <- as.numeric(ci_trt$conf_int[2])

# Estimating the diff and n_ref, n2 (it allows different weights to be used)
t_tbl <- table(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-estimate_proportion.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ testthat::test_that("prop_strat_wilson returns right result", {
)

expected <- list(
conf.int = c(lower = 0.4072891, upper = 0.5647887),
conf_int = c(lower = 0.4072891, upper = 0.5647887),
weights = c(0.2074199, 0.1776464, 0.1915610, 0.1604678, 0.1351096, 0.1277952)
)
names(expected$weights) <- colnames(table_strata)
Expand All @@ -126,7 +126,7 @@ testthat::test_that("prop_strat_wilson returns right result with inserted weight
n_ws <- ncol(table_strata) # Number of weights

# Test without estimating weights (all equal here)
expected <- list(conf.int = c(lower = 0.4190436, upper = 0.5789733))
expected <- list(conf_int = c(lower = 0.4190436, upper = 0.5789733))
result <- prop_strat_wilson(
rsp = rsp, strata = strata,
weights = rep(1 / n_ws, n_ws), # Not automatic setting of weights
Expand Down

0 comments on commit 17fad84

Please sign in to comment.