Skip to content

Commit

Permalink
issue #1272
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Dec 11, 2024
1 parent 7129130 commit c828f45
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
8 changes: 1 addition & 7 deletions R/ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ get_ci <- function(
draws = NULL,
vcov = TRUE,
null_hypothesis = 0,
p_adjust = NULL,
model = NULL,
...) {

Expand Down Expand Up @@ -61,8 +60,7 @@ get_ci <- function(
p_overwrite

ci_overwrite <- !"conf.low" %in% colnames(x) &&
"std.error" %in% colnames(x) &&
is.null(p_adjust)
"std.error" %in% colnames(x)

if (z_overwrite) {
x[["statistic"]] <- (x[["estimate"]] - null_hypothesis) / x[["std.error"]]
Expand All @@ -83,10 +81,6 @@ get_ci <- function(
x[["conf.low"]] <- x[["estimate"]] - critical * x[["std.error"]]
x[["conf.high"]] <- x[["estimate"]] + critical * x[["std.error"]]
}

if (!is.null(p_adjust) && "p.value" %in% colnames(x)) {
x$p.value <- stats::p.adjust(x$p.value, method = p_adjust)
}

# s-value
if ("p.value" %in% colnames(x)) {
Expand Down
7 changes: 0 additions & 7 deletions R/sanity.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
sanity_equivalence_p_adjust <- function(equivalence, p_adjust) {
if (!is.null(equivalence) && !is.null(p_adjust)) {
insight::format_error("The `equivalence` and `p_adjust` arguments cannot be used together.")
}
checkmate::assert_choice(p_adjust, choices = stats::p.adjust.methods, null.ok = TRUE)
}


sanity_df <- function(df, x) {
checkmate::assert(
Expand Down
3 changes: 3 additions & 0 deletions R/sanity_dots.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ sanity_dots <- function(model, calling_function = NULL, ...) {
# flexsurv
valid[["flexsurvreg"]] <- c("times", "p", "start")

# survival
valid[["survreg"]] <- c("p")

# WeightIt models
valid[["ordinal_weightit"]] <- valid[["multinom_weightit"]] <- "values"

Expand Down
5 changes: 5 additions & 0 deletions inst/tinytest/test-pkg-survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ expect_equivalent(e0$estimate, e3$estimate)



# Issue #1272
fit <- survreg(Surv(time, status) ~ ph.ecog + age + sex, lung,dist="weibull")
p1 <- avg_predictions(fit, variables = "sex", type = "quantile", p = 0.5)
p2 <- avg_predictions(fit, variables = "sex", type = "quantile", p = 0.1)
expect_true(all(p1$estimate > p2$estimate))



Expand Down

0 comments on commit c828f45

Please sign in to comment.