tests/testthat/test-MCMCglmm.R

.runThisTest <- Sys.getenv("RunAllggeffectsTests") == "yes"

if (.runThisTest && requiet("testthat") && requiet("ggeffects") && requiet("MCMCglmm")) {
  set.seed(123)
  data(PlodiaPO)
  m1 <- MCMCglmm(
    PO ~ plate,
    random = ~FSfamily,
    data = PlodiaPO,
    verbose = FALSE,
    nitt = 1300,
    burnin = 300,
    thin = 1
  )

  test_that("ggpredict", {
    p <- ggpredict(m1, "plate")
    expect_equal(p$predicted[1], 1.055517, tolerance = 1e-3)
  })


  data(iris)
  set.seed(123)
  iris$grp <<- as.factor(sample(1:3, 150, TRUE))

  set.seed(123)
  model <- MCMCglmm(
    Sepal.Length ~ Sepal.Width + Species,
    random = ~grp,
    verbose = FALSE,
    data = iris
  )

  test_that("ggpredict", {
    p <- ggpredict(model, "Sepal.Width")
    expect_equal(p$predicted[1], 3.862325, tolerance = 1e-3)
    expect_equal(p$conf.low[1], 3.494669, tolerance = 1e-3)
  })
}

Try the ggeffects package in your browser

Any scripts or data that you put into this service are public.

ggeffects documentation built on Oct. 17, 2023, 5:07 p.m.