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 a categorical variable, var1 , that can take on values of W, B, A, M, N or P. There are some NAs that I want to impute using the mice package in R, but I know that the missing values cannot be "W" or "B" because those people said that they do not belong in that category. I want to impute var1 but force mice to only choose from everything except B or W .
Thanks for getting back to me. The problem with that is that I don't want to follow this approach because I lose power. The actual dataset is much bigger. df mentioned above is just an example. Preferably I want to do it with either post processing or create a function in mice. But I don't really know how to it. I also know that for integers I can use squeeze. Is there anything similar for categorical variables?
Another way is to start with the mice.impute.polyreg() function. At some point, you see the line post <- predict(fit, xy[wy, , drop = FALSE], type = "probs"), which contains the probabilities per categories. You can then nullify the probabilities of the categories that you want to exclude, and perhaps you need to restandardise so that they add up to 1. If all is well, the method will then only draw from the permitted categories.
Sorry, I don't have examples that implements this approach, but in principle it should work.
I have a categorical variable, var1 , that can take on values of W, B, A, M, N or P. There are some NAs that I want to impute using the mice package in R, but I know that the missing values cannot be "W" or "B" because those people said that they do not belong in that category. I want to impute var1 but force mice to only choose from everything except B or W .
Here is sample code for you to use:
Thank you for your help and please let me know if you need more information.
The text was updated successfully, but these errors were encountered: