-
Notifications
You must be signed in to change notification settings - Fork 109
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
Major update that improves support for formulas specification #582
base: master
Are you sure you want to change the base?
Conversation
- reintrocudes the square predictorMatrix - defines conversion functions p2f(), p2c(), f2p(), n2b(), b2n() - defines validate.blocks(), validate.predictorMatrix() - extends edit.setup() to formulas and blots - for reading ease, use "~ 1" for the empty model instead of "~ 0" - does not automatically set method = "" for variables that are not imputed - as far as possible, changes the leading argument to formulas (instead of blocks or predictorMatrix) - adds function typecodes() in sampler() to reduce multiple predictorMatrix lines to one (support for multivariate imputation methods) - implement new logic in samper.univ() - outcomments some tests that depend on hard-coded parameter estimates - sharpens test for equality between predictorMatrix and formulas specifications
Ideas for further development:
|
|
…block. Update make.method() so that homogeneous types and nlevels within a block get an appropriate default method.
…, ] to zero when variable j is member of a block for which no imputations are needed.
Commits 5c6bee2 and 755c23a generalise the classic behaviour of the It works as follows:
This PR also removes the error message mice detected constant and/or collinear variables. No predictors were left after their removal. Imputations will be generated without predictors by the intercept-only imputation model (not recommended in general). WARNING: Setting |
Commit c2da03c cleans up the internal function |
- Stricter controls on input predictorMatrix - Output test of mids object
New behaviours
Changes
|
Exit checks added:
|
…ted issues in check.blocks(), make.method(), edit.predictorMatrix()
…o impute (ynames)
New behaviours and features thus far
|
Three proposed changes to new behaviour
|
@@ -82,9 +83,23 @@ check.predictorMatrix <- function(predictorMatrix, | |||
) | |||
} | |||
|
|||
# calculate ynames (variables to impute) for use in check.method() | |||
# NA-propagation prevention | |||
# find all dependent (imputed) variables | |||
hit <- apply(predictorMatrix, 1, function(x) any(x != 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to: apply(predictorMatrix != 0, 1, any)
# find all variables in data that are not imputed | ||
notimputed <- setdiff(colnames(data), ynames) | ||
# select uip: unimputed incomplete predictors | ||
completevars <- colnames(data)[!apply(is.na(data), 2, sum)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!apply(is.na(data), 2, any)
might be more efficient
Merge branch 'master' into mice4 # Conflicts: # DESCRIPTION # NEWS.md # R/ampute.continuous.R # R/edit.setup.R # R/futuremice.R # R/mice.R # R/mira.R # R/parlmice.R # R/predictorMatrix.R
@@ -157,6 +156,16 @@ check.blocks <- function(blocks, data, calltype = "pred") { | |||
)) | |||
} | |||
|
|||
# save ynames (variables to impute) for use in check.method() | |||
ynames <- unique(as.vector(unname(unlist(blocks)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is as.vector
redundant for the return value from unlist
?
Merge branch 'master' into support_blocks # Conflicts: # DESCRIPTION # NEWS.md # R/ampute.R # R/method.R # R/mice.R # R/mice.impute.rf.R # man/ampute.Rd # man/mice.Rd # man/mice.impute.rf.Rd # tests/testthat/test-parlmice.R
predictorMatrix
p2f()
,p2c()
,f2p()
,n2b()
,b2n()
validate.blocks()
,validate.predictorMatrix()
edit.setup()
toformulas
andblots
~ 1
for the empty predictor set instead of~ 0
method = ""
for variables that are not imputed (NOTE: DECISION REVERTED. SEE BELOW)formulas
(instead ofblocks
orpredictorMatrix
)typecodes()
insampler()
to reduce multiplepredictorMatrix
lines to one (support for multivariate imputation methods)samper.univ()
predictorMatrix
andformulas
specifications