Skip to content

Commit

Permalink
Sample initial levels with replacement (surprising to find this bug a…
Browse files Browse the repository at this point in the history
…fter 24 years)
  • Loading branch information
stefvanbuuren committed Aug 23, 2024
1 parent bd4efd1 commit 30e7661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# mice 3.16.14

* Fixes a bug during initialization of factor values

# mice 3.16.13

* Adds support for the `literanger` package for `rf` imputation that is about twice as fast as `ranger` (#648). Thanks @stephematician for the contribution.
Expand Down
2 changes: 1 addition & 1 deletion R/initialize.imp.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ initialize.imp <- function(data, m, ignore, where, blocks, visitSequence,
imp[[j]][, i] <- data.init[wy, j]
} else {
if (is.factor(y)) {
imp[[j]][, i] <- sample(levels(y), nrow(data))
imp[[j]][, i] <- sample(levels(y), nrow(data), replace = TRUE)
} else {
imp[[j]][, i] <- rnorm(nrow(data))
}
Expand Down

0 comments on commit 30e7661

Please sign in to comment.