Skip to content

Commit 77e3b62

Browse files
committed
fix missing p.value
1 parent 85da373 commit 77e3b62

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: modelbased
33
Title: Estimation of Model-Based Predictions, Contrasts and Means
4-
Version: 0.14.0.3
4+
Version: 0.14.0.4
55
Authors@R:
66
c(person(given = "Dominique",
77
family = "Makowski",

R/format.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ format.marginaleffects_means <- function(x, model, ci = 0.95, ...) {
155155
non_focal <- setdiff(colnames(model_data), attr(x, "focal_terms"))
156156
predict_type <- attributes(x)$predict
157157
transform <- attributes(x)$transform
158+
context_effects <- attributes(x)$context_effects
158159

159160
# special attributes we get from "get_marginalcontrasts()"
160161
comparison <- list(...)$hypothesis
@@ -173,7 +174,7 @@ format.marginaleffects_means <- function(x, model, ci = 0.95, ...) {
173174
)
174175
# for inequality analysis, we want to keep the stratification variable
175176
remove_columns <- setdiff(remove_columns, attributes(x)$hypothesis_by)
176-
} else if (is_contrast_analysis) {
177+
} else if (is_contrast_analysis || context_effects) {
177178
estimate_name <- "Difference"
178179
} else {
179180
# for simple means, we don't want p-values

tests/testthat/test-estimate_contrasts_context.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ test_that("estimate_contrast, context effects, linear", {
1919
)
2020
expect_equal(out$Mean, b[1] - b[2], tolerance = 1e-4, ignore_attr = TRUE)
2121
expect_equal(out$SE, sqrt((se[1]^2 + se[2]^2)), tolerance = 1e-4, ignore_attr = TRUE)
22+
expect_true(!is.null(out$p))
2223
})
2324

2425
test_that("estimate_contrast, context effects, glm", {
@@ -36,13 +37,15 @@ test_that("estimate_contrast, context effects, glm", {
3637
comparison = "context"
3738
)
3839
expect_equal(out$Odds_Ratio, exp(b[1] - b[2]), tolerance = 1e-4, ignore_attr = TRUE)
40+
expect_true(!is.null(out$p))
3941

4042
out <- modelbased::estimate_contrasts(
4143
m,
4244
c("bill_len_between", "bill_len_within"),
4345
comparison = "slope"
4446
)
4547
expect_equal(out$Odds_Ratio, exp(b[1] - b[2]), tolerance = 1e-4, ignore_attr = TRUE)
48+
expect_true(!is.null(out$p))
4649

4750
out <- modelbased::estimate_contrasts(
4851
m,

0 commit comments

Comments
 (0)