I want to perform a time-to-event analysis using qgcomp package. I used qgcomp.cox.boot function and adjusted for confounding factors. However I have encountered some problems.
library("ggplot2")
data("metals", package="qgcomp")
Xnm <-c('arsenic','barium','cadmium','calcium','chromium','copper','iron','lead','magnesium','manganese','mercury','selenium','silver','sodium','zinc')
qc.survfit2 <- qgcomp.cox.boot(Surv(disease_time, disease_state) ~ arsenic+barium+cadmium+calcium+chromium+copper+iron+lead+magnesium+manganese+mercury+selenium+silver+sodium+zinc+ph,expnms=Xnm,data=metals[,c(Xnm, 'disease_time', 'disease_state')], q=4,B=5, MCsize=1000, parallel=TRUE, parplan=TRUE) #ph is a confounding factor
Error in eval(predvars, data, env) : object 'ph' not found
Then I fixed the code as followed:
qc.survfit2 <- qgcomp.cox.boot(Surv(disease_time, disease_state) ~ arsenic+barium+cadmium+calcium+chromium+copper+iron+lead+magnesium+manganese+mercury+selenium+silver+sodium+zinc+metals$ph,expnms=Xnm,data=metals[,c(Xnm, 'disease_time', 'disease_state')], q=4,B=5, MCsize=1000, parallel=TRUE, parplan=TRUE)
Error in model.frame.default(data = list(id__ = c(2L, 2L, 3L, 3L, 3L, :
variable lengths differ ('metals$ph')
Can anyone solve this problem? Thanks a lot.
I have googled this quite a lot, however they didn't solve my problem. In the linear model, I can adjust for confounding factors by inputting the variable name directly. However, it did not work in the time-to-event analysis with qgcomp.cox.boot function.