Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling var(x) on a factor x is defunct when using mice pool function #433

Closed
bskubi opened this issue Sep 27, 2021 · 6 comments
Closed

Comments

@bskubi
Copy link

bskubi commented Sep 27, 2021

I'm using mice and trying to pool the multiple imputations.

#kp is a dataframe with three columns, "x", "Y", and "View". x and Y are numeric, View is class "character"
html <-  read_html("https://wiki.socr.umich.edu/index.php/SOCR_Data_KneePainData_041409")
kp <- html_nodes(html, "table")[[2]] %>%
  html_table()
kp$View <- factor(kp$View)
kp_m <- as.data.frame(kp)
#Some code edited out - I replace values in kp_m with NA because this is for a homework assignment testing multiple imputations. Result is kp_m, a version of kp with 5% of values missing.
kp_i <- mice(kp_m, m=5, maxit=50, meth='pmm', seed=1)
kp_p <- pool(kp_i)

On the call to "pool" above, I get the error:
Calling var(x) on a factor x is defunct. Use something like 'all(duplicated(x)[-1L])' to test for a constant vector. Calls: ... tibble -> tibble_quos -> eval_tidy -> vapply -> FUN -> var

@gerkovink
Copy link
Member

I'd suggest looking at the mice vignettes for the proper workflow. You don't seem to be pooling a model.

@jay-sf
Copy link

jay-sf commented Sep 28, 2021

You're right, @gerkovink , however I suggest pool to throw a more useful error message. Please see my answer on Stack Overflow in this context.

@gerkovink
Copy link
Member

@jay-sf that's a good point. Wouldn't have guessed this user behaviour for pool(). Will add a more informative error message.

@stefvanbuuren
Copy link
Member

Ah, never saw this error before. The error message is best implemented in as.mira() when it sees a mids object.

@gerkovink
Copy link
Member

Agreed. Will do.

@stefvanbuuren
Copy link
Member

mice 3.13.14 should give the appropriate error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants