Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception needed for multicollinearity error "No predictors were left..." for mean imputation? #588

Closed
hanneoberman opened this issue Oct 3, 2023 · 1 comment
Labels

Comments

@hanneoberman
Copy link
Member

Since mean imputation doesn't rely on other variables in the data, the following error should not occur, I believe.

library(mice, warn.conflicts = FALSE)
#> Warning: package 'mice' was built under R version 4.3.1
pred <- make.predictorMatrix(nhanes)
pred[pred == 1] <- 0 # set all imputation model predictors to 0
imp <- mice(nhanes, meth = "mean", pred = pred, print = FALSE)
#> Error in edit.setup(data, setup, ...): `mice` detected constant and/or collinear variables. No predictors were left after their removal.
imp <- mice(nhanes, meth = "mean", print = FALSE) # error does not occur when ignoring the predictor matrix

Created on 2023-10-03 with reprex v2.0.2

stefvanbuuren added a commit that referenced this issue Oct 3, 2023

Verified

This commit was signed with the committer’s verified signature.
utkarshgupta137 Utkarsh Gupta
@stefvanbuuren
Copy link
Member

Thanks. Fixed in mice 3.16.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants