Skip to content

Commit

Permalink
marginaleffects_0_18_0
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Feb 5, 2024
1 parent 12c6389 commit d320b87
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions tests/testthat/test-marginaleffects.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ skip_if_not_installed("rstanarm")
test_that("marginaleffects()", {
# Frequentist
x <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
model <- marginaleffects::slopes(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length")
model <- marginaleffects::avg_slopes(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length")

Check warning on line 7 in tests/testthat/test-marginaleffects.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-marginaleffects.R,line=7,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 121 characters.
out <- parameters(model)
expect_identical(nrow(out), 1L)
expect_named(out, c(
"Parameter", "Comparison", "Coefficient", "SE", "Statistic",
"p", "CI", "CI_low", "CI_high"
"Parameter", "Coefficient", "SE", "Statistic",
"p", "s.value", "CI", "CI_low", "CI_high"
))
out <- model_parameters(model, exponentiate = TRUE)
expect_equal(out$Coefficient, 1.394, tolerance = 1e-3)
Expand All @@ -24,7 +24,7 @@ test_that("marginaleffects()", {
chains = 1
)
)
model <- marginaleffects::slopes(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length")
model <- marginaleffects::avg_slopes(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length")

Check warning on line 27 in tests/testthat/test-marginaleffects.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-marginaleffects.R,line=27,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 121 characters.
expect_identical(nrow(parameters(model)), 1L)
})

Expand All @@ -47,7 +47,7 @@ test_that("comparisons()", {
data(iris)
# Frequentist
x <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
m <- marginaleffects::comparisons(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length")
m <- marginaleffects::avg_comparisons(x, newdata = insight::get_datagrid(x, at = "Species"), variables = "Petal.Length")

Check warning on line 50 in tests/testthat/test-marginaleffects.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-marginaleffects.R,line=50,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 122 characters.
expect_identical(nrow(parameters(m)), 1L)
out <- parameters(m, exponentiate = TRUE)
expect_equal(out$Coefficient, 1.393999, tolerance = 1e-4)
Expand All @@ -62,7 +62,7 @@ test_that("comparisons()", {
chains = 1
)
)
m <- marginaleffects::slopes(
m <- marginaleffects::avg_slopes(
x,
newdata = insight::get_datagrid(x, at = "Species"),
variables = "Petal.Length"
Expand All @@ -71,16 +71,6 @@ test_that("comparisons()", {
})


test_that("marginalmeans()", {
data(mtcars)
dat <- mtcars
dat$cyl <- factor(dat$cyl)
dat$gear <- factor(dat$gear)
x <- lm(mpg ~ cyl + gear, data = dat)
m <- marginaleffects::marginalmeans(x)
expect_identical(nrow(parameters(m)), 6L)
})


test_that("hypotheses()", {
data(mtcars)
Expand Down

0 comments on commit d320b87

Please sign in to comment.