Skip to content

Commit

Permalink
Fix problems with zero predictors (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefvanbuuren committed Oct 3, 2023
1 parent 5100464 commit 615a1ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/edit.setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ edit.setup <- function(data, setup,
}
}

if (all(pred == 0L)) {
if (all(pred == 0L) && didlog) {
stop("`mice` detected constant and/or collinear variables. No predictors were left after their removal.")
}

Expand Down
2 changes: 1 addition & 1 deletion R/sampler.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sampler.univ <- function(data, r, where, pred, formula, method, yname, k,
if (calltype == "pred") {
vars <- colnames(data)[pred != 0]
xnames <- setdiff(vars, j)
if (length(pred) > 0L) {
if (length(xnames) > 0L) {
formula <- reformulate(xnames, response = j)
formula <- update(formula, ". ~ . ")
} else {
Expand Down

0 comments on commit 615a1ed

Please sign in to comment.