Hi all, I have many variables to test using cox model (coxph), and I am only interested in those variables with p value less than 0.01. Is there a quick way to do this automatically instead of looking at the output of each variable? Plus, is there a method in R that I could adjust the multiple testing in coxph? Thanks, Chris
> I have many variables to test using cox model (coxph), and I am onlyinterested in those variables with p value less than 0.01. Is there a quick way to do this automatically instead of looking at the output of each variable?> ChrisI guess you need covariate selection. for a lengthy discussion of another method (AIC/BIC), look at last month archive: https://www.stat.math.ethz.ch/pipermail/r-help/2004-July/subject.html#53519 and try using> library(MASS) > stepAIC (...)Most of the time, it starts removing the covariate with the lower p-value. Mayeul KAUFFMANN Univ. Pierre Mendes France Grenoble - France
Thanks Mayeul, I actually would like to test each variable individually and use those have low p-value to build a classifier (not in cox model). Therefore, I need to write a function to subset those low p-value variables, instead of putting them as covariates. Any ideas? Chris -----Original Message----- From: Mayeul KAUFFMANN [mailto:mayeul.kauffmann at tiscali.fr] Sent: Thursday, August 12, 2004 8:17 PM To: r-help at stat.math.ethz.ch Subject: [R] coxph question> I have many variables to test using cox model (coxph), and I am onlyinterested in those variables with p value less than 0.01. Is there a quick way to do this automatically instead of looking at the output of each variable?> ChrisI guess you need covariate selection. for a lengthy discussion of another method (AIC/BIC), look at last month archive: https://www.stat.math.ethz.ch/pipermail/r-help/2004-July/subject.html#53519 and try using> library(MASS) > stepAIC (...)Most of the time, it starts removing the covariate with the lower p-value. Mayeul KAUFFMANN Univ. Pierre Mendes France Grenoble - France ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Chris, I understood the following: you want to try every single covariate in a cox model with only one covariate, then take the best ones according to p-value. Assume your columns look like: stop status event x1 x2 x3 etc You want to add column 3 (x1), then 4, etc. I suggest a for() loop: z<-NULL;for(i in 3:ncol(data)) {coxtmp <- coxph(Surv(stop,status)~ data[,i]) #you can modify the formula for #adding covariates in any case, for instance beta<-coxtmp$coefficients[1] se<-sqrt(diag(coxtmp$var))[1] z<- rbind(z,c(i,beta,se,pvalue=signif(1 - pchisq((beta/ se)^2, 1), 4))) print (i)} #then select the covariates according to the p values: z[z$pvalue<.01,"i"] Hope it helps. Mayeul KAUFFMANN Univ. Pierre Mendes France Grenoble - France ----- Original Message ----- Thanks Mayeul, I actually would like to test each variable individually and use those have low p-value to build a classifier (not in cox model). Therefore, I need to write a function to subset those low p-value variables, instead of putting them as covariates. Any ideas? Chris -----Original Message-----> I have many variables to test using cox model (coxph), and I am onlyinterested in those variables with p value less than 0.01. Is there a quick way to do this automatically instead of looking at the output of each variable?> Chris