This is a brief guide on package cureph illustrated with a simulated data set. First, you should load the package.
library(curephEM)## Loading required package: survival
## Loading required package: Matrix
You may generate a simulated dataset using the build-in function cureph.simgen()
sim.cureph.data = cureph.simgen()
attach(sim.cureph.data)The true parameters are stored in the attributes true.coef and true.baseline.surv.
attr(sim.cureph.data, 'true.coef')## $a
## [1] 1.00 -0.63 1.00 0.00 0.00 0.00 0.00
##
## $b
## [1] -0.2 0.3 0.0 0.0 0.0 0.0
You may use the conventional syntax for coxph to fit a cureph, except for the use of a newly defined Surv.cure object instead of Surv.
Surv.cure(time,time2,event,origin=0,end=20)If only one formula is provided, the set of covariates goes into both the logistic part and the cox part of the model.
fit=cureph(Surv.cure(time,time2,event,origin=0,end=20)~Z1+Z2+Z3+Z4,data=sim.cureph.data)## Converge at step 97
Alternatively, you can provide two formulae—first formula for logistic part, then formula2 for cox part.
fit2=cureph(Surv.cure(time,time2,event,origin=0,end=20)~Z1+Z2+Z3+Z4,
formula2 = ~ Z1+Z2,data=sim.cureph.data)## Converge at step 69
A detailed summary can be produced in a generic way. A multivariate Wald test table is activated if the two sets of covariates are detected to be the same. The null hypothesis is all the coefficients associated with the listed covariate are all zero.
summary(fit)## Call:
## cureph(formula = Surv.cure(time, time2, event, origin = 0, end = 20) ~
## Z1 + Z2 + Z3 + Z4, data = sim.cureph.data)
##
## Logistic Model:
## Surv.cure(time, time2, event, origin = 0, end = 20) ~ Z1 + Z2 +
## Z3 + Z4
## Cox Model:
## Surv.cure(time, time2, event, origin = 0, end = 20) ~ Z1 + Z2 +
## Z3 + Z4
##
## n= 200, number of events= 28
##
## Logistic:
## coef exp(coef) se(coef) z Pr(>|z|)
## (Intercept) 1.044 2.8405 0.9653 1.081 0.279
## Z1 -0.6436 0.5254 0.2278 -2.825 0.005 **
## Z21 1.144 3.1392 0.492 2.325 0.02 *
## Z3B -0.7428 0.4758 0.5641 -1.317 0.188
## Z3C -0.1317 0.8766 0.5848 -0.225 0.822
## Z41 0.1202 1.1278 0.4926 0.244 0.807
## Z42 <NA> <NA> 0 <NA> <NA>
##
## Cox:
## coef exp(coef) se(coef) z Pr(>|z|)
## Z1 -0.652 0.521 0.2667 -2.445 0.014 *
## Z21 0.6047 1.8306 0.4677 1.293 0.196
## Z3B -0.5449 0.5799 0.5997 -0.909 0.364
## Z3C -0.7043 0.4945 0.5629 -1.251 0.211
## Z41 -0.4924 0.6112 0.4729 -1.041 0.298
## Z42 <NA> <NA> 0 <NA> <NA>
##
## Combined Wald tests:
## Wald-chi.square df p-value
## Z1 14.982 2 6e-04 ***
## Z2 7.37 2 0.025 *
## Z3 3.889 4 0.421
## Z4 <NA> 4 <NA>
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Logistic:
## exp(coef) exp(-coef) lower .95 upper .95
## (Intercept) 2.8405 0.3521 0.4282 18.8405
## Z1 0.5254 1.9034 0.3362 0.8211
## Z21 3.1392 0.3185 1.1969 8.2336
## Z3B 0.4758 2.1017 0.1575 1.4375
## Z3C 0.8766 1.1407 0.2786 2.7579
## Z41 1.1278 0.8867 0.4294 2.9618
## Z42 NA NA NA NA
##
## Cox:
## exp(coef) exp(-coef) lower .95 upper .95
## Z1 0.5210 1.9194 0.3089 0.8787
## Z21 1.8306 0.5463 0.7320 4.5783
## Z3B 0.5799 1.7245 0.1790 1.8784
## Z3C 0.4945 2.0224 0.1640 1.4904
## Z41 0.6112 1.6362 0.2419 1.5441
## Z42 NA NA NA NA
##
## Wald test = 41.62 on 11 df, p = 1.883e-05
Another function survpred combines conventional predict and survfit. It returns the linear predictors for both part, the estimated probabilities, the mean-baselevel survival in cox part and the marginal mean-baselevel survival.
mysurv = survpred(fit)## Warning in prob0 * surv.cox: Recycling array of length 1 in array-vector arithmetic is deprecated.
## Use c() or as.vector() instead.
## Warning in 1 - prob0 + prob0 * surv.cox: Recycling array of length 1 in array-vector arithmetic is deprecated.
## Use c() or as.vector() instead.
The generic plot function produces the survival curves.
plot(mysurv)
plot(mysurv, pooled = F)Detach the simulated data.
detach(sim.cureph.data)