Skip to content

Commit

Permalink
Suitably complain about anova with only 1 model
Browse files Browse the repository at this point in the history
  • Loading branch information
jpritikin committed Jul 21, 2017
1 parent e9743f3 commit 9e85875
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/MxCompare.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ anova.MxModel <- function(object, ...) {
}

comparison <- args
if (length(comparison) == 0) {
stop(paste("Compare model",omxQuotes(object$name),
"with which other models?"))
}
if(!all(sapply(comparison, is, "MxModel"))) {
stop("The '...' argument must consist of MxModel objects")
}
Expand Down
3 changes: 3 additions & 0 deletions inst/models/nightly/BootLRT.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ cmp3 <- mxRun(cmp3)

mxCompare(base, cmp1) # p=0

omxCheckError(anova(cmp1),
"Compare model 'cmp1' with which other models?")

pgot <- anova(cmp1, cmp2, cmp3, base)
omxCheckEquals(is.na(pgot[,'p']), c(T,F,T,T))

Expand Down

0 comments on commit 9e85875

Please sign in to comment.