You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been working on a simulation study and have been using mice for multiple imputation. I think I have found a bug in mice.impute.polr.
Describe the bug
In some cases I get the following error: Error in apply(draws, 2, sum) : dim(X) must have a positive length
I was able to narrow down this issue and found it only occurred when there was a single missing data point that needs to be imputed for the variable and the proportional log odds model fails and the function resorts to running a multinomial regression as a back up.
I think the error is caused by line 27 converting the post object to a matrix:
if (sum(wy) == 1) {
post <- matrix(post, nrow = 1, ncol = length(post))
}
and then later in the if statement starting on line 32 (which I think is meant to catch cases where just one piece of data is imputed so converts a vector into a matrix):
if (is.vector(post)) {
post <- matrix(c(1 - post, post), ncol = 2)
}
Therefore this leaves the post matrix in incorrect format to then apply the following code, which results in the error:
draws <- un > apply(post, 1, cumsum)
idx <- 1 + apply(draws, 2, sum)
Please let me know if you have any feedback on this issue.
The text was updated successfully, but these errors were encountered:
Hello,
I have been working on a simulation study and have been using mice for multiple imputation. I think I have found a bug in mice.impute.polr.
Describe the bug
In some cases I get the following error: Error in apply(draws, 2, sum) : dim(X) must have a positive length
I was able to narrow down this issue and found it only occurred when there was a single missing data point that needs to be imputed for the variable and the proportional log odds model fails and the function resorts to running a multinomial regression as a back up.
I think the error is caused by line 27 converting the post object to a matrix:
if (sum(wy) == 1) {
post <- matrix(post, nrow = 1, ncol = length(post))
}
and then later in the if statement starting on line 32 (which I think is meant to catch cases where just one piece of data is imputed so converts a vector into a matrix):
if (is.vector(post)) {
post <- matrix(c(1 - post, post), ncol = 2)
}
Therefore this leaves the post matrix in incorrect format to then apply the following code, which results in the error:
draws <- un > apply(post, 1, cumsum)
idx <- 1 + apply(draws, 2, sum)
Please let me know if you have any feedback on this issue.
The text was updated successfully, but these errors were encountered: