1

I am trying to do impute some data using random forest using the mice package but it throws an error. Why?

library(mice)
library(tidyverse)
library(dplyr)
  • Random forest will be the best fit to impute this particular data
  • [31] mice.impute.rf

Use mice function produces an error

imputed_data <- mice(data, m = 5, method = "rf")

Error in get(".Random.seed", envir = globalenv(), mode = "integer", inherits = FALSE):object '.Random.seed' of mode 'integer' was not found

summary(imputed_data)

Error in summary(imputed_data) : object 'imputed_data' not found

This is when I run into my error and I have no clue how to fix it. If anyone can help me, and explain what this means in the most basic terms, I would greatly appreciate it. I posted the error message after the tried to do the impute random forest.

user20650
  • 24,654
  • 5
  • 56
  • 91
Julie Rae
  • 11
  • 1
  • 1
    What version of R are you running? What if you run `set.seed(101)` (or any random integer) before you try calling `mice()`. You should avoid copy/pasting a worksheet or tutorial or whatever the first part of your question is. Just focus on the specific problem you are having and make a minimal [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to demonstrate the problem. Just copy/pasting the entire text leaves a lot of irrelevant noise in the question. – MrFlick Aug 04 '22 at 20:22
  • I have the most updated version. Sorry, I included all the work, I didn't want to leave anything out. I didn't copy and paste anything. I typed out all of this... its a mixture of videos and googled code. I've tried to run `set.seed` once before and it runs, and when I run the summary it goes through, however, I'm not showing the results it's supposed to. I've tried to run `set.seed = 101` argument, I get a `Warning message: Number of logged events: 9`. When i do the summary, it doesn't list "rf" under the 3 columns I need to run & impute under. so I know the `set.seed` didn't work. – Julie Rae Aug 04 '22 at 21:44
  • 1
    @JulieRae; there is a lot of text there. Is it correct that your query begins at the "*Use mice function*" section and it is that the function `mice` thows an error . If so, its worth deleting all the stuff before to make your question clearer. Have you tried restarting R and running again --> without loading a previous workspace? Can you edit your question with the results of `sessionInfo()` please. If the error persists in a fresh session can you share an example of `data` please - just enough to replicate the issue. – user20650 Aug 04 '22 at 22:27
  • ... or do you also get the error with the built in datasets e.g. `imputed_data <- mice(nhanes2, m = 5, method = "rf")` .. in a fresh R session – user20650 Aug 04 '22 at 22:33
  • I see, thank you for editing, that makes more sense and to the point. Sorry, I'm still learning. Not a built-in dataset. I imported the data. I've ran this code in both R-studio the new updated version, and in an R-kernel in jupyter-lab. Both gave me the same error. When I do put the `set.seed` argument and then run the `summary`, it runs but shows that the random forest did not run in the columns I wanted it too. All the columns show up blank with no specifications that "rf" ran on those specific columns with missing data in the output. – Julie Rae Aug 05 '22 at 00:06

0 Answers0