Displaying 1 result from an estimated 1 matches for "dataphr".
Did you mean:
datadir
2011 Dec 19
1
Calculating the probability of an event at time "t" from a Cox model fit
...d of censoring
x1 = rnorm(n,0)
x2 = rnorm(n,0)
# true event time
T = rweibull(n, shape=1, scale=lambdaT*exp(-beta1*x1-beta2*x2))
C = rweibull(n, shape=1, scale=lambdaC) #censoring time
time = pmin(T,C) #observed time is min of censored and true
event = time==T # set to 1 if event is observed
dataphr=data.frame(time,event,x1,x2)
library(survival)
fit_coxph <- coxph(Surv(time, event)~ x1 + x2 , method="breslow")
library(peperr)
predictProb.coxph(fit_coxph, Surv(dataphr$time, dataphr$event), dataphr,
0.003)
# Using predictProb.coxph function, probability of event at time (t) is
es...