rpietro / airwayDehiscence

Airway dehiscence project using the UNOS database
0 stars 0 forks source link

Cox model error #17

Open acastleberry opened 12 years ago

acastleberry commented 12 years ago

I created a Cox model and named it "survival1". The model runs fine without errors and if I run "summary(survival1)", it shows all the data, p-values, etc. I then run the following code: cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE) so I can get the data in a more user-friendly format. This worked fine yesterday and I had nice, clean columns with OR, CI, and p-values. Today, however, when I run this same code I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

I have not made any changes to the script so I'm unsure why it was working yesterday but not today. Also, if there is some error with undefined columns, I don't know why "summary(survival1)" works just fine. I have installed all the same packages and rerun this a couple of times, but keep getting the same error. Any thoughts?

rpietro commented 12 years ago

not in front of my computer now, but a few things to do:

  1. View(data) -- where data is your data object and check for any empty lines at the end, note that the command View has a capital V
  2. if you find an empty line or lines (likely), then just delete them either on your original data set or in R with something like:

data <- data[!is.na(data$variable),]

need to check code above since i didn't run it, but it's kind of like that

On Wed, Oct 3, 2012 at 11:39 AM, acastleberry notifications@github.comwrote:

I created a Cox model and named it "survival1". The model runs fine without errors and if I run "summary(survival1)", it shows all the data, p-values, etc. I then run the following code: cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE) so I can get the data in a more user-friendly format. This worked fine yesterday and I had nice, clean columns with OR, CI, and p-values. Today, however, when I run this same code I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

I have not made any changes to the script so I'm unsure why it was working yesterday but not today. Also, if there is some error with undefined columns, I don't know why "summary(survival1)" works just fine. I have installed all the same packages and rerun this a couple of times, but keep getting the same error. Any thoughts?

— Reply to this email directly or view it on GitHubhttps://github.com/rpietro/airwayDehiscence/issues/17.

mworni commented 12 years ago

i don't know... On Oct 3, 2012 5:56 PM, "acastleberry" notifications@github.com wrote:

I created a Cox model and named it "survival1". The model runs fine without errors and if I run "summary(survival1)", it shows all the data, p-values, etc. I then run the following code: cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE) so I can get the data in a more user-friendly format. This worked fine yesterday and I had nice, clean columns with OR, CI, and p-values. Today, however, when I run this same code I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

I have not made any changes to the script so I'm unsure why it was working yesterday but not today. Also, if there is some error with undefined columns, I don't know why "summary(survival1)" works just fine. I have installed all the same packages and rerun this a couple of times, but keep getting the same error. Any thoughts?

— Reply to this email directly or view it on GitHubhttps://github.com/rpietro/airwayDehiscence/issues/17.

rpietro commented 12 years ago

If what Ricardo said does not work, could you indicate the line of the code in github that is showing this problem?

2012/10/3 Ricardo Pietrobon pietr007@gmail.com

not in front of my computer now, but a few things to do:

  1. View(data) -- where data is your data object and check for any empty lines at the end, note that the command View has a capital V
  2. if you find an empty line or lines (likely), then just delete them either on your original data set or in R with something like:

data <- data[!is.na(data$variable),]

need to check code above since i didn't run it, but it's kind of like that

On Wed, Oct 3, 2012 at 11:39 AM, acastleberry notifications@github.comwrote:

I created a Cox model and named it "survival1". The model runs fine without errors and if I run "summary(survival1)", it shows all the data, p-values, etc. I then run the following code: cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE) so I can get the data in a more user-friendly format. This worked fine yesterday and I had nice, clean columns with OR, CI, and p-values. Today, however, when I run this same code I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

I have not made any changes to the script so I'm unsure why it was working yesterday but not today. Also, if there is some error with undefined columns, I don't know why "summary(survival1)" works just fine. I have installed all the same packages and rerun this a couple of times, but keep getting the same error. Any thoughts?

— Reply to this email directly or view it on GitHubhttps://github.com/rpietro/airwayDehiscence/issues/17.

Joao Ricardo N. Vissoci Tel. US - +19194916644 Tel. Brazil - +554499298078 Psicólogo CRP 08/12469 - Psychologist Prof. MSc. Faculdade Ingá Doutorando em Psicologia Social - PUCsp - Phd Candidate Social Psychology Grupo Pro-Esporte UEM/CNPq - Pro-Sport Research Group Núcleo de Estudos e Pesquisas sobre Identidade-Metamorfose - NEPIM/PUC/CNPq Research on Research Group - RoR - Duke University joaovissoci@gmail.com http://joaovissoci@gmail.com/jrvissoci@ig.com.br proesporteuem.blogspot.com.br researchonresearch.org

acastleberry commented 12 years ago

I looked with View(data) and there aren't any empty lines. The weird thing here is that I use the same covariates for the logistic regression model, and that runs fine as does the command logistic.display. The Cox model also appears to run fine and I get no error messages when I run it. Also, when I then run “summary(survival1)”, that works fine and displays the raw data output (where "survival1" is what I named the Cox model). It appears to be an issue with the “cox.display” command, which is what is generating the error message.

The code on line 86 of our script and is as follows:

cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE)

rpietro commented 12 years ago

let's definitely look into this. could you post the script line that is generating the error and the error itself?

On Wed, Oct 3, 2012 at 4:42 PM, Joao Ricardo Nickenig Vissoci < joaovissoci@gmail.com> wrote:

If what Ricardo said does not work, could you indicate the line of the code in github that is showing this problem?

2012/10/3 Ricardo Pietrobon pietr007@gmail.com

not in front of my computer now, but a few things to do:

  1. View(data) -- where data is your data object and check for any empty lines at the end, note that the command View has a capital V
  2. if you find an empty line or lines (likely), then just delete them either on your original data set or in R with something like:

data <- data[!is.na(data$variable),]

need to check code above since i didn't run it, but it's kind of like that

On Wed, Oct 3, 2012 at 11:39 AM, acastleberry notifications@github.comwrote:

I created a Cox model and named it "survival1". The model runs fine without errors and if I run "summary(survival1)", it shows all the data, p-values, etc. I then run the following code: cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE) so I can get the data in a more user-friendly format. This worked fine yesterday and I had nice, clean columns with OR, CI, and p-values. Today, however, when I run this same code I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

I have not made any changes to the script so I'm unsure why it was working yesterday but not today. Also, if there is some error with undefined columns, I don't know why "summary(survival1)" works just fine. I have installed all the same packages and rerun this a couple of times, but keep getting the same error. Any thoughts?

— Reply to this email directly or view it on GitHubhttps://github.com/rpietro/airwayDehiscence/issues/17.

Joao Ricardo N. Vissoci Tel. US - +19194916644 Tel. Brazil - +554499298078 Psicólogo CRP 08/12469 - Psychologist Prof. MSc. Faculdade Ingá Doutorando em Psicologia Social - PUCsp - Phd Candidate Social Psychology Grupo Pro-Esporte UEM/CNPq - Pro-Sport Research Group Núcleo de Estudos e Pesquisas sobre Identidade-Metamorfose - NEPIM/PUC/CNPq Research on Research Group - RoR - Duke University joaovissoci@gmail.com http://joaovissoci@gmail.com/jrvissoci@ig.com.br proesporteuem.blogspot.com.br researchonresearch.org

acastleberry commented 12 years ago

Yes, here is the full script for that section:

cox_AA_PROCEDURE_TY<-recode(AA_PROCEDURE_TY, "'H/L'=NA; ''=NA") #Recode H/L as NA so dropped. cox_AA_PROCEDURE_TY <- relevel(cox_AA_PROCEDURE_TY, ref="S") #Make "S" the reference

survival1 <- coxph(Surv(AA_FU_TIME_DAYS, AA_VITAL_STATUS) ~ AA_BRONC_STRICTURE + TRTREJ1Y + AGE_BY_5 + GENDER + AA_ETHCAT_MISMATCH + AA_DIAG_LTX_RECODE + cox_AA_PROCEDURE_TY + TX_YEAR + STEROID + rcd_MED_COND_TRR + LIFE_SUP_TRR + VENTILATOR_TRR + DAYSWAIT_BY_90 + VOL_BY_10_PER_YEAR + AGE_DON_BY_5 + rcd_HIST_CIG_DON + rcd_HIST_COCAINE_DON + IMP_PO2_BY_50 + AA_IMP_ISCHTIME + rcd_DIABETES_DON, data=BRST_StudyPopulation)

summary(survival1) cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE)

Everything works fine up until cox.display. When I run that line I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

rpietro commented 12 years ago

Tony, good meeting today. as we discussed, if the variable$coefficient approach has all you need, then i would go with that. the cox.display issue seems to be a bug, and if you would like to get that to work i would post an email to the R mailing list and copy the developer of the epicalc package

btw, the variable$coefficient approach is what Mathias was using to build custom tables. the approach works, it's just far too cumbersome to do every time. at some point we might want to create a package (see attached) to create automated tables in a simpler way and then publish about this package on http://goo.gl/f3FH . for now just an idea ...

On Wed, Oct 3, 2012 at 5:07 PM, acastleberry notifications@github.comwrote:

Yes, here is the full script for that section:

cox_AA_PROCEDURE_TY<-recode(AA_PROCEDURE_TY, "'H/L'=NA; ''=NA") #Recode H/L as NA so dropped. cox_AA_PROCEDURE_TY <- relevel(cox_AA_PROCEDURE_TY, ref="S") #Make "S" the reference

survival1 <- coxph(Surv(AA_FU_TIME_DAYS, AA_VITAL_STATUS) ~ AA_BRONC_STRICTURE + TRTREJ1Y + AGE_BY_5 + GENDER + AA_ETHCAT_MISMATCH + AA_DIAG_LTX_RECODE + cox_AA_PROCEDURE_TY + TX_YEAR + STEROID + rcd_MED_COND_TRR + LIFE_SUP_TRR + VENTILATOR_TRR + DAYSWAIT_BY_90 + VOL_BY_10_PER_YEAR + AGE_DON_BY_5 + rcd_HIST_CIG_DON + rcd_HIST_COCAINE_DON

  • IMP_PO2_BY_50 + AA_IMP_ISCHTIME + rcd_DIABETES_DON, data=BRST_StudyPopulation)

summary(survival1)

cox.display (survival1, alpha = 0.05, crude = TRUE, crude.p.value = TRUE, decimal = 2, simplified = TRUE)

Everything works fine up until cox.display. When I run that line I get the following error:

Error in [.data.frame(get(as.character(model$call)[3]), , attr(model$term, : undefined columns selected

Reply to this email directly or view it on GitHubhttps://github.com/rpietro/airwayDehiscence/issues/17#issuecomment-9122236.