Running examples in 'pec-Ex.R' failed
The error most likely occurred in:

> ### Name: predictRestrictedMeanTime
> ### Title: Predicting restricted mean time
> ### Aliases: predictRestrictedMeanTime predictRestrictedMeanTime.aalen
> ###   predictRestrictedMeanTime.riskRegression
> ###   predictRestrictedMeanTime.cox.aalen predictRestrictedMeanTime.coxph
> ###   predictRestrictedMeanTime.cph predictRestrictedMeanTime.default
> ###   predictRestrictedMeanTime.rfsrc predictRestrictedMeanTime.matrix
> ###   predictRestrictedMeanTime.pecCtree predictRestrictedMeanTime.prodlim
> ###   predictRestrictedMeanTime.psm predictRestrictedMeanTime.selectCox
> ###   predictRestrictedMeanTime.survfit predictRestrictedMeanTime.pecRpart
> ### Keywords: survival
> 
> ### ** Examples
> 
> 
> # generate some survival data
> library(prodlim)
> set.seed(100)
> d <- SimSurv(100)
> # then fit a Cox model
> library(rms)
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, units

Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

> coxmodel <- cph(Surv(time,status)~X1+X2,data=d,surv=TRUE)
> 
> # predicted survival probabilities can be extracted
> # at selected time-points:
> ttt <- quantile(d$time)
> # for selected predictor values:
> ndat <- data.frame(X1=c(0.25,0.25,-0.05,0.05),X2=c(0,1,0,1))
> # as follows
> predictRestrictedMeanTime(coxmodel,newdata=ndat,times=ttt)
   0.4260983  2.1691480  4.9274490  7.6507514   14.4062674
1  0.9955287  0.8986157  0.7441616  0.4961380 0.0160256016
2  0.9886826  0.7622278  0.4721214  0.1686068 0.0000275735
3  0.9966398  0.9228473  0.8009592  0.5907036 0.0448385378
4  0.9906394  0.7990404  0.5378687  0.2297102 0.0001708277
> 
> # stratified cox model
> sfit <- coxph(Surv(time,status)~strata(X1)+X2,data=d,y=TRUE)
> predictRestrictedMeanTime(sfit,newdata=d[1:3,],times=c(1,3,5,10))
Error in Ops.Surv(times, mintime) : Invalid operation on a survival time
Calls: predictRestrictedMeanTime ... summary.survfit -> findrow -> [ -> [.Surv -> Ops.Surv
Execution halted