Skip to content

Commit

Permalink
styler
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Dec 18, 2024
1 parent fd57758 commit ed11964
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
10 changes: 7 additions & 3 deletions tests/testthat/test-data.frame-with-rvar.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ test_that("data.frame w/ rvar_col descrive_posterior etc", {
res <- eti(dfx, rvar_col = "my_rvar", ci = c(0.8, 0.95))
res.ref <- eti(dfx$my_rvar, ci = c(0.8, 0.95))
expect_true(all(c("mu", "sigma") %in% colnames(res)))
expect_identical(as.data.frame(res[c("mu", "sigma")]),
data.frame(mu = c(0, 0, 0.5, 0.5, 1, 1),
sigma = c(1, 1, 0.5, 0.5, 0.25, 0.25)))
expect_identical(
as.data.frame(res[c("mu", "sigma")]),
data.frame(
mu = c(0, 0, 0.5, 0.5, 1, 1),
sigma = c(1, 1, 0.5, 0.5, 0.25, 0.25)
)
)
expect_identical(nrow(format(res)), 3L)
expect_identical(ncol(format(res)), 4L)
expect_equal(res[setdiff(colnames(res), c("mu", "sigma"))],
Expand Down
10 changes: 7 additions & 3 deletions tests/testthat/test-emmGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ test_that("emmGrid hdi", {
expect_identical(xhdi$CI_low, xhdi2$CI_low)

xhdi3 <- hdi(all_, ci = c(0.9, 0.95))
expect_identical(as.data.frame(xhdi3[1:2]),
data.frame(group = c("1", "1", "2", "2", ".", "."),
contrast = c(".", ".", ".", ".", "group1 - group2", "group1 - group2"), stringsAsFactors = FALSE))
expect_identical(
as.data.frame(xhdi3[1:2]),
data.frame(
group = c("1", "1", "2", "2", ".", "."),
contrast = c(".", ".", ".", ".", "group1 - group2", "group1 - group2"), stringsAsFactors = FALSE
)
)
})

test_that("emmGrid point_estimate", {
Expand Down
30 changes: 20 additions & 10 deletions tests/testthat/test-marginaleffects.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,26 @@ withr::with_environment(

# multi ci levels
res <- hdi(mfx, ci = c(0.8, 0.9))
expect_identical(as.data.frame(res[1:3]),
data.frame(term = c("am", "am", "am", "am", "cyl", "cyl",
"cyl", "cyl", "cyl", "cyl", "cyl", "cyl",
"hp", "hp", "hp", "hp"),
contrast = c("1 - 0", "1 - 0", "1 - 0", "1 - 0",
"6 - 4", "6 - 4", "8 - 4", "8 - 4",
"6 - 4", "6 - 4", "8 - 4", "8 - 4",
"dY/dX", "dY/dX", "dY/dX", "dY/dX"),
am = c(0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0,
1, 1), stringsAsFactors = FALSE))
expect_identical(
as.data.frame(res[1:3]),
data.frame(
term = c(
"am", "am", "am", "am", "cyl", "cyl",
"cyl", "cyl", "cyl", "cyl", "cyl", "cyl",
"hp", "hp", "hp", "hp"
),
contrast = c(
"1 - 0", "1 - 0", "1 - 0", "1 - 0",
"6 - 4", "6 - 4", "8 - 4", "8 - 4",
"6 - 4", "6 - 4", "8 - 4", "8 - 4",
"dY/dX", "dY/dX", "dY/dX", "dY/dX"
),
am = c(
0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0,
1, 1
), stringsAsFactors = FALSE
)
)

# estimate_density
mfx <- marginaleffects::comparisons(mod,
Expand Down

0 comments on commit ed11964

Please sign in to comment.