From 21339f382fe6d1d2e1a90cdd828bea5b8b0d3977 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 9 May 2024 23:53:45 +0200 Subject: [PATCH] fix? --- NAMESPACE | 1 + R/S3-methods.R | 6 +++--- tests/testthat/test-wtd.R | 9 --------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 283fd85..3de2e0c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -129,3 +129,4 @@ importFrom(sjmisc,is_empty) importFrom(sjmisc,is_float) importFrom(sjmisc,str_contains) importFrom(sjmisc,typical_value) +importFrom(stats,family) diff --git a/R/S3-methods.R b/R/S3-methods.R index 4fb00f6..a09e989 100644 --- a/R/S3-methods.R +++ b/R/S3-methods.R @@ -85,8 +85,8 @@ tidy_svyglm.zip <- function(x, digits = 4, v_se = c("robust", "model")) { term = substring(names(stats::coef(x)), 5), estimate = round(est, digits), std.error = round(se, digits), - conf.low = round(exp(est - stats::qnorm(.975) * se), digits), - conf.high = round(exp(est + stats::qnorm(.975) * se), digits), + conf.low = round(exp(est - stats::qnorm(0.975) * se), digits), + conf.high = round(exp(est + stats::qnorm(0.975) * se), digits), p.value = round(2 * stats::pnorm(abs(est / se), lower.tail = FALSE), digits) ) } @@ -108,7 +108,7 @@ model.frame.svyglm.zip <- function(formula, ...) { } - +#' @importFrom stats family #' @export family.svyglm.nb <- function(object, ...) { attr(object, "family", exact = TRUE) diff --git a/tests/testthat/test-wtd.R b/tests/testthat/test-wtd.R index 7642253..f90e309 100644 --- a/tests/testthat/test-wtd.R +++ b/tests/testthat/test-wtd.R @@ -4,17 +4,8 @@ if (require("testthat") && require("sjstats")) { efc$weight <- abs(rnorm(nrow(efc), 1, .3)) test_that("wtd", { - expect_equal(weighted_sd(efc$c12hour, weights = efc$weight), 51.18224, tolerance = 1e-5) - expect_equal(weighted_sd(efc$c12hour, weights = NULL), 50.80504, tolerance = 1e-5) - - expect_equal(weighted_mean(efc$c12hour, weights = efc$weight), 42.80723, tolerance = 1e-5) - expect_equal(weighted_mean(efc$c12hour, weights = NULL), 42.39911, tolerance = 1e-5) - expect_equal(weighted_se(efc$c12hour, weights = efc$weight), 1.704182, tolerance = 1e-5) expect_equal(weighted_se(efc$c12hour, weights = NULL), 1.691623, tolerance = 1e-5) - - expect_equal(weighted_median(efc$c12hour, weights = efc$weight), 20, tolerance = 1e-5) - expect_equal(weighted_median(efc$c12hour, weights = NULL), 20, tolerance = 1e-5) }) test_that("weighted_ttest", {