R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("cmprsk-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('cmprsk') Loading required package: survival Loading required package: splines > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "crr" > > ### * crr > > flush(stderr()); flush(stdout()) > > ### Name: crr > ### Title: Competing Risks Regression > ### Aliases: crr > ### Keywords: survival > > ### ** Examples > > # simulated data to test > set.seed(10) > ftime <- rexp(200) > fstatus <- sample(0:2,200,replace=TRUE) > cov <- matrix(runif(600),nrow=200) > print(z <- crr(ftime,fstatus,cov)) convergence: TRUE coefficients: [1] -0.6306 0.2024 0.6384 standard errors: [1] 0.4043 0.3782 0.4105 two-sided p-values: [1] 0.12 0.59 0.12 > # convergence: TRUE > # coefficients: > # [1] 0.8470 -0.3473 -0.6913 > # standard errors: > # [1] 0.4027 0.4402 0.4916 > # two-sided p-values: > # [1] 0.035 0.430 0.160 > # for failures of type 2 > z.p <- predict(z,rbind(c(.1,.5,.8),c(.1,.5,.2))) > plot(z.p,lty=1,color=2:3) > crr(ftime,fstatus,cov,failcode=2) convergence: TRUE coefficients: [1] 0.01017 -0.17020 -0.58140 standard errors: [1] 0.4418 0.4799 0.4217 two-sided p-values: [1] 0.98 0.72 0.17 > # convergence: TRUE > # coefficients: > # [1] -0.4638 0.4896 0.2331 > # standard errors: > # [1] 0.3896 0.4540 0.4256 > # two-sided p-values: > # [1] 0.23 0.28 0.58 > # quadratic in time for first cov > crr(ftime,fstatus,cov,cbind(cov[,1],cov[,1]),function(Uft) cbind(Uft,Uft^2)) convergence: TRUE coefficients: [1] -0.7257 0.1976 0.6392 0.3692 -0.1459 standard errors: [1] 0.8403 0.3785 0.4116 1.1810 0.3142 two-sided p-values: [1] 0.39 0.60 0.12 0.75 0.64 > # convergence: TRUE > # coefficients: > # [1] 1.3360 -0.3484 -0.6852 -1.1210 0.3897 > # standard errors: > # [1] 0.8657 0.4405 0.4909 1.6860 0.6271 > # two-sided p-values: > # [1] 0.12 0.43 0.16 0.51 0.53 > #last 2 values are the coefs of the cov[,1]*t and cov[,1]*t^2 terms > #additional examples in test.R > > > > cleanEx(); ..nameEx <- "cuminc" > > ### * cuminc > > flush(stderr()); flush(stdout()) > > ### Name: cuminc > ### Title: Cumulative Incidence Analysis > ### Aliases: cuminc > ### Keywords: survival > > ### ** Examples > > set.seed(2) > ss <- rexp(100) > gg <- factor(sample(1:3,100,replace=TRUE),1:3,c('a','b','c')) > cc <- sample(0:2,100,replace=TRUE) > strt <- sample(1:2,100,replace=TRUE) > print(xx <- cuminc(ss,cc,gg,strt)) Tests: stat pv df 1 0.1110522 0.9459873 2 2 0.1344095 0.9350037 2 Estimates and Variances: $est 1 2 3 4 a 1 0.1997374 0.3337599 0.4082169 0.4082169 b 1 0.2582589 0.3116745 0.3116745 0.3116745 c 1 0.2194354 0.2813451 0.2813451 0.2813451 a 2 0.2641725 0.4428692 0.4428692 0.4428692 b 2 0.2669364 0.4479557 0.5280790 0.6082023 c 2 0.2471892 0.4400615 0.4400615 0.4400615 $var 1 2 3 4 a 1 0.005842447 0.009576915 0.013764577 0.013764577 b 1 0.007508487 0.009432554 0.009432554 0.009432554 c 1 0.006644662 0.009550507 0.009550507 0.009550507 a 2 0.008127032 0.011168223 0.011168223 0.011168223 b 2 0.008030980 0.014868553 0.016688860 0.016481796 c 2 0.006941955 0.016574813 0.016574813 0.016574813 > #Tests: > # stat pv > #1 3.393977 0.1832345 > #2 1.989511 0.3698139 > #Estimates and Variances: > #$est > # 1 2 3 4 5 > #a 1 0.1311269 0.2699184 0.3420625 0.3420625 0.3420625 > #b 1 0.2176471 0.2615686 NA NA NA > #c 1 0.3816280 0.4889137 0.5723581 NA NA > #a 2 0.2257601 0.2972171 0.4415053 0.4415053 0.4415053 > #b 2 0.3117647 0.5878431 NA NA NA > #c 2 0.2160508 0.2607532 0.2607532 NA NA > # > #$var > # 1 2 3 4 5 > #a 1 0.003922836 0.009113464 0.012507959 0.01250796 0.01250796 > #b 1 0.005528913 0.006916070 NA NA NA > #c 1 0.009854126 0.012351948 0.015575726 NA NA > #a 2 0.005947601 0.007356628 0.014479506 0.01447951 0.01447951 > #b 2 0.007033454 0.010927780 NA NA NA > #c 2 0.006497566 0.007867543 0.007867543 NA NA > plot(xx,lty=1,color=1:6) > # see also test.R, test.out > > > > ### *