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()
= cureph.simgen()
sim.cureph.data 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.
=cureph(Surv.cure(time,time2,event,origin=0,end=20)~Z1+Z2+Z3+Z4,data=sim.cureph.data) fit
## Converge at step 86
Alternatively, you can provide two formulae—first formula
for logistic part, then formula2
for cox part.
=cureph(Surv.cure(time,time2,event,origin=0,end=20)~Z1+Z2+Z3+Z4,
fit2formula2 = ~ Z1+Z2,data=sim.cureph.data)
## Converge at step 53
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= 32
##
## Logistic:
## coef exp(coef) se(coef) z Pr(>|z|)
## (Intercept) 1.9372 6.9393 0.9579 2.022 0.043 *
## Z1 -0.8117 0.4441 0.2364 -3.434 6e-04 ***
## Z21 0.5959 1.8148 0.4702 1.268 0.205
## Z3B -0.2848 0.7522 0.5293 -0.538 0.591
## Z3C -0.1986 0.8199 0.5498 -0.361 0.718
## Z41 -0.3741 0.6879 0.4595 -0.814 0.416
## Z42 <NA> <NA> 0 <NA> <NA>
##
## Cox:
## coef exp(coef) se(coef) z Pr(>|z|)
## Z1 -0.1013 0.9036 0.2085 -0.486 0.627
## Z21 0.5145 1.6728 0.661 0.778 0.436
## Z3B -0.2278 0.7963 0.6693 -0.34 0.734
## Z3C -0.3241 0.7232 0.6701 -0.484 0.629
## Z41 0.0632 1.0653 0.5753 0.11 0.913
## Z42 <NA> <NA> 0 <NA> <NA>
##
## Combined Wald tests:
## Wald-chi.square df p-value
## Z1 12.944 2 0.002 **
## Z2 2.743 2 0.254
## Z3 0.717 4 0.949
## 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) 6.9393 0.1441 1.0616 45.3584
## Z1 0.4441 2.2518 0.2794 0.7058
## Z21 1.8148 0.5510 0.7221 4.5606
## Z3B 0.7522 1.3295 0.2665 2.1225
## Z3C 0.8199 1.2197 0.2791 2.4082
## Z41 0.6879 1.4537 0.2795 1.6930
## Z42 NA NA NA NA
##
## Cox:
## exp(coef) exp(-coef) lower .95 upper .95
## Z1 0.9036 1.1066 0.6005 1.360
## Z21 1.6728 0.5978 0.4579 6.111
## Z3B 0.7963 1.2559 0.2144 2.957
## Z3C 0.7232 1.3828 0.1945 2.689
## Z41 1.0653 0.9387 0.3449 3.290
## Z42 NA NA NA NA
##
## Wald test = 39.62 on 11 df, p = 4.149e-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.
= survpred(fit) mysurv
## 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)