rpietro / NSQIPageComplications

Analysis of surgical complications using the NSQIP data set
1 stars 1 forks source link

VIM - why is femalesex not imputed? #27

Closed mworni closed 12 years ago

mworni commented 12 years ago

I did run the script of NSQIP_imputation.R (hosted on google drive at the same place as the full script...). Eventhough I used the code below, femalesex was not not imputed at the end. Any idea why?

nsqip.data_IMPUTED_norace <- kNN(nsqip.data,variable=c("bmi", "residentpresent", "highasa", "preopsepsisclass", "preophospitallos", "femalesex"),dist_var=c("diabetes", "alcoholuse", "chronicpulmonary", "decreasedfunction", "acutepulmonary", "chroniccardiac", "acutecardiac", "hypertension", "pvd", "renal", "acutecognitive", "cerebrovascular", "preopinfectedwound", "chronicsteroids", "preopalbumincateg", "bleedingdisorder", "totalwrvuquartile", "incisionalwoundclass", "optimequartile", "anesthesiaonlytimequartile", "ascites", "esophvarices", "yearoperation"), k=3,imp_suffix="_imp")

rpietro commented 12 years ago

here is what happened:

  1. although you were using a recoding syntax that didn't require attaching the data (the one that looks like data$variable), you did attach it, which means that the recoding you did wasn't working
  2. this means that the "''=NA code never worked and so the femalesex variable didn't have missing values, it had a value of "". with no missing values, there was nothing to be imputed
  3. way i found this was to subset the data to 100 obs and reduce the number of variables to be imputed to one variable, having one predictor (i took this code out of your script but you know how to do this). this made the code run fast and i could run multiple tests. it does create the femalesex_imp with the sample data, now you just have to run it with the full dataset. would just recommend that you look at your whole recoding section again

main message: avoid attaching the data -- I only do it when i'm feeling really lazy. if you do and then you get some strange behavior, first thing to do is to eliminate all attaching since attaching tends to lead to strange behavior

On Sun, Jul 8, 2012 at 4:22 PM, mworni < reply@reply.github.com

wrote:

I did run the script of NSQIP_imputation.R (hosted on google drive at the same place as the full script...). Eventhough I used the code below, femalesex was not not imputed at the end. Any idea why?

nsqip.data_IMPUTED_norace <- kNN(nsqip.data,variable=c("bmi", "residentpresent", "highasa", "preopsepsisclass", "preophospitallos", "femalesex"),dist_var=c("diabetes", "alcoholuse", "chronicpulmonary", "decreasedfunction", "acutepulmonary", "chroniccardiac", "acutecardiac", "hypertension", "pvd", "renal", "acutecognitive", "cerebrovascular", "preopinfectedwound", "chronicsteroids", "preopalbumincateg", "bleedingdisorder", "totalwrvuquartile", "incisionalwoundclass", "optimequartile", "anesthesiaonlytimequartile", "ascites", "esophvarices", "yearoperation"), k=3,imp_suffix="_imp")


Reply to this email directly or view it on GitHub: https://github.com/rpietro/NSQIPageComplications/issues/27

mworni commented 12 years ago

Thanks - makes completely sense. It now worked as well and all variables were imputed I wanted to get imputed.

On Mon, Jul 9, 2012 at 2:03 PM, Ricardo Pietrobon < reply@reply.github.com

wrote:

here is what happened:

  1. although you were using a recoding syntax that didn't require attaching the data (the one that looks like data$variable), you did attach it, which means that the recoding you did wasn't working
  2. this means that the "''=NA code never worked and so the femalesex variable didn't have missing values, it had a value of "". with no missing values, there was nothing to be imputed
  3. way i found this was to subset the data to 100 obs and reduce the number of variables to be imputed to one variable, having one predictor (i took this code out of your script but you know how to do this). this made the code run fast and i could run multiple tests. it does create the femalesex_imp with the sample data, now you just have to run it with the full dataset. would just recommend that you look at your whole recoding section again

main message: avoid attaching the data -- I only do it when i'm feeling really lazy. if you do and then you get some strange behavior, first thing to do is to eliminate all attaching since attaching tends to lead to strange behavior

On Sun, Jul 8, 2012 at 4:22 PM, mworni < reply@reply.github.com

wrote:

I did run the script of NSQIP_imputation.R (hosted on google drive at the same place as the full script...). Eventhough I used the code below, femalesex was not not imputed at the end. Any idea why?

nsqip.data_IMPUTED_norace <- kNN(nsqip.data,variable=c("bmi", "residentpresent", "highasa", "preopsepsisclass", "preophospitallos", "femalesex"),dist_var=c("diabetes", "alcoholuse", "chronicpulmonary", "decreasedfunction", "acutepulmonary", "chroniccardiac", "acutecardiac", "hypertension", "pvd", "renal", "acutecognitive", "cerebrovascular", "preopinfectedwound", "chronicsteroids", "preopalbumincateg", "bleedingdisorder", "totalwrvuquartile", "incisionalwoundclass", "optimequartile", "anesthesiaonlytimequartile", "ascites", "esophvarices", "yearoperation"), k=3,imp_suffix="_imp")


Reply to this email directly or view it on GitHub: https://github.com/rpietro/NSQIPageComplications/issues/27


Reply to this email directly or view it on GitHub:

https://github.com/rpietro/NSQIPageComplications/issues/27#issuecomment-6844648

Mathias Worni, MD, MHS Consulting Associate in Surgery Department of Surgery Duke University Medical Center