I am plotting a calibration during the establishment of the proportional hazards model,but there comes an error after running the last line:
Error in xy.coords(x, y) : 'x' and 'y' lengths differ
code is as follows:
#data reading
seer<-read.table("seer.txt",header=T,sep="\t")
seer$age<-factor(seer$age,labels=c("<50","50-59","60-69","70-79",">=80"))
seer$sex<-factor(seer$sex,labels=c("Female","Male"))
seer$race<-factor(seer$race,labels=c("Black","White","Other"))
seer$stage_T<-factor(seer$stage_T,labels=c("T0","T1","T2","T3a","T3b","T3NOS","T4","TX"))
seer$stage_N<-factor(seer$stage_N,labels=c("N0","N1","NX"))
seer$stage_M<-factor(seer$stage_M,labels=c("M0","M1"))
#establishing the cox model
#3-year
cox1 <- cph(Surv(survival_time,status) ~ age + sex + race + stage_T + stage_N + stage_M,surv=T,x=T, y=T,time.inc = 1*12*3,data=seer)
cal <- calibrate(cox1, cmethod="KM", method="boot", u=1*12*3, m= 12000, B=100)
#plotting the calibration curve
pdf("calibrate3.pdf",12,8)
par(mar = c(10,5,3,2),cex = 1.0)
plot(cal,lwd=3,lty=2,errbar.col="black",xlim = c(0,1),ylim = c(0,1),xlab ="Nomogram-Predicted Probability of 3-Year Survival",ylab="Actual 3-Year Survival",col="blue")
lines(cal,c('mean.predicted','KM'),type = 'a',lwd = 3,col ="black" ,pch = 16) #error comes after here
I am very looking forward to your reply!Thank you.