Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 5, 2024
1 parent 4849f56 commit 359be88
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions tests/testthat/test-random_effects_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ skip_on_cran()
data(sleepstudy, package = "lme4")
data(cake, package = "lme4")
set.seed(123)
sleepstudy$Months <- sample(1:4, nrow(sleepstudy), TRUE)
sleepstudy$Months <- sample.int(4, nrow(sleepstudy), TRUE)

m1 <- suppressMessages(lme4::lmer(
angle ~ temperature + (temperature | recipe) + (temperature | replicate),
Expand All @@ -20,11 +20,31 @@ m5 <- suppressMessages(lme4::lmer(Reaction ~ Days + (Days + Months | Subject), d

## TODO also check messages for profiled CI

expect_message(mp1 <- model_parameters(m1, ci_random = TRUE), "meaningful")
expect_message(
{
mp1 <- model_parameters(m1, ci_random = TRUE)
},
regex = "meaningful"
)
mp2 <- model_parameters(m2, ci_random = TRUE)
expect_message(mp3 <- model_parameters(m3, ci_random = TRUE), "meaningful")
expect_message(mp4 <- model_parameters(m4, ci_random = TRUE), "meaningful")
expect_message(mp5 <- model_parameters(m5, ci_random = TRUE), "meaningful")
expect_message(
{
mp3 <- model_parameters(m3, ci_random = TRUE)
},
regex = "meaningful"
)
expect_message(
{
mp4 <- model_parameters(m4, ci_random = TRUE)
},
regex = "meaningful"
)
expect_message(
{
mp5 <- model_parameters(m5, ci_random = TRUE)
},
regex = "meaningful"
)


# model 1 ---------------------
Expand Down Expand Up @@ -239,7 +259,7 @@ test_that("random effects CIs, double slope", {
test_that("random effects CIs, simple slope", {
data(sleepstudy, package = "lme4")
set.seed(123)
sleepstudy$Months <- sample(1:4, nrow(sleepstudy), TRUE)
sleepstudy$Months <- sample.int(4, nrow(sleepstudy), TRUE)

m2 <- lme4::lmer(Reaction ~ Days + (0 + Days | Subject), data = sleepstudy)
m5 <- lme4::lmer(Reaction ~ Days + (0 + Days + Months | Subject), data = sleepstudy)
Expand Down Expand Up @@ -280,9 +300,9 @@ test_that("random effects CIs, simple slope", {
# poly random slope --------------------------
test_that("random effects CIs, poly slope", {
data(cake, package = "lme4")
suppressMessages(
suppressMessages({
m <- lme4::lmer(angle ~ poly(temp, 2) + (poly(temp, 2) | replicate) + (1 | recipe), data = cake)
)
})
mp <- model_parameters(m, ci_random = TRUE)

expect_equal(
Expand Down

0 comments on commit 359be88

Please sign in to comment.