in my code for coxph, i am keep getting the error that Tstart and tstop are of different length, despite the number of rows are same in tstart, tstop, and event. Can someone advide how to solve this?
model<-coxph(Surv(tstart,tstop,event~sbp+hba1c+ln_uacr+hb+weight+hdl+ldl+ua+alb+k),data=emp)
Error in Surv(tstart, tstop, event ~ sbp + hba1c + ln_uacr + :
Start and stop are different lengths
We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.
If you've never heard of a reprex before, you might want to start by reading this FAQ:
A reprex needs to be self-contained, including the libraries used. Currently, your code produces the following:
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
data<-mtcars
tstart_app<-rep(0,nrow(mtcars))
tstop_app<-mtcars[,paste0("am","hp")]
#> Error in `[.data.frame`(mtcars, , paste0("am", "hp")): undefined columns selected
event_app<-mtcars[,"am"]
appmodel<-coxph(Surv(tstart_app,tstop_app,event_app)~mpg+disp+drat+qsec,data=mtcars)
#> Error in coxph(Surv(tstart_app, tstop_app, event_app) ~ mpg + disp + drat + : could not find function "coxph"