Skip to content

Commit

Permalink
NEWS/more tests for NA + re.form = NULL + simulate (GH #737) [run ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Jan 20, 2024
1 parent 1e678b6 commit 957f428
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
8 changes: 6 additions & 2 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
\itemize{
\item \code{lFormula} and \code{glFormula} once again \emph{do}
allow matrix-valued responses (for use in downstream packages like \code{galamm})
}
}
} % itemize
} % user-visible changes
\subsection{BUG FIXES}{
\itemize{
\item \code{simulate} works (again) with \code{re.form=NULL} when
\code{NA} values are present in the data (GH #737, @frousseu)
}

\section{CHANGES IN VERSION 1.1-35 (2023-11-03)}{
Expand Down
19 changes: 14 additions & 5 deletions tests/testthat/test-predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,21 @@ test_that("prediction standard error", {

})

test_that("NA + re.form = NULL + simulate OK", {
test_that("NA + re.form = NULL + simulate OK (GH #737)", {
d <- lme4::sleepstudy
d$Reaction[1] <- NA
fm1 <- lmer(Reaction ~ Days + (Days | Subject), d)
expect_equal(c(head(simulate(fm1, seed = 101, re.form = NULL)[[1]])),
c(266.139101412856, 308.148180398426,
296.081377893883, 338.367909016478,
360.294339946214, 401.91050930589))
ss <- simulate(fm1, seed = 101, re.form = NULL)[[1]]
expect_equal(c(head(ss)),
c(266.139101412856, 308.148180398426,
296.081377893883, 338.367909016478,
360.294339946214, 401.91050930589))
ss0 <- simulate(fm1, seed = 101, re.form = NA)[[1]]
expect_equal(length(ss), length(ss0))
## correct dimensions with na.exclude as well ?
fm2 <- update(fm1, na.action = na.exclude)
ss2 <- simulate(fm2, seed = 101, re.form = NULL)[[1]]
ss3 <- simulate(fm2, seed = 101, re.form = NA)[[1]]
expect_equal(length(ss2), nrow(d))
expect_equal(length(ss3), nrow(d))
})

0 comments on commit 957f428

Please sign in to comment.