Hi all,

I have a question about multiple imputation within the MICE package. I want to 
use passive imputation for my variable called X, because it is calculated out 
of multiple variables, namely Y, Z. Let's give an example with BMI. I know, 
that if I want to use passive imputation for BMI, I can use the following 
command:

meth["BMI"] <- "~I(weight/(height/100)^2)"
pred[c("weight", "length"), "BMI"] <- 0
imp <- mice(Data, method = meth, predictorMatrix = pred, maxit = 10, m = 5)

But what If the formula for a variable is much more complicated, like with 
CKD-epi. The formula is:

egfr_crea_ckdepi = function(creatinine, age, is_female, is_male) {
  if (length(creatinine) != length(age) ||
      length(creatinine) != length(is_female) ||
      length(creatinine) != length(is_black)) {
    stop("input vector lengths must match!")
  }


  a = ifelse(!is_black, ifelse(!is_female, 141, 144), ifelse(!is_female(163, 
166)))
  b = ifelse(!is_female, 0.9, 0.7)
  c = ifelse(!is_female, ifelse(creatinine <= 0.9, -0.411, -1.209), 
ifelse(creatinine <= 0.7, -0.329, -1.209))
  a * ((creatinine / b) ^ c) * (0.993 ^ age)
}

How can I then use this function for the passive imputation of CKD-epi? (My 
variable is a different variable, but it has the same principle). I have tried 
to do:

meth["CKD-epi"] <- "~I(egfr_crea_ckdepi)"

But that does not work. Using the whole function as written above also does not 
work. Does anybody know how I can solve this issue?

Thank you in advance.

Best,
Lisa





        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to