Package longroc. November 20, 2017

Similar documents
Package appnn. R topics documented: July 12, 2015

Package citccmst. February 19, 2015

Package prognosticroc

Package nopaco. R topics documented: April 13, Type Package Title Non-Parametric Concordance Coefficient Version 1.0.

Package inctools. January 3, 2018

Package AbsFilterGSEA

Package wally. May 25, Type Package

Package ICCbin. November 14, 2017

ivlewbel: Uses heteroscedasticity to estimate mismeasured and endogenous regressor models

Package rvtdt. February 20, rvtdt... 1 rvtdt.example... 3 rvtdts... 3 TrendWeights Index 6. population control weighted rare-varaints TDT

Package clust.bin.pair

Package HAP.ROR. R topics documented: February 19, 2015

Package QualInt. February 19, 2015

Package ordibreadth. R topics documented: December 4, Type Package Title Ordinated Diet Breadth Version 1.0 Date Author James Fordyce

Package xseq. R topics documented: September 11, 2015

Package singlecase. April 19, 2009

Package ORIClust. February 19, 2015

Package inote. June 8, 2017

Package MethPed. September 1, 2018

Package speff2trial. February 20, 2015

1 Diagnostic Test Evaluation

Package cssam. February 19, 2015

Package p3state.msm. R topics documented: February 20, 2015

Package pollen. October 7, 2018

Package ExactCIdiff. February 15, 2013

Package CompareTests

Package ega. March 21, 2017

Supplementary Materials

Package RNAsmc. December 11, 2018

1 Introduction. st0020. The Stata Journal (2002) 2, Number 3, pp

Package PELVIS. R topics documented: December 18, Type Package

Package Actigraphy. R topics documented: January 15, Type Package Title Actigraphy Data Analysis Version 1.3.

Package tumgr. February 4, 2016

Package influence.me

Package hei. August 17, 2017

Abstract: Heart failure research suggests that multiple biomarkers could be combined

Assessment of performance and decision curve analysis

Package sbpiper. April 20, 2018

Package TEQR. R topics documented: February 5, Version Date Title Target Equivalence Range Design Author M.

Package NonCompart. August 16, 2017

Review. Imagine the following table being obtained as a random. Decision Test Diseased Not Diseased Positive TP FP Negative FN TN

Package StepReg. November 3, 2017

Package CorMut. January 21, 2019

Package preference. May 8, 2018

Package mediation. September 18, 2009

Package propoverlap. R topics documented: February 20, Type Package

Package MSstatsTMT. February 26, Title Protein Significance Analysis in shotgun mass spectrometry-based

Net Reclassification Risk: a graph to clarify the potential prognostic utility of new markers

Knowledge Discovery and Data Mining. Testing. Performance Measures. Notes. Lecture 15 - ROC, AUC & Lift. Tom Kelsey. Notes

Package ncar. July 20, 2018

4. Model evaluation & selection

Package SAMURAI. February 19, 2015

Package EpiEstim. R topics documented: February 19, Version Date 2013/03/08

Package CorMut. August 2, 2013

Package GANPAdata. February 19, 2015

3. Model evaluation & selection

Package labstats. December 5, 2016

Package DeconRNASeq. November 19, 2017

Package xmeta. August 16, 2017

Package BCRA. April 25, 2018

Package mdsdt. March 12, 2016

Glucose tolerance status was defined as a binary trait: 0 for NGT subjects, and 1 for IFG/IGT

Comparing Two ROC Curves Independent Groups Design

Package memapp. R topics documented: June 2, Version 2.10 Date

Package CopulaREMADA

Package CopulaREMADA

Package Interpol. R topics documented: February 19, Type Package. Title Interpolation of amino acid sequences. Version

Small Group Presentations

Part [2.1]: Evaluation of Markers for Treatment Selection Linking Clinical and Statistical Goals

Predicting Breast Cancer Survival Using Treatment and Patient Factors

Package noia. February 20, 2015

Computer Models for Medical Diagnosis and Prognostication

Package pathifier. August 17, 2018

Package ClusteredMutations

Section 6: Analysing Relationships Between Variables

A mathematical model for short-term vs. long-term survival in patients with. glioma

It s hard to predict!

CLINICAL TRIAL SIMULATION & ANALYSIS

Package BUScorrect. September 16, 2018

Landmarking, immortal time bias and. Dynamic prediction

Introduction. We can make a prediction about Y i based on X i by setting a threshold value T, and predicting Y i = 1 when X i > T.

Bootstrapped Integrative Hypothesis Test, COPD-Lung Cancer Differentiation, and Joint mirnas Biomarkers

Critical reading of diagnostic imaging studies. Lecture Goals. Constantine Gatsonis, PhD. Brown University

Improved Hepatic Fibrosis Grading Using Point Shear Wave Elastography and Machine Learning

PERFORMANCE MEASURES

Package frailtyhl. February 19, 2015

1.4 - Linear Regression and MS Excel

Package diggitdata. April 11, 2019

Neural Coding. Computing and the Brain. How Is Information Coded in Networks of Spiking Neurons?

RISK PREDICTION MODEL: PENALIZED REGRESSIONS

Web Appendix Index of Web Appendix

Quantitative Evaluation of Edge Detectors Using the Minimum Kernel Variance Criterion

Modeling Sentiment with Ridge Regression

Discrimination and Reclassification in Statistics and Study Design AACC/ASN 30 th Beckman Conference

Lecture Outline Biost 517 Applied Biostatistics I. Statistical Goals of Studies Role of Statistical Inference

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Final, Fall 2014

Research Methods in Forest Sciences: Learning Diary. Yoko Lu December Research process

Statistical Considerations: Study Designs and Challenges in the Development and Validation of Cancer Biomarkers

Transcription:

Type Package Package longroc November 20, 2017 Title Time-Dependent Prognostic Accuracy with Multiply Evaluated Bio Markers or Scores Version 1.0 Date 2017-11-18 Author Alessio Farcomeni Maintainer Alessio Farcomeni <alessio.farcomeni@uniroma1.it> Description Time-dependent Receiver Operating Characteristic curves, Area Under the Curve, and Net Reclassification Indexes for repeated measures. It is based on methods in Barbati and Farcomeni (2017) <doi:10.1007/s10260-017-0410-2>. License GPL (>= 2) Depends R (>= 3.1.2) Imports survival Encoding UTF-8 LazyData true NeedsCompilation no Repository CRAN Date/Publication 2017-11-20 12:17:47 UTC R topics documented: auc.............................................. 2 butstrap........................................... 4 butstrap.nri......................................... 6 butstrap.s.......................................... 8 maxauc........................................... 10 maxauc.s.......................................... 12 nri.............................................. 14 plotauc........................................... 16 plotauc.s.......................................... 18 plotroc........................................... 20 1

2 auc roc.............................................. 22 roc.............................................. 25 sensspec........................................... 27 sensspec.s.......................................... 28 Index 30 auc AUC Description Compute area under the ROC curve Usage auc(ss) Arguments ss Matrix with two columns (1-specificities, sensitivities). It can be simply the output of roc function Details Area under the ROC curve. Value A scalar with the AUC. Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods & Applications, in press See Also roc, butstrap, maxauc

auc 3 Examples # parameters n=100 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5) # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## ## an important marker ro=roc(s2,ti,delta,u,tt,s,vtimes) auc(ro) ## an unrelated marker ro=roc(s1,ti,delta,u,tt,s,vtimes)

4 butstrap auc(ro) butstrap Bootstrapping AUC Description Usage Boostrap the AUC for significance testing and confidence interval calculation butstrap(x,etime,status,u=null,tt,s,vtimes,auc1,b=50,fc=null) Arguments X etime status u tt s vtimes auc1 n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to vtimes[s] (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. Scalar number of measurements/visits to use for each subject. s<=s S vector with visit times AUC for the original data set B Number of bootstrap replicates. Defaults to 50 fc Details Value Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ This function can be used to resample the AUC. The resulting p-value is obtained after assumption that the resampled AUC is Gaussian. Non-parametric confidence interval is obtained as the 2.5 and 97.5 confidence interval is simply given by a Gaussian approximation. A list with the following elements: p.value se ci.np ci.par (Parametric) p-value for H0: AUC=0.5 Standard deviation of the AUC replicates Non-parametric 95% confidence interval for AUC Parametric 95% confidence interval for AUC

butstrap 5 Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also roc, auc, maxauc Examples # parameters n=100 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5) # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))]

6 butstrap.nri cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## an unimportant marker ro=roc(s1,ti,delta,u,tt,s,vtimes) but=butstrap(s1,ti,delta,u,tt,s,vtimes,ro) butstrap.nri Bootstrapping NRI Description Usage Boostrap the AUC for significance testing and confidence interval calculation butstrap.nri(risk1,risk2,etime,status,u,tt,nri1,wh,b=1000) Arguments risk1 risk2 etime status u tt nri1 wh Details Value Baseline risk measurements Enhanced risk measurements n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity Upper limit (time-horizon) for evaluation of sensitivity and specificity. NRI for the original data set Which NRI to boostrap? wh=1 1/2NRI, wh=2 NRI for events, wh=3 NRI for non-events B Number of bootstrap replicates. Defaults to 1000 This function can be used to resample the NRI. The resulting p-value is obtained after assumption that the resampled NRI is Gaussian. Non-parametric confidence interval is obtained as the 2.5 and 97.5 confidence interval is simply given by a Gaussian approximation. A list with the following elements: p.value se ci.np ci.par (Parametric) p-value for H0: NRI=0 Standard deviation of the NRI replicates Non-parametric 95% confidence interval for NRI Parametric 95% confidence interval for NRI

butstrap.nri 7 Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also nri Examples # parameters n=25 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5) # generate data ngrid=1000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))]

8 butstrap.s cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] risk1=apply(s1[,1:s],1,sum) risk1=(risk1-min(risk1))/(max(risk1)-min(risk1)) risk2=apply(s2[,1:s],1,sum) risk2=(risk2-min(risk2))/(max(risk2)-min(risk2)) butstrap.nri(risk1,risk2,ti,delta,u,tt,nri(risk1,risk2,ti,delta,u,tt)$nri,wh=1,b=500) butstrap.s Bootstrapping AUC Description Boostrap the AUC for significance testing and confidence interval calculation Usage butstrap.s(x,etime,status,u=null,tt,s,vtimes,auc1,b=50,fc=null) Arguments X etime status u tt s vtimes auc1 n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to max(vtimes[s]) (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. n vector of number of measurements/visits to use for each subject. all(s<=s) S vector with visit times AUC for the original data set B Number of bootstrap replicates. Defaults to 50 fc Details Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ This function can be used to resample the AUC. The resulting p-value is obtained after assumption that the resampled AUC is Gaussian. Non-parametric confidence interval is obtained as the 2.5 and 97.5 confidence interval is simply given by a Gaussian approximation. Value A list with the following elements:

butstrap.s 9 p.value se ci.np ci.par (Parametric) p-value for H0: AUC=0.5 Standard deviation of the AUC replicates Non-parametric 95% confidence interval for AUC Parametric 95% confidence interval for AUC Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also roc, auc, maxauc Examples # parameters n=100 tt=3 Tmax=10 u=1.5 s=sample(3,n,replace=true) vtimes=c(0,1,2,5) # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n)

10 maxauc ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## an unimportant marker ro=roc.s(s1,ti,delta,u,tt,s,vtimes) but=butstrap.s(s1,ti,delta,u,tt,s,vtimes,ro) maxauc Optimal Score Description Compute optimal score for AUC Usage maxauc(x,etime,status,u=null,tt,s,vtimes,fc=null) Arguments X etime status u tt s vtimes fc p by n by S array of longitudinal scores/biomarkers for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to vtimes[s] (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. Scalar number of measurements/visits to use for each subject. s<=s S vector with visit times Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Details This function can be used to find an optimal linear combination of p scores/biomarkers repeatedly measured over time. The resulting score is optimal as it maximizes the AUC among all possible linear combinations. The first biomarker in array X plays a special role, as by default its coefficient is unitary.

maxauc 11 Value A list with the following elements: beta score Beta coefficients for the optimal score Optimal score Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also auc, butstrap, maxauc Examples # parameters n=25 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5) # generate data ngrid=500 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm]

12 maxauc.s cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## X=array(NA,c(2,nrow(S1),ncol(S1))) X[1,,]=round(S2) #fewer different values, quicker computation X[2,,]=S1 sc=maxauc(x,ti,delta,u,tt,s,vtimes) # beta coefficients sc$beta # final score (X[1,,]+X[2,,]*sc$beta[1]+...+X[p,,]*sc$beta[p-1]) sc$score maxauc.s Optimal Score Description Compute optimal score for AUC Usage maxauc.s(x,etime,status,u=null,tt,s,vtimes,fc=null) Arguments X etime status u n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to max(vtimes[s]) (see below)

maxauc.s 13 tt s vtimes fc Upper limit (time-horizon) for evaluation of sensitivity and specificity. n vector of number of measurements/visits to use for each subject. all(s<=s) S vector with visit times Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Details Value This function can be used to find an optimal linear combination of p scores/biomarkers repeatedly measured over time. The resulting score is optimal as it maximizes the AUC among all possible linear combinations. The first biomarker in array X plays a special role, as by default its coefficient is unitary. A list with the following elements: beta score Beta coefficients for the optimal score Optimal score Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also auc, butstrap, maxauc Examples # parameters n=20 tt=3 Tmax=10 u=1.5 s=sample(3,n,replace=true) vtimes=c(0,1,2,5) # generate data ngrid=500 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid)

14 nri sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## X=array(NA,c(2,nrow(S1),ncol(S1))) X[1,,]=round(S2) #fewer different values, quicker computation X[2,,]=S1 sc=maxauc.s(x,ti,delta,u,tt,s,vtimes) # beta coefficients sc$beta # final score (X[1,,]+X[2,,]*sc$beta[1]+...+X[p,,]*sc$beta[p-1]) sc$score nri NRI Description Compute NRI

nri 15 Usage nri(risk1, risk2, etime,status,u,tt) Arguments risk1 risk2 etime status u tt Baseline risk measures Enhanced risk measures n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Upper limit (time-horizon) for evaluation of sensitivity and specificity. Details This function gives the continuous NRI to compare two risk measures. Value A list with the following elements: nri nri.events nri.nonevents 1/2 NRI NRI for events NRI for non-events Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also butstrap.nri Examples # parameters n=100 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5)

16 plotauc # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] risk1=apply(s1[,1:s],1,sum) risk1=(risk1-min(risk1))/(max(risk1)-min(risk1)) risk2=apply(s2[,1:s],1,sum) risk2=(risk2-min(risk2))/(max(risk2)-min(risk2)) nri(risk1,risk2,ti,delta,u,tt) plotauc AUC as a function of time Description Compute area under the ROC curve for several values of time horizon Usage plotauc(x,etime,status,u=null,tt,s,vtimes,fc=null,plot=true)

plotauc 17 Arguments X etime status u tt s vtimes fc plot n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to vtimes[s] (see below) A vector of upper limits (time-horizons) for evaluation of sensitivity and specificity. Scalar number of measurements/visits to use for each subject. s<=s S vector with visit times Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Do we plot the AUCs? Defaults to TRUE Details Value Area under the ROC curve is computed for each value of the vector tt. The resulting vector is returned. If plot=true (which is the default) also a plot of tt vs AUC is displayed. A vector with AUCs Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods & Applications, in press See Also roc, butstrap, auc Examples # parameters n=25 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5)

18 plotauc.s # generate data ngrid=1000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## ## an important marker aucs=plotauc(s2,ti,delta,u,seq(2,5,length=5),s,vtimes) plotauc.s AUC as a function of time Description Compute area under the ROC curve for several values of the time horizon Usage plotauc.s(x,etime,status,u=null,tt,s,vtimes,fc=null,plot=true)

plotauc.s 19 Arguments X etime status u tt s vtimes fc plot n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to vtimes[s] (see below) A vector of upper limits (time-horizons) for evaluation of sensitivity and specificity. n vector of measurements/visits to use for each subject. all(s<=s) S vector with visit times Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Do we plot the AUCs? Defaults to TRUE Details Value Area under the ROC curve is computed for each value of the vector tt. The resulting vector is returned. If plot=true (which is the default) also a plot of tt vs AUC is displayed. A vector with AUCs Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods & Applications, in press See Also roc.s, butstrap.s, auc Examples # parameters n=25 tt=3 Tmax=10 u=1.5 s=sample(3,n,replace=true) vtimes=c(0,1,2,5)

20 plotroc # generate data ngrid=1000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## ## an important marker aucs=plotauc.s(s2,ti,delta,u,seq(2,5,length=5),s,vtimes) plotroc Plot ROC Description Plot the ROC curve Usage plotroc(ro, add=false, col=null)

plotroc 21 Arguments ro add col Matrix with two columns (1-specificities, sensitivities). It can be simply the output of roc function If FALSE (default) creates a new plot, otherwise adds to the existing one Colour for the ROC curve (defaults to red) Details Plots the area under the ROC curve. Value A plot or a new line in an open plot. Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods & Applications, in press See Also roc, roc.s, auc Examples # parameters n=100 tt=3 Tmax=10 u=1.5 s=2 vtimes=c(0,1,2,5) # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid]

22 roc S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## ## an important marker ro=roc(s2,ti,delta,u,tt,s,vtimes) plotroc(ro) ## an unrelated marker ro=roc(s1,ti,delta,u,tt,s,vtimes) plotroc(ro) roc ROC curve Description Compute ROC curve Usage roc(x,etime,status,u=null,tt,s,vtimes,fc=null) Arguments X etime n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times

roc 23 status u tt s vtimes fc n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to vtimes[s] (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. Scalar number of measurements/visits to use for each subject. s<=s S vector with visit times Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Details Value ROC curve is defined as the curve given by (1-specificities, sensitivities). Here these are obtained for a time-dependent multiply-measured marker are defined as Se(t,c,s,u) = Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) u <= T <= t), and Sp(t,c,s,u) = 1-Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) T > t) for some fixed f_c, where c is a cutoff. The default for f_c is that a positive diagnosis is given as soon as any measurement among the s considered is above the threshold. A matrix with the following columns: 1-spec sens 1-Specificities Sensitivities Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also auc, butstrap, maxauc Examples # parameters n=100 tt=3 Tmax=10 u=1.5

24 roc s=2 vtimes=c(0,1,2,5) # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))] cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## ## an important marker ro=roc(s2,ti,delta,u,tt,s,vtimes) plot(ro,type="l",col="red") abline(a=0,b=1) ## an unrelated marker ro=roc(s1,ti,delta,u,tt,s,vtimes) plot(ro,type="l",col="red") abline(a=0,b=1)

roc. 25 roc. ROC curve Description Compute ROC curve Usage roc.s(x,etime,status,u=null,tt,s,vtimes,fc=null) Arguments X etime status u tt s vtimes fc n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to max(vtimes[s]) (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. n vector of measurements/visits to use for each subject. all(s<=s) S vector with visit times Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Details Value ROC curve is defined as the curve given by (1-specificities, sensitivities). Here these are obtained for a time-dependent multiply-measured marker are defined as Se(t,c,s,u) = Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) u <= T <= t), and Sp(t,c,s,u) = 1-Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) T > t) for some fixed f_c, where c is a cutoff. The default for f_c is that a positive diagnosis is given as soon as any measurement among the s considered is above the threshold. A matrix with the following columns: 1-spec sens 1-Specificities Sensitivities

26 roc. Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also auc, butstrap, maxauc Examples # parameters n=100 tt=3 Tmax=10 u=1.5 s=sample(3,n,replace=true) vtimes=c(0,1,2,5) # generate data ngrid=5000 ts=seq(0,tmax,length=ngrid) X2=matrix(rnorm(n*ngrid,0,0.1),n,ngrid) sa=sample(ngrid/6,1) vals=sample(3,1)-1 X2[i,1:sa[1]]=vals[1]+X2[i,1:sa[1]] X2[i,(sa[1]+1):ngrid]=vals[1]+sample(c(-2,2),1)+X2[i,(sa[1]+1):ngrid] S1=matrix(sample(4,n,replace=TRUE),n,length(vtimes)) S2=matrix(NA,n,length(vtimes)) S2[,1]=X2[,1] for(j in 2:length(vtimes)) { tm=which.min(abs(ts-vtimes[j])) S2[,j]=X2[,tm] cens=runif(n) ripart=1-exp(-0.01*apply(exp(x2),1,cumsum)*ts/1:ngrid) Ti=rep(NA,n) Ti[i]=ts[which.min(abs(ripart[,i]-cens[i]))]

sensspec 27 cens=runif(n,0,tmax*2) delta=ifelse(cens>ti,1,0) Ti[cens<Ti]=cens[cens<Ti] ## ## an important marker ro=roc.s(s2,ti,delta,u,tt,s,vtimes) plot(ro,type="l",col="red") abline(a=0,b=1) ## an unrelated marker ro=roc.s(s1,ti,delta,u,tt,s,vtimes) plot(ro,type="l",col="red") abline(a=0,b=1) sensspec Sensitivity and Specificity Description Compute sensitivity and specificity Usage sensspec(x,etime,status,u=null,tt,s,vtimes,cutoff=0,fc=null) Arguments X etime status u tt s vtimes n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to vtimes[s] (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. Scalar number of measurements/visits to use for each subject. s<=s S vector with visit times cutoff cutoff for definining events. Defaults to 0 fc Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$

28 sensspec.s Details Value Sensitivity and specificities for a time-dependent multiply-measured marker are defined as Se(t,c,s,u) = Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) u <= T <= t), and Sp(t,c,s,u) = 1-Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) T > t) for some fixed f_c, where c is a cutoff. The default for f_c is that a positive diagnosis is given as soon as any measurement among the s considered is above the threshold. A vector with the following elements: sens spec Sensitivity at the cutoff Specificity at the cutoff Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also roc, auc, butstrap, maxauc sensspec.s Sensitivity and Specificity Description Compute sensitivity and specificity Usage sensspec.s(x,etime,status,u=null,tt,s,vtimes,cutoff=0,fc=null)

sensspec.s 29 Arguments X etime status u tt s vtimes n by S matrix of longitudinal score/biomarker for i-th subject at j-th occasion (NA if unmeasured) n vector with follow-up times n vector with event indicators Lower limit for evaluation of sensitivity and specificity. Defaults to max(vtimes[s]) (see below) Upper limit (time-horizon) for evaluation of sensitivity and specificity. n vector of measurements/visits to use for each subject. all(s<=s) S vector with visit times cutoff cutoff for definining events. Defaults to 0 fc Details Value Events are defined as fc = 1. Defaults to $I(cup X(t_j)>cutoff)$ Sensitivity and specificities for a time-dependent multiply-measured marker are defined as Se(t,c,s,u) = Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) u <= T <= t), and Sp(t,c,s,u) = 1-Pr(f_c(X(t_1),X(t_2),...,X(t_s_i)) T > t) for some fixed f_c, where c is a cutoff. The default for f_c is that a positive diagnosis is given as soon as any measurement among the s considered is above the threshold. A vector with the following elements: sens spec Sensitivity at the cutoff Specificity at the cutoff Author(s) Alessio Farcomeni <alessio.farcomeni@uniroma1.it> References Barbati, G. and Farcomeni, A. (2017) Prognostic assessment of repeatedly measured time-dependent biomarkers, with application to dilated cardiomuopathy, Statistical Methods \& Applications, in press See Also roc, auc, butstrap, maxauc

Index auc, 2, 5, 9, 11, 13, 17, 19, 21, 23, 26, 28, 29 butstrap, 2, 4, 11, 13, 17, 23, 26, 28, 29 butstrap.nri, 6, 15 butstrap.s, 8, 19 maxauc, 2, 5, 9, 10, 11, 13, 23, 26, 28, 29 maxauc.s, 12 nri, 7, 14 plotauc, 16 plotauc.s, 18 plotroc, 20 roc, 2, 5, 9, 17, 21, 22, 28, 29 roc., 25 roc.s, 19, 21 roc.s (roc.), 25 sensspec, 27 sensspec.s, 28 30