Meet the Other Phone. Child-safe in minutes.

Meet the Other Phone.
Child-safe in minutes.

Buy now

Please or to access all these features

Chat

Join the discussion and chat with other Mumsnetters about everyday life, relationships and parenting.

I realise there are better forums to ask, but does anyone have experience of multilevel imputation using mice in R

115 replies

StealthPolarBear · 12/04/2020 18:58

And be willing to answer some idiotic questions?

OP posts:
StealthPolarBear · 12/04/2020 19:44

Yes all variables in one data frame.
I think its complaining because my binary variables have three levels and I'm trying to use logreg, but the 3 are 1,0 and NA!

OP posts:
MinesAPintOfTea · 12/04/2020 19:52

Are they proper binary, or factors? Can you filter out the NA values?

TooMinty · 12/04/2020 19:52

Sorry, are you clustering or building a predictive model? It sounds like you want to build a multi-class logistic regression model where the target variable is either 1,0 or NA? Is that right? Or are you doing that to impute missing values before you cluster?

StealthPolarBear · 12/04/2020 19:55

Mines I want mice to treat the nas as missing
I want to use mice to generate 100 or whatever imputations, and then I'll pool the results

OP posts:
MinesAPintOfTea · 12/04/2020 20:02

But if you think that might be the problem, filter them out for now, and see if it works. When you use str(dataframe) what type is your input variable?

Maybe build it up, starting with one input and debug that?

Really, it is difficult without seeing script or specific errors

TooMinty · 12/04/2020 20:03

What about replacing the N/As with nulls first?

StealthPolarBear · 12/04/2020 20:05

str(dataframe)
Thank you - I think that will be helpful. I need to know what types it thinks my variables are
I'm sorry, I know it's really frustrating, I don't really understand what I'm asking :( I do appreciate people's help

OP posts:
StealthPolarBear · 12/04/2020 20:08

Yes it thinks all my binary are ints. Grr

OP posts:
StealthPolarBear · 12/04/2020 20:09

Agh I bet binary need to be true/false

OP posts:
Magpiecomplex · 12/04/2020 20:20

No experience of MICE but reading the documentation would polyreg work instead of logreg?

StealthPolarBear · 12/04/2020 20:27

I'm using polyreg for unordered categorical data.
Which i suppose you could argue binary data is!
Why can't I find any examples I understand??

OP posts:
StealthPolarBear · 12/04/2020 20:29

OK I've done something and it's run and brought me back a 'complete' dataset with no NAs.
I used pmm for binary but don't understand why I needed to.
Hmm

OP posts:
Magpiecomplex · 12/04/2020 20:37

Does it look sensible if you plot it? If so, I'd be tempted to just accept it! I know what you mean about understanding the examples though - I once spent several hours trying to get a particularly complicated boxplot to use the right colours!

oncemorewithfeeling99 · 12/04/2020 20:40

I read this as mice amputation Confused Anyway, as you were......

StealthPolarBear · 12/04/2020 20:56

I need to calculate proportions on the pooled dataset, and obviously I can also do it using the original dataset with the missings. And yes, if it looks OK, I'm going to accept it. I have someone helping me but she uses stata and so struggles with the syntax.

OP posts:
TooMinty · 12/04/2020 21:31

Is your original dataset big enough to be statistically robust if you ignore the missing values? If so, wouldn't it be better to go with that rather than model to impute the missing ones? Especially if you don't understand how it is doing it. Explainability is important too, I think.

Witchend · 12/04/2020 21:36

I read it as mice in amputations and thought you were perhaps being a bit mean. Grin

StealthPolarBear · 12/04/2020 21:45

Too minty that would have been my preference ebut apparently it had to be this way

OP posts:
MitziK · 12/04/2020 21:58

Thank you for giving me a happy reminder of what it's like sitting in the pub with my mates.

I usually treat it as a drinking game so, by the time they've spilt integers and recalibrated the coefficient of the flux capacitor, I'm ready to wobble off home.

TooMinty · 12/04/2020 21:59

Does R studio try and do everything for you? I've never used it, I'm quite old school... Just taught myself some Python though, that seems good for most things. But I like to write the code myself and decide what it does!

PenfoldsFive · 12/04/2020 22:03

And that’s Numberwang. Grin

StealthPolarBear · 13/04/2020 06:47

Not that I've noticed, or if it does I stop it as I don't understand.
It completes variable names etc which I find helpful

OP posts:
StealthPolarBear · 13/04/2020 07:00

Last night my imputation was running well. This morning it seems to be imputing some of the values I'd expect it to but not others. I bloody hate thos stuff

OP posts:
midgebabe · 13/04/2020 07:16

No idea what mice is but do know R

Have you done much R? You make it sound like you just haven't defined the variable

Also not being able to see the code is tricky to comment

And have you tried stackexchange ?

StealthPolarBear · 13/04/2020 07:19

No, this is my first r project. Though I have coded before.
I am struggling with very basic stuff.
One of my variables is age. One of the NAs has been imputed, another hasn't. Its so odd

OP posts: