SchoenSmooth | R Documentation |
This function smooths the Schoenfeld residuals using Epanechnikov's optimal kernel.
SchoenSmooth(fit, Stime, status, span=0.40, order=0, entry=NULL)
fit |
the result of fitting a Cox regression model, using the coxph function |
Stime |
Survival times in case of right censored data and exit time for left truncated data |
status |
Survival status |
span |
bandwidth parameter that controls the size of a local neighborhood |
order |
0 or 1, locally mean if 0 and local linear if 1 |
entry |
entry time when left censored data is considered, default is NULL for only right censored data |
This function smooths the Schoenfeld residuals to get an estimate of time-varying effect of the marker using Epanechnikov's optimal kernel using either local mean or local linear smoother.
Returns a list of following items:
time |
failure times |
beta |
estimate of time-varying parameter β(t) at each unique failure time. |
Patrick J. Heagerty
Heagerty, P.J., Zheng Y. (2005) Survival Model Predictive Accuracy and ROC curves Biometrics, 61, 92 – 105
data(pbc) ## considering only randomized patients pbc1 <- pbc[1:312,] ## create new censoring variable combine 0,1 as 0, 2 as 1 survival.status <- ifelse( pbc1$status==2, 1, 0) survival.time <- pbc1$fudays pbc1$status1 <- survival.status fit <- coxph( Surv(fudays,status1) ~ log(bili) + log(protime) + edema + albumin + age, data=pbc1 ) eta5 <- fit$linear.predictors x <- eta5 nobs <- length(survival.time[survival.status==1]) span <- 1.5*(nobs^(-0.2)) fitCox5 <- coxph( Surv(survival.time,survival.status) ~ x ) bfnx1.1 <- SchoenSmooth( fit=fitCox5, Stime=survival.time, status=survival.status, span=span, order=1) bfnx1.0 <- SchoenSmooth( fit=fitCox5, Stime=survival.time, status=survival.status, span=span, order=0) plot(bfnx1.1$time, bfnx1.1$beta, type="l", xlab="Time", ylab="beta(t)") lines(bfnx1.0$time, bfnx1.0$beta, lty=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.