-
Notifications
You must be signed in to change notification settings - Fork 108
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
Open
stefvanbuuren
wants to merge
39
commits into
master
Choose a base branch
from
support_blocks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
4cf4953
Major update that improves support for formulas specification
stefvanbuuren ea84be3
Convert documentation Rd tags to markdown tags for roxygen2
stefvanbuuren 5c6bee2
Add a data argument to nimp() to calculate number of imputations per …
stefvanbuuren 755c23a
Restore classic predictorMatrix behaviour that sets predictorMatrix[j…
stefvanbuuren c2da03c
Clean up source, identicate that there is still a problem with edit.s…
stefvanbuuren 28821a6
Create a make.nest(), n2b() and b2n() function for working with nest …
stefvanbuuren 731bf25
Insist that predictorMatrix has a zero diagonal
stefvanbuuren 8f92307
- Prevention of NA propagation
stefvanbuuren 772c876
Add exit checks on mids object
stefvanbuuren 465bd5c
Add test for zero predictorMatrix row if method == "", deal with rela…
stefvanbuuren c8ed335
Update news
stefvanbuuren 05a0209
Update documentation for mice() arguments
stefvanbuuren 6033fc6
Update list of builtin imputation methods
stefvanbuuren 29fee22
Reorder sequence of mice() arguments
stefvanbuuren fef881b
Reorder nest in data sequence
stefvanbuuren ba383eb
Use lowercase 'b' and 'f' for automatic naming of blocks and formulas
stefvanbuuren 4175534
Update error message in mpmm
stefvanbuuren 0166992
Sort terms both for pred and formulas
stefvanbuuren 35b6084
Create a mechanism to inform check.method() of the set of variables t…
stefvanbuuren 65f544f
Introduce NA types in initialize.imp()
stefvanbuuren d9c6fa6
Update nest printing in print.mids()
stefvanbuuren b9e398e
Add support for blots to multivariate imputation models
stefvanbuuren 0345ec3
Rename `nest` to `parcel`
stefvanbuuren 07a79e9
Use lower case default block names
stefvanbuuren 53916f4
Rename `blots` to `dots`
stefvanbuuren 3c09055
Rename files from blots/nest to dots/parcel
stefvanbuuren 3cebc30
Add deprecation support for make.blots()
stefvanbuuren 7b7a17c
Implement autoremove in check.predictorMatrix() and check.formulas()
stefvanbuuren 8c4bb38
Write one loggedEvent for each removed variable
stefvanbuuren 24688b1
Abort mice when user speficies mixes of `formulas` and `predictorMatr…
stefvanbuuren e1c475f
Update NEWS.md
stefvanbuuren da6396b
Reorder mice() arguments into a clusters of operations
stefvanbuuren db5caf6
Remove superfluous construct.parcel(), make remove.rhs.variables() in…
stefvanbuuren f5d5c99
Add MICE 4 Syntax Documentation CONCEPT as a vignette
stefvanbuuren 6edcd71
Rebuild site to include article mice4syntax
stefvanbuuren 232a0b6
Add test for character variable (#601)
stefvanbuuren 09e58ea
Merge main and support_blocks into new branch mice4 (still failing so…
stefvanbuuren 15321b4
Merging update
stefvanbuuren deac372
Update support_blocks with master
stefvanbuuren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,8 @@ make.predictorMatrix <- function(data, blocks = make.blocks(data), | |
|
||
check.predictorMatrix <- function(predictorMatrix, | ||
data, | ||
blocks = NULL) { | ||
blocks = NULL, | ||
autoremove = TRUE) { | ||
data <- check.dataform(data) | ||
|
||
if (!is.matrix(predictorMatrix)) { | ||
|
@@ -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)) | ||
ynames <- row.names(predictorMatrix)[hit] | ||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
uip <- setdiff(notimputed, completevars) | ||
# if any of these are predictors, remove them | ||
removeme <- intersect(uip, colnames(predictorMatrix)) | ||
if (length(removeme) && autoremove) { | ||
predictorMatrix[, removeme] <- 0 | ||
vars <- paste(removeme, collapse = ",") | ||
updateLog(out = paste("incomplete predictor(s)", vars), | ||
meth = "check", frame = 1) | ||
} | ||
|
||
# grow predictorMatrix to all variables in data | ||
if (ncol(predictorMatrix) < ncol(data)) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)