1

Given a simple df:

library(naniar)
library(tidyverse)

df <- tibble(a = c(1,NA,2,3,NA,4,5))

Please explain me why I get first NA to be 0.623 and second 0.504 after running:

df %>% bind_shadow() %>% impute_below_all()

According to the documentation of

naniar::impute_below_all()

It says:

Impute Data With Values Shifted 10% Below Range.

But my range here is 1 to 5. Minimum value is 1 and 10% below it is 1*0.9 = 0.9 Why do I get 0.623 and 0.504.

Can somebody explain this anomaly?

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
SteveS
  • 3,789
  • 5
  • 30
  • 64
  • 1
    I think you can check the `getAnywhere('shadow_shift.numeric')` for more info. I find `x_jitter <- (stats::runif(length(x)) - 0.5) * x_shift * jitter x <- ifelse(is.na(x), yes = x_shift + x_jitter, no = x)` – akrun Sep 18 '19 at 19:37
  • 1
    @akrun you are a professional! I have no words, each time you just impress me with your great knowledge and super informative answers. Please post as answer – SteveS Sep 18 '19 at 19:40
  • 1
    Thanks, but I haven't tested it. If you can test it, please post as an answer – akrun Sep 18 '19 at 19:41

0 Answers0