Replies: 1 comment
-
You are changing the structure of the data created by For your case, try to evade the error by replacing
Also try a simpler version
Does that give you the result you desire? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Stef & Team,
I’m facing an issue with as.mids() that I am hoping you can help with.
I’m running mice on a repeated measures dataset in the wide format, because I want to use the same variables measured at different time points as auxiliary variables. I am following the example workflow of this from Section 11.2 of FIMD. My issue arises when I try to covert back to a mids object for plotting and analysis, I get a duplicate row names error. I know people have posted about getting a rownames error with as.mids before, but I have not found a post that details a solution.
I know where the issue is arising; in lines 111-114 of the source code for as.mids, row names are reassigned:
https://github.com/cran/mice/blob/94c89a24f0456d90cf37a15be758c6304818a67d/R/as.R#L111-L114
If my dataset was not longitudinal, or still in wide format, there is no problem because all the .id variables are unique within imps==0. However with repeated measures data in the long format, this line causes the function to fail out because there are going to be repeated ids within imps==0.
A crude solution of course is removing this chunk of the source code which redefines the row names, and this does appear to work for me. However I’m aware thats a bit of a dicey solution, and I feel like I am probably missing something here. What is the purpose of redefining rownames inside the as.mids() function? Is my solution of circumventing this valid or am I off track and should be following a different workflow?
Reprex provided below.
Thanks so much in advance,
Amanda
Beta Was this translation helpful? Give feedback.
All reactions