amices / mice

Multivariate Imputation by Chained Equations
https://amices.org/mice/
GNU General Public License v2.0
433 stars 107 forks source link

Meaning of entries in loggedEvents #481

Closed muelsak closed 2 years ago

muelsak commented 2 years ago

Hello, I unsuccessfully tried to find out what the "out" entries in the loggedEvents matrix mean. Some are self-explanatory but for example if "x" is a variable name, what means "out" = x2, where 2 is a category of x? Here's an example:

set.seed(13)
df <- mice::nhanes
df$x <- sample(factor(c(1, 2, 3, NA, NA)), 25, replace = TRUE)
imp <- mice(
  df
)
imp$loggedEvents

Furthermore, I encountered entries x.Q, x.L, x.C, and x^4, where again "x" is the name of a variable but Q, L, C are not values of x. I did not manage to create a small example for this.

It would be nice to add the meaning of all possible entries in the loggedEvents matrix to the documentation.

gerkovink commented 2 years ago

If for row x the record for out states x2, then x2 has not been used as a predictor and has been kicked out. The Q, C and L and ^4 refer to the expansion of ordered factors in their polynomial components, where in this scenario the expansion has been made in a linear, quadratic, cubic and 4th power term. This is standard behaviour in R for ordered factors

muelsak commented 2 years ago

Thank you very much, that was very helpful! The documentation of the mids class indeed states that out contains the names of altered and removed predictors. But since I encountered entries that clearly don't fall in this category (like mice detected that your data are (nearly) multi-collinear.\nIt applied a ridge penalty to continue calculations, but the results can be unstable.\nDoes your dataset contain duplicates, linear transformation, or factors with unique respondent names? or df set to 1. # observed cases: 25 # predictors: 31), I suspected that x.Q would have another meaning since I wasn't aware of the dummy coding for polynomial regression. You may consider to complete the documentation, but I'm happy now.