# How to impute a categorical variable with MICE but prevent it from taking some values?

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:

df=data.frame(age=c(24,37,58,65,70,84, 56, 36, 48,23,15),
var1 =c("B","W", NA, "A",NA, "P","N", NA, "M",NA, "B"),
var1categ=c(0,0, 1, 1, 1,1,1,1,1,1, 0),
ht = c(156, 169, 180, 175, 168, 165, 171, 158, 160, 175, 160))

imp=mice(df, remove_collinear = FALSE)