diff --git a/R/plot.p_significance.R b/R/plot.p_significance.R index 445b0ded8..0bd8994ab 100644 --- a/R/plot.p_significance.R +++ b/R/plot.p_significance.R @@ -32,7 +32,7 @@ data_plot.p_significance <- function(x, data <- data[, x$Parameter, drop = FALSE] dataplot <- data.frame() for (i in names(data)) { - if (is.null(params)) { + if (is.null(params) || !all(c("Effects", "Component") %in% colnames(params))) { dataplot <- rbind( dataplot, .compute_densities_ps(data[[i]], name = i, threshold = attr(x, "threshold")) @@ -160,7 +160,7 @@ data_plot.p_significance <- function(x, # normalize range_diff <- diff(range(out$height, na.rm = TRUE), na.rm = TRUE) - out$height <- as.vector(out$height - min(out$height, na.rm = TRUE) / range_diff) + out$height <- as.vector((out$height - min(out$height, na.rm = TRUE)) / range_diff) out } diff --git a/R/utils.R b/R/utils.R index 87cbf49ac..99535ccac 100644 --- a/R/utils.R +++ b/R/utils.R @@ -42,7 +42,9 @@ # clean parameters names params <- gsub("(b_|bs_|bsp_|bcs_)(.*)", "\\2", params, perl = TRUE) - params <- gsub("^zi_(.*)", "\\1 (Zero-Inflated)", params, perl = TRUE) + params <- gsub("^cond_(.*)", "\\1 (Conditional)", params, perl = TRUE) + params <- gsub("(.*)_cond$", "\\1 (Conditional)", params, perl = TRUE) + params <- gsub("^zi_(.*)", "\\1 (Zero-Inflated)", params, perl = TRUE) params <- gsub("(.*)_zi$", "\\1 (Zero-Inflated)", params, perl = TRUE) params <- gsub("(.*)_disp$", "\\1 (Dispersion)", params, perl = TRUE) # clean random effect parameters names diff --git a/tests/testthat/_snaps/plot.p_significance/plot-p-sig-glmmtmb.svg b/tests/testthat/_snaps/plot.p_significance/plot-p-sig-glmmtmb.svg new file mode 100644 index 000000000..f444dd4cc --- /dev/null +++ b/tests/testthat/_snaps/plot.p_significance/plot-p-sig-glmmtmb.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +minedno (Zero-Inflated) +cover (Conditional) +minedno (Conditional) + + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +Possible parameter values +Parameters +Practical Significance + + diff --git a/tests/testthat/test-plot.p_significance.R b/tests/testthat/test-plot.p_significance.R index a65b2b794..1a0d1827b 100644 --- a/tests/testthat/test-plot.p_significance.R +++ b/tests/testthat/test-plot.p_significance.R @@ -8,8 +8,8 @@ test_that("`plot.see_p_significance()` works", { expect_s3_class(plot(result), "gg") }) -skip_if_not_installed("bayestestR", minimum_version = "0.14.1") -skip_if_not_installed("parameters", minimum_version = "0.22.3") +# skip_if_not_installed("bayestestR", minimum_version = "0.14.1") +# skip_if_not_installed("parameters", minimum_version = "0.22.3") test_that("`plot.see_p_significance works for two thresholds", { skip_if_not_installed("vdiffr") @@ -27,7 +27,7 @@ test_that("`plot.see_p_significance works for two thresholds", { ) }) -test_that("`plot.see_p_significance works {parmaters}}", { +test_that("`plot.see_p_significance works {parameters}}", { skip_if_not_installed("vdiffr") data(qol_cancer, package = "parameters") model <- lm(QoL ~ time + age + education, data = qol_cancer) @@ -50,3 +50,19 @@ test_that("`plot.see_p_significance works {parmaters}}", { fig = plot(out) ) }) + +test_that("plot p_significance, glmmTMB", { + skip_if_not_installed("glmmTMB") + data(Salamanders, package = "glmmTMB") + m1 <- glmmTMB::glmmTMB(count ~ mined + cover + (1 | site), + zi = ~mined, + family = poisson, + data = Salamanders + ) + set.seed(123) + out <- parameters::p_significance(m1) + vdiffr::expect_doppelganger( + title = "plot.p_sig_glmmTMB", + fig = plot(out) + ) +})