Skip to content

Commit

Permalink
clean up tests [run ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Apr 29, 2024
1 parent d4eaefd commit 2d82cbe
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 0 additions & 2 deletions R/plot.R
Expand Up @@ -434,8 +434,6 @@ qqmath.merMod <- function(x, data = NULL, id=NULL, idLabels=NULL, ...) {
if (!is.null(data)) {
idLabels <- id
id <- data
print(id)
print(idLabels)
warning("qqmath.merMod takes ", sQuote("data"), "as its ",
"first argument for S3 method compatibility: ",
"in the future, please ",
Expand Down
8 changes: 6 additions & 2 deletions R/predict.R
Expand Up @@ -503,8 +503,12 @@ predict.merMod <- function(object, newdata=NULL, newparams=NULL,
newRE <- mkNewReTrms(object, rfd, re.form, na.action=na.action,
allow.new.levels=allow.new.levels)
REvals <- base::drop(as(newRE$b %*% newRE$Zt, "matrix"))
if (class(fit.na.action) %in% c("omit", "exclude") && length(fit.na.action)>0) {
REvals <- REvals[-fit.na.action]
## only needed if called as simulation? NAs sometimes excluded within mkNewReTrms ...
if (length(pred) != length(REvals)) {
if (!class(fit.na.action) %in% c("omit", "exclude") && length(fit.na.action)>0) {
stop("fixed/RE pred length mismatch")
}
REvals <- REvals[-fit.na.action]
}
pred <- pred + REvals
if (random.only) {
Expand Down
1 change: 0 additions & 1 deletion src/Makevars
@@ -1,6 +1,5 @@
## -*- mode: makefile; -*-

PKG_LIBS = `$(R_HOME)/bin/Rscript --vanilla -e "Rcpp:::LdFlags()"`
PKG_CXXFLAGS = -DEIGEN_DONT_VECTORIZE

## For a release, uncomment the following line to suppress package
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-methods.R
Expand Up @@ -685,8 +685,8 @@ test_that("plot", {
(1|recipe:replicate), cake2, REML= FALSE)
expect_is(lattice::qqmath(fm2, id=0.05), "trellis")
expect_is(lattice::qqmath(fm2, id=0.05, idLabels=~recipe), "trellis")
expect_is(lattice::qqmath(fm2, 0.05, ~recipe), "trellis") # was expect_warning()
expect_is(lattice::qqmath(fm2, 0.05), "trellis") # was expect_warning()
expect_warning(lattice::qqmath(fm2, 0.05, ~recipe), "please specify")
expect_warning(lattice::qqmath(fm2, 0.05), "please specify")
})

context("misc")
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/test-predict.R
Expand Up @@ -498,20 +498,23 @@ test_that("predict works with factors in left-out REs", {
lc = factor(rep(1:2, 50)),
g1 = factor(rep(1:10, 10)),
g3 = factor(rep(1:10, each = 10)))
m1B <- lmer(yield ~ 1 + ( 1 | g1) + (lc |g3), data = df2)
m1B <- lmer(yield ~ 1 + ( 1 | g1) + (lc |g3), data = df2,
control = lmerControl(check.conv.singular = "ignore"))
expect_equal(head(predict(m1B, re.form = ~(1|g1)),1),
c(`1` = 0.146787496519465))
})

test_that("predict works with dummy() in left-out REs", {
set.seed(101)
df3 <- data.frame(v1 = rnorm(100),
v3 = factor(rep(1:10, each = 10)),
v4 = factor(rep(1:2, each = 50)),
v5 = factor(rep(1:10, 10)))
m1C <- lmer(v1~(1|v3) + (0+dummy(v4,"1")|v5),
data = df3,
control=lmerControl(check.nobs.vs.nlev="ignore",
check.nobs.vs.nRE="ignore"))
check.nobs.vs.nRE="ignore",
check.conv.singular = "ignore"))
expect_equal(head(predict(m1C, re.form = ~1|v3), 1),
c(`1` = 0.0354183724049692))
c(`1` = -0.035719520719991))
})
Binary file added tests/testthat/test-summary_testlevel_1.rda
Binary file not shown.

0 comments on commit 2d82cbe

Please sign in to comment.