I need to impute missing data and then coduct multinomial regression with the generated datasets. I have tried using mice for the imputing and then multinom function from nnet for the multnomial regression. But this gives me unreadable output. Here is an example using the nhanes2 dataset available with the mice package:
library(mice)
library(nnet)
test <- mice(nhanes2, meth=c('sample','pmm','logreg','norm'))
#age is categorical, bmi is continuous
m <- with(test, multinom(age ~ bmi, model = T))
summary(pool(m))
m1 <- with(test, lm(bmi ~ age, model = T))
summary(pool(m1))
With the code above, the output of 'm' lists the coefficients as 1, 2, 3 and 4 instead of their variable names. The output for m1 when using the lm command instead comes out correctly. This seems to be an issue with running the multinomial command on a mira object. Does anyone have any suggestions on how to fix this or suggestions for other imputation and multinomial regression methods that would work better?
EDIT
This has now been updated on the development branch of
mice
, and executes as expected: see https://github.com/stefvanbuuren/mice/issues/85There are a couple of issues when using
mulitnom
. Thepool
method mixes up the ordering of the coefficients and standard errors - so (asaik) the object returned from usingpool
is not correct (actually mixes up is a bit strong - there is no specificpool
method formultinom
models, and so it uses the default which doesn't quite work in this case) .Also, as you mention, then names are dropped - this is due to
pool
callingnames(coef(modelobject))
, butmultinom
models return a matrix of coefficients, and so don't havenames
(they haverownames
&colnames
).So you can alter the
pool
function to cater formultinom
models - seepooly
below (actually you could write a much smaller function that just deals with this model class, but I chose to write a quick, more general approach which should hopefully not break for other model classes, but with caveat, I have not fully tested that it didn't.)Test with your example
Compare to original which (I think) mixes up the coefs & se's
Define function to accept
multinom
models. The added code has comments next to it.