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("changeLOS-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('changeLOS') load changeLOS: /CRANPkg/check/changeLOS.Rcheck ... > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "aj" > > ### * aj > > flush(stderr()); flush(stdout()) > > ### Name: aj > ### Title: Aalen-Johansen estimator > ### Aliases: aj > ### Keywords: models > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > my.trans <- trans(model=my.model,observ=my.observ) > my.aj <- aj(my.trans,s=0,t=80) > > > > cleanEx(); ..nameEx <- "clos" > > ### * clos > > flush(stderr()); flush(stdout()) > > ### Name: clos > ### Title: Change in LOS > ### Aliases: clos > ### Keywords: survival programming > > ### ** Examples > > > ## run clos > data(los.data) > my.observ <- prepare.los.data(x=los.data) > tra <- matrix(FALSE,4,4) > diag(tra) <- TRUE > tra[1,] <- TRUE > tra[2,3:4] <- TRUE > my.model <- msmodel(c("0","1","2","3"),tra,cens.name="cens") > los <- clos(model=my.model,observ=my.observ) Loading required package: survival Loading required package: splines > summary(los) Change in LOS: 1.975314 Total % Number of observed patients 756 100.00 Number of patients being discharged 565 74.74 Number of patients who die 191 25.26 Number of patients being censored 0 0.00 Number of patients who experienced the intermediate event(IE) 124 16.40 Number of patients who experienced the IE being discharged 90 11.90 Number of patients who experienced the IE and died 34 4.50 Number of patients who experienced the IE and were censored 0 0.00 > plot(los) > > > ## compute bootstrap SE with function boot() from library boot > > ## first we need a statistic, which boot takes as an argument > "clos.for.bstrap" <- function(data, index, mod){ + my.observ <- prepare.los.data(x=data[index,]) + return(clos(model=mod,observ=my.observ)$cLOS) + } > > ## our estimate is > clos.for.bstrap(data=los.data, index=1:length(los.data[,1]), mod=my.model) [,1] [1,] 1.975314 > > ## now bootstrap > library(boot) Attaching package: 'boot' The following object(s) are masked from package:survival : aml > nb <- 20 ## nb <- 2000 > los.bootstrap <- boot(los.data, clos.for.bstrap, nb, mod=my.model) > sqrt(var(los.bootstrap$t)) [,1] [1,] 1.012948 > > ## compute change in LOS `by hand'; also works for alternative weights > > ## first, get pure event times > my.evtimes <- sort(unique(my.observ$time[my.observ$to !="cens"])) > ## compute daywise difference between expected LOS > my.diffs <- los$e.given.1 - los$e.given.0 > ## restrict to those days when a transition out of the initial state was observed > my.diffs <- my.diffs[is.element(my.evtimes, los$w.times)] > ## compute weighted average, but don't sum up over > ## days where one of the groups (no) IE (yet) experienced was empty. > sum((my.diffs * los$weights)[!(is.element(los$w.times, c(los$empty.0, los$empty.1)))]) [1] 1.975314 > > > > > cleanEx(); ..nameEx <- "los.data" > > ### * los.data > > flush(stderr()); flush(stdout()) > > ### Name: los.data > ### Title: data > ### Aliases: los.data > ### Keywords: datasets > > ### ** Examples > > data(los.data) > > > > cleanEx(); ..nameEx <- "msmodel" > > ### * msmodel > > flush(stderr()); flush(stdout()) > > ### Name: msmodel > ### Title: multi-state model > ### Aliases: msmodel > ### Keywords: models > > ### ** Examples > > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > > > > cleanEx(); ..nameEx <- "plot.aj" > > ### * plot.aj > > flush(stderr()); flush(stdout()) > > ### Name: plot.aj > ### Title: Plot function for objects of class 'aj' > ### Aliases: plot.aj > ### Keywords: hplot > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > my.trans <- trans(model=my.model,observ=my.observ) > my.aj <- aj(my.trans, s=0, t=80) > plot(my.aj,c("0","0","0","0"),c("0","1","2","3")) Time 0 0 0 1 0 2 0 3 [1,] 3 0.882275132 0.017195767 0.08465608 0.01587302 [2,] 4 0.702380952 0.058201058 0.20502646 0.03439153 [3,] 5 0.560846561 0.078042328 0.30026455 0.06084656 [4,] 6 0.461640212 0.084656085 0.37037037 0.08333333 [5,] 7 0.388888889 0.092592593 0.42460317 0.09391534 [6,] 8 0.321428571 0.095238095 0.46825397 0.11507937 [7,] 9 0.265873016 0.093915344 0.51322751 0.12698413 [8,] 10 0.219576720 0.089947090 0.54365079 0.14682540 [9,] 11 0.187830688 0.088624339 0.56084656 0.16269841 [10,] 12 0.164021164 0.082010582 0.58068783 0.17328042 [11,] 13 0.137566138 0.075396825 0.59920635 0.18783069 [12,] 14 0.119047619 0.067460317 0.61507937 0.19841270 [13,] 15 0.112433862 0.063492063 0.62301587 0.20105820 [14,] 16 0.099206349 0.059523810 0.63756614 0.20370370 [15,] 17 0.085978836 0.055555556 0.64814815 0.21031746 [16,] 18 0.070105820 0.051587302 0.66137566 0.21693122 [17,] 19 0.063492063 0.050264550 0.66534392 0.22089947 [18,] 20 0.059523810 0.043650794 0.67328042 0.22354497 [19,] 21 0.052910053 0.042328042 0.67724868 0.22751323 [20,] 22 0.050264550 0.038359788 0.68121693 0.23015873 [21,] 23 0.047619048 0.033068783 0.68518519 0.23412698 [22,] 24 0.043650794 0.033068783 0.68650794 0.23677249 [23,] 25 0.039682540 0.030423280 0.69179894 0.23809524 [24,] 26 0.034391534 0.030423280 0.69576720 0.23941799 [25,] 27 0.031746032 0.030423280 0.69841270 0.23941799 [26,] 28 0.025132275 0.027777778 0.70370370 0.24338624 [27,] 29 0.021164021 0.026455026 0.70899471 0.24338624 [28,] 30 0.018518519 0.025132275 0.71164021 0.24470899 [29,] 31 0.017195767 0.022486772 0.71428571 0.24603175 [30,] 32 0.015873016 0.021164021 0.71693122 0.24603175 [31,] 33 0.014550265 0.022486772 0.71693122 0.24603175 [32,] 34 0.013227513 0.021164021 0.71957672 0.24603175 [33,] 35 0.011904762 0.019841270 0.71957672 0.24867725 [34,] 38 0.009259259 0.019841270 0.72222222 0.24867725 [35,] 39 0.007936508 0.018518519 0.72354497 0.25000000 [36,] 40 0.006613757 0.018518519 0.72486772 0.25000000 [37,] 41 0.006613757 0.015873016 0.72751323 0.25000000 [38,] 42 0.006613757 0.013227513 0.73015873 0.25000000 [39,] 44 0.005291005 0.011904762 0.73280423 0.25000000 [40,] 47 0.005291005 0.010582011 0.73412698 0.25000000 [41,] 50 0.003968254 0.010582011 0.73544974 0.25000000 [42,] 54 0.003968254 0.007936508 0.73677249 0.25132275 [43,] 55 0.003968254 0.005291005 0.73941799 0.25132275 [44,] 61 0.002645503 0.005291005 0.74074074 0.25132275 [45,] 68 0.002645503 0.003968254 0.74206349 0.25132275 [46,] 69 0.001322751 0.002645503 0.74338624 0.25264550 [47,] 74 0.001322751 0.001322751 0.74470899 0.25264550 [48,] 78 0.001322751 0.000000000 0.74603175 0.25264550 > > > > cleanEx(); ..nameEx <- "plot.clos" > > ### * plot.clos > > flush(stderr()); flush(stdout()) > > ### Name: plot.clos > ### Title: Plot function for objects of class 'clos' > ### Aliases: plot.clos > ### Keywords: hplot > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x = los.data) > tra <- matrix(FALSE, 4, 4) > diag(tra) <- TRUE > tra[1, ] <- TRUE > tra[2, 3:4] <- TRUE > my.model <- msmodel(c("0", "1", "2", "3"), tra, cens.name = "cens") > los <- clos(model = my.model, observ = my.observ) Loading required package: survival Loading required package: splines > plot(los, xlim=c(0,80), ylim.1=c(0,120)) > ## same plot with nicer y-axis in the lower graph > plot(los, xlim=c(0,80), ylim.1=c(0,120), lab.1=c(8,6,7)) > > > > cleanEx(); ..nameEx <- "prepare.los.data" > > ### * prepare.los.data > > flush(stderr()); flush(stdout()) > > ### Name: prepare.los.data > ### Title: Prepare the data for clos > ### Aliases: prepare.los.data > ### Keywords: datasets manip > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > > > > cleanEx(); ..nameEx <- "print.aj" > > ### * print.aj > > flush(stderr()); flush(stdout()) > > ### Name: print.aj > ### Title: Print and summary method for objects of class 'aj' > ### Aliases: print.aj summary.aj > ### Keywords: print > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > my.trans <- trans(model=my.model,observ=my.observ) > my.aj <- aj(my.trans,s=0,t=80) > summary(my.aj) The Aalen-Johansen estimator for the transition matrix P(0,80) 0 1 2 3 0 0.001322751 0 0.7460317 0.2526455 1 0.000000000 0 0.7072985 0.2927015 2 0.000000000 0 1.0000000 0.0000000 3 0.000000000 0 0.0000000 1.0000000 > print(my.aj) The Aalen-Johansen estimator for the transition matrix P(0,80) 0 1 2 3 0 0.001322751 0 0.7460317 0.2526455 1 0.000000000 0 0.7072985 0.2927015 2 0.000000000 0 1.0000000 0.0000000 3 0.000000000 0 0.0000000 1.0000000 Time points in the interval (0,80] [1] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [26] 28 29 30 31 32 33 34 35 38 39 40 41 42 44 47 50 54 55 61 68 69 74 78 Estimate of P(0,3) 0 1 2 3 0 0.8822751 0.01719577 0.08465608 0.01587302 1 0.0000000 1.00000000 0.00000000 0.00000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Estimate of P(0,4) 0 1 2 3 0 0.702381 0.05820106 0.2050265 0.03439153 1 0.000000 1.00000000 0.0000000 0.00000000 2 0.000000 0.00000000 1.0000000 0.00000000 3 0.000000 0.00000000 0.0000000 1.00000000 Estimate of P(0,5) 0 1 2 3 0 0.5608466 0.07804233 0.30026455 0.06084656 1 0.0000000 0.97727273 0.02272727 0.00000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Estimate of P(0,6) 0 1 2 3 0 0.4616402 0.08465608 0.37037037 0.08333333 1 0.0000000 0.92758089 0.05585516 0.01656394 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Estimate of P(0,7) 0 1 2 3 0 0.3888889 0.0925926 0.42460317 0.09391534 1 0.0000000 0.8841005 0.07034861 0.04555085 2 0.0000000 0.0000000 1.00000000 0.00000000 3 0.0000000 0.0000000 0.00000000 1.00000000 Estimate of P(0,8) 0 1 2 3 0 0.3214286 0.0952381 0.4682540 0.11507937 1 0.0000000 0.7830605 0.1461287 0.07081086 2 0.0000000 0.0000000 1.0000000 0.00000000 3 0.0000000 0.0000000 0.0000000 1.00000000 Estimate of P(0,9) 0 1 2 3 0 0.265873 0.09391534 0.5132275 0.1269841 1 0.000000 0.71780544 0.1787562 0.1034384 2 0.000000 0.00000000 1.0000000 0.0000000 3 0.000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,10) 0 1 2 3 0 0.2195767 0.08994709 0.5436508 0.1468254 1 0.0000000 0.64703589 0.2191959 0.1337682 2 0.0000000 0.00000000 1.0000000 0.0000000 3 0.0000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,11) 0 1 2 3 0 0.1878307 0.08862434 0.5608466 0.1626984 1 0.0000000 0.59945972 0.2572569 0.1432834 2 0.0000000 0.00000000 1.0000000 0.0000000 3 0.0000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,12) 0 1 2 3 0 0.1640212 0.08201058 0.5806878 0.1732804 1 0.0000000 0.52788244 0.3109398 0.1611777 2 0.0000000 0.00000000 1.0000000 0.0000000 3 0.0000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,13) 0 1 2 3 0 0.1375661 0.07539683 0.5992063 0.1878307 1 0.0000000 0.46828281 0.3535110 0.1782062 2 0.0000000 0.00000000 1.0000000 0.0000000 3 0.0000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,14) 0 1 2 3 0 0.1190476 0.06746032 0.6150794 0.1984127 1 0.0000000 0.41077439 0.3945884 0.1946372 2 0.0000000 0.00000000 1.0000000 0.0000000 3 0.0000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,15) 0 1 2 3 0 0.1124339 0.06349206 0.6230159 0.2010582 1 0.0000000 0.38661119 0.4106972 0.2026916 2 0.0000000 0.00000000 1.0000000 0.0000000 3 0.0000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,16) 0 1 2 3 0 0.09920635 0.05952381 0.6375661 0.2037037 1 0.00000000 0.34633919 0.4429148 0.2107460 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,17) 0 1 2 3 0 0.08597884 0.05555556 0.6481481 0.2103175 1 0.00000000 0.31555349 0.4737005 0.2107460 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,18) 0 1 2 3 0 0.07010582 0.0515873 0.6613757 0.2169312 1 0.00000000 0.2704744 0.5112664 0.2182592 2 0.00000000 0.0000000 1.0000000 0.0000000 3 0.00000000 0.0000000 0.0000000 1.0000000 Estimate of P(0,19) 0 1 2 3 0 0.06349206 0.05026455 0.6653439 0.2208995 1 0.00000000 0.24966869 0.5251369 0.2251944 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,20) 0 1 2 3 0 0.05952381 0.04365079 0.6732804 0.2235450 1 0.00000000 0.21681755 0.5514178 0.2317646 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,21) 0 1 2 3 0 0.05291005 0.04232804 0.6772487 0.2275132 1 0.00000000 0.21024732 0.5579880 0.2317646 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,22) 0 1 2 3 0 0.05026455 0.03835979 0.6812169 0.2301587 1 0.00000000 0.19053664 0.5645583 0.2449051 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,23) 0 1 2 3 0 0.04761905 0.03306878 0.6851852 0.2341270 1 0.00000000 0.16425572 0.5776987 0.2580455 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,24) 0 1 2 3 0 0.04365079 0.03306878 0.6865079 0.2367725 1 0.00000000 0.15768549 0.5776987 0.2646158 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,25) 0 1 2 3 0 0.03968254 0.03042328 0.691799 0.2380952 1 0.00000000 0.13876323 0.596621 0.2646158 2 0.00000000 0.00000000 1.000000 0.0000000 3 0.00000000 0.00000000 0.000000 1.0000000 Estimate of P(0,26) 0 1 2 3 0 0.03439153 0.03042328 0.6957672 0.2394180 1 0.00000000 0.12669686 0.6026542 0.2706490 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,27) 0 1 2 3 0 0.03174603 0.03042328 0.6984127 0.2394180 1 0.00000000 0.12118830 0.6081627 0.2706490 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,28) 0 1 2 3 0 0.02513228 0.02777778 0.7037037 0.2433862 1 0.00000000 0.11065019 0.6134318 0.2759180 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,29) 0 1 2 3 0 0.02116402 0.02645503 0.7089947 0.2433862 1 0.00000000 0.10011208 0.6239699 0.2759180 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,30) 0 1 2 3 0 0.01851852 0.02513228 0.7116402 0.244709 1 0.00000000 0.09510647 0.6289755 0.275918 2 0.00000000 0.00000000 1.0000000 0.000000 3 0.00000000 0.00000000 0.0000000 1.000000 Estimate of P(0,31) 0 1 2 3 0 0.01719577 0.02248677 0.7142857 0.2460317 1 0.00000000 0.08509527 0.6389867 0.2759180 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,32) 0 1 2 3 0 0.01587302 0.02116402 0.7169312 0.2460317 1 0.00000000 0.08008966 0.6439923 0.2759180 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,33) 0 1 2 3 0 0.01455026 0.02248677 0.7169312 0.2460317 1 0.00000000 0.08008966 0.6439923 0.2759180 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,34) 0 1 2 3 0 0.01322751 0.02116402 0.7195767 0.2460317 1 0.00000000 0.07066735 0.6534146 0.2759180 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,35) 0 1 2 3 0 0.01190476 0.01984127 0.7195767 0.2486772 1 0.00000000 0.06183393 0.6534146 0.2847514 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,38) 0 1 2 3 0 0.00925926 0.01984127 0.7222222 0.2486772 1 0.00000000 0.06183393 0.6534146 0.2847514 2 0.00000000 0.00000000 1.0000000 0.0000000 3 0.00000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,39) 0 1 2 3 0 0.007936508 0.01851852 0.7235450 0.2500000 1 0.000000000 0.05771167 0.6534146 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,40) 0 1 2 3 0 0.006613757 0.01851852 0.7248677 0.2500000 1 0.000000000 0.05358941 0.6575369 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,41) 0 1 2 3 0 0.006613757 0.01587302 0.7275132 0.2500000 1 0.000000000 0.04593378 0.6651925 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,42) 0 1 2 3 0 0.006613757 0.01322751 0.7301587 0.2500000 1 0.000000000 0.03827815 0.6728482 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,44) 0 1 2 3 0 0.005291005 0.01190476 0.7328042 0.2500000 1 0.000000000 0.03445033 0.6766760 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,47) 0 1 2 3 0 0.005291005 0.01058201 0.7341270 0.2500000 1 0.000000000 0.03062252 0.6805038 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,50) 0 1 2 3 0 0.003968254 0.01058201 0.7354497 0.2500000 1 0.000000000 0.03062252 0.6805038 0.2888737 2 0.000000000 0.00000000 1.0000000 0.0000000 3 0.000000000 0.00000000 0.0000000 1.0000000 Estimate of P(0,54) 0 1 2 3 0 0.003968254 0.007936508 0.7367725 0.2513228 1 0.000000000 0.022966888 0.6843316 0.2927015 2 0.000000000 0.000000000 1.0000000 0.0000000 3 0.000000000 0.000000000 0.0000000 1.0000000 Estimate of P(0,55) 0 1 2 3 0 0.003968254 0.005291005 0.7394180 0.2513228 1 0.000000000 0.015311259 0.6919872 0.2927015 2 0.000000000 0.000000000 1.0000000 0.0000000 3 0.000000000 0.000000000 0.0000000 1.0000000 Estimate of P(0,61) 0 1 2 3 0 0.002645503 0.005291005 0.7407407 0.2513228 1 0.000000000 0.015311259 0.6919872 0.2927015 2 0.000000000 0.000000000 1.0000000 0.0000000 3 0.000000000 0.000000000 0.0000000 1.0000000 Estimate of P(0,68) 0 1 2 3 0 0.002645503 0.003968254 0.7420635 0.2513228 1 0.000000000 0.011483444 0.6958150 0.2927015 2 0.000000000 0.000000000 1.0000000 0.0000000 3 0.000000000 0.000000000 0.0000000 1.0000000 Estimate of P(0,69) 0 1 2 3 0 0.001322751 0.002645503 0.7433862 0.2526455 1 0.000000000 0.007655629 0.6996429 0.2927015 2 0.000000000 0.000000000 1.0000000 0.0000000 3 0.000000000 0.000000000 0.0000000 1.0000000 Estimate of P(0,74) 0 1 2 3 0 0.001322751 0.001322751 0.7447090 0.2526455 1 0.000000000 0.003827815 0.7034707 0.2927015 2 0.000000000 0.000000000 1.0000000 0.0000000 3 0.000000000 0.000000000 0.0000000 1.0000000 Estimate of P(0,78) 0 1 2 3 0 0.001322751 0 0.7460317 0.2526455 1 0.000000000 0 0.7072985 0.2927015 2 0.000000000 0 1.0000000 0.0000000 3 0.000000000 0 0.0000000 1.0000000 > > > > cleanEx(); ..nameEx <- "print.clos" > > ### * print.clos > > flush(stderr()); flush(stdout()) > > ### Name: print.clos > ### Title: Print method for objects of class 'clos' > ### Aliases: print.clos > ### Keywords: print > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > trans <- matrix(FALSE,4,4) > diag(trans) <- TRUE > trans[1,] <- TRUE > trans[2,3:4] <- TRUE > my.model <- msmodel(c("0","1","2","3"),trans,cens.name="cens") > los <- clos(model=my.model,observ=my.observ) Loading required package: survival Loading required package: splines > print(los) Change in LOS: 1.975314 Total % Number of observed patients 756 100.00 Number of patients being discharged 565 74.74 Number of patients who die 191 25.26 Number of patients being censored 0 0.00 Number of patients who experienced the intermediate event(IE) 124 16.40 Number of patients who experienced the IE being discharged 90 11.90 Number of patients who experienced the IE and died 34 4.50 Number of patients who experienced the IE and were censored 0 0.00 Time points: [1] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [26] 28 29 30 31 32 33 34 35 38 39 40 41 42 44 47 50 54 55 61 68 69 74 78 82 Estimates given in state 1: [1] 16.54583 16.54583 16.81433 17.39367 17.90484 19.18288 20.10860 21.21422 [9] 22.02488 23.38418 24.70581 26.20462 26.90491 28.17292 29.26296 31.14012 [17] 32.15180 33.99298 34.39901 35.68167 37.71073 38.28201 40.09320 41.43541 [25] 42.09156 43.43361 44.95294 45.73994 47.47405 48.44118 48.44118 50.36667 [33] 52.56190 52.56190 53.53061 54.57143 56.83333 59.80000 61.55556 63.37500 [41] 63.37500 66.50000 72.25000 72.25000 73.66667 76.00000 78.00000 NA [49] NA Estimates given in state 0: [1] 11.28321 12.41617 13.84187 15.26592 16.47844 17.79767 19.35965 21.06285 [9] 22.45305 23.69501 25.52663 27.18405 27.90076 29.16291 30.84547 33.01010 [17] 33.92149 34.84959 36.58079 37.34820 38.14532 38.99848 39.89522 40.84560 [25] 41.37059 44.88916 46.87132 49.28151 50.68778 52.24510 52.59091 52.81333 [33] 52.84127 57.08163 60.09524 61.20000 61.20000 61.20000 65.50000 65.50000 [41] 70.66667 70.66667 70.66667 75.50000 75.50000 82.00000 82.00000 82.00000 [49] NA the group `intermediate, but no terminal event yet' was empty for the following event times: [1] 78 82 the group `no intermediate or terminal event yet' was empty for the following event times: [1] 82 No comparison between groups was possible at these time points. Change in LOS associated with the intermediate event acquired up to such a time point was set to 0. Weights for the weighted average: [1] 0.117724868 0.179894180 0.141534392 0.099206349 0.072751323 0.067460317 [7] 0.055555556 0.046296296 0.031746032 0.023809524 0.026455026 0.018518519 [13] 0.006613757 0.013227513 0.013227513 0.015873016 0.006613757 0.003968254 [19] 0.006613757 0.002645503 0.002645503 0.003968254 0.003968254 0.005291005 [25] 0.002645503 0.006613757 0.003968254 0.002645503 0.001322751 0.001322751 [31] 0.001322751 0.001322751 0.001322751 0.002645503 0.001322751 0.001322751 [37] 0.001322751 0.001322751 0.001322751 0.001322751 0.001322751 Transition matrix for time point nr. 1: 3 0 1 2 3 0 0.8822751 0.01719577 0.08465608 0.01587302 1 0.0000000 1.00000000 0.00000000 0.00000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 2: 4 0 1 2 3 0 0.796102 0.04647676 0.1364318 0.02098951 1 0.000000 1.00000000 0.0000000 0.00000000 2 0.000000 0.00000000 1.0000000 0.00000000 3 0.000000 0.00000000 0.0000000 1.00000000 Transition matrix for time point nr. 3: 5 0 1 2 3 0 0.7984934 0.03013183 0.13370998 0.03766478 1 0.0000000 0.97727273 0.02272727 0.00000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 4: 6 0 1 2 3 0 0.8231132 0.01886792 0.12028302 0.03773585 1 0.0000000 0.94915254 0.03389831 0.01694915 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 5: 7 0 1 2 3 0 0.8424069 0.02578797 0.1146132 0.01719198 1 0.0000000 0.95312500 0.0156250 0.03125000 2 0.0000000 0.00000000 1.0000000 0.00000000 3 0.0000000 0.00000000 0.0000000 1.00000000 Transition matrix for time point nr. 6: 8 0 1 2 3 0 0.8265306 0.03401361 0.09183673 0.04761905 1 0.0000000 0.88571429 0.08571429 0.02857143 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 7: 9 0 1 2 3 0 0.8271605 0.02057613 0.12757202 0.02469136 1 0.0000000 0.91666667 0.04166667 0.04166667 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 8: 10 0 1 2 3 0 0.8258706 0.01990050 0.09452736 0.05970149 1 0.0000000 0.90140845 0.05633803 0.04225352 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 9: 11 0 1 2 3 0 0.8554217 0.02409639 0.05421687 0.06626506 1 0.0000000 0.92647059 0.05882353 0.01470588 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 10: 12 0 1 2 3 0 0.8732394 0.02112676 0.06338028 0.04225352 1 0.0000000 0.88059701 0.08955224 0.02985075 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 11: 13 0 1 2 3 0 0.8387097 0.01612903 0.07258065 0.07258065 1 0.0000000 0.88709677 0.08064516 0.03225806 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 12: 14 0 1 2 3 0 0.8653846 0.009615385 0.06730769 0.05769231 1 0.0000000 0.877192982 0.08771930 0.03508772 2 0.0000000 0.000000000 1.00000000 0.00000000 3 0.0000000 0.000000000 0.00000000 1.00000000 Transition matrix for time point nr. 13: 15 0 1 2 3 0 0.9444444 0.0000000 0.04444444 0.01111111 1 0.0000000 0.9411765 0.03921569 0.01960784 2 0.0000000 0.0000000 1.00000000 0.00000000 3 0.0000000 0.0000000 0.00000000 1.00000000 Transition matrix for time point nr. 14: 16 0 1 2 3 0 0.882353 0.02352941 0.08235294 0.01176471 1 0.000000 0.89583333 0.08333333 0.02083333 2 0.000000 0.00000000 1.00000000 0.00000000 3 0.000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 15: 17 0 1 2 3 0 0.8666667 0.01333333 0.05333333 0.06666667 1 0.0000000 0.91111111 0.08888889 0.00000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 16: 18 0 1 2 3 0 0.8153846 0.04615385 0.07692308 0.06153846 1 0.0000000 0.85714286 0.11904762 0.02380952 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 17: 19 0 1 2 3 0 0.9056604 0.03773585 0.01886792 0.03773585 1 0.0000000 0.92307692 0.05128205 0.02564103 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 18: 20 0 1 2 3 0 0.9375 0.000000 0.04166667 0.02083333 1 0.0000 0.868421 0.10526316 0.02631579 2 0.0000 0.000000 1.00000000 0.00000000 3 0.0000 0.000000 0.00000000 1.00000000 Transition matrix for time point nr. 19: 21 0 1 2 3 0 0.8888889 0.000000 0.04444444 0.06666667 1 0.0000000 0.969697 0.03030303 0.00000000 2 0.0000000 0.000000 1.00000000 0.00000000 3 0.0000000 0.000000 0.00000000 1.00000000 Transition matrix for time point nr. 20: 22 0 1 2 3 0 0.95 0.00000 0.05000 0.0000 1 0.00 0.90625 0.03125 0.0625 2 0.00 0.00000 1.00000 0.0000 3 0.00 0.00000 0.00000 1.0000 Transition matrix for time point nr. 21: 23 0 1 2 3 0 0.9473684 0.000000 0.02631579 0.02631579 1 0.0000000 0.862069 0.06896552 0.06896552 2 0.0000000 0.000000 1.00000000 0.00000000 3 0.0000000 0.000000 0.00000000 1.00000000 Transition matrix for time point nr. 22: 24 0 1 2 3 0 0.9166667 0.02777778 0.02777778 0.02777778 1 0.0000000 0.96000000 0.00000000 0.04000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 23: 25 0 1 2 3 0 0.9090909 0.03030303 0.03030303 0.03030303 1 0.0000000 0.88000000 0.12000000 0.00000000 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 24: 26 0 1 2 3 0 0.8666667 0.06666667 0.06666667 0.00000000 1 0.0000000 0.91304348 0.04347826 0.04347826 2 0.0000000 0.00000000 1.00000000 0.00000000 3 0.0000000 0.00000000 0.00000000 1.00000000 Transition matrix for time point nr. 25: 27 0 1 2 3 0 0.923077 0.03846154 0.03846154 0 1 0.000000 0.95652174 0.04347826 0 2 0.000000 0.00000000 1.00000000 0 3 0.000000 0.00000000 0.00000000 1 Transition matrix for time point nr. 26: 28 0 1 2 3 0 0.7916667 0.0000000 0.12500000 0.08333333 1 0.0000000 0.9130435 0.04347826 0.04347826 2 0.0000000 0.0000000 1.00000000 0.00000000 3 0.0000000 0.0000000 0.00000000 1.00000000 Transition matrix for time point nr. 27: 29 0 1 2 3 0 0.8421053 0.05263158 0.1052632 0 1 0.0000000 0.90476190 0.0952381 0 2 0.0000000 0.00000000 1.0000000 0 3 0.0000000 0.00000000 0.0000000 1 Transition matrix for time point nr. 28: 30 0 1 2 3 0 0.875 0.00 0.0625 0.0625 1 0.000 0.95 0.0500 0.0000 2 0.000 0.00 1.0000 0.0000 3 0.000 0.00 0.0000 1.0000 Transition matrix for time point nr. 29: 31 0 1 2 3 0 0.9285714 0.0000000 0.0000000 0.07142857 1 0.0000000 0.8947368 0.1052632 0.00000000 2 0.0000000 0.0000000 1.0000000 0.00000000 3 0.0000000 0.0000000 0.0000000 1.00000000 Transition matrix for time point nr. 30: 32 0 1 2 3 0 0.923077 0.0000000 0.07692308 0 1 0.000000 0.9411765 0.05882353 0 2 0.000000 0.0000000 1.00000000 0 3 0.000000 0.0000000 0.00000000 1 Transition matrix for time point nr. 31: 33 0 1 2 3 0 0.9166667 0.08333333 0 0 1 0.0000000 1.00000000 0 0 2 0.0000000 0.00000000 1 0 3 0.0000000 0.00000000 0 1 Transition matrix for time point nr. 32: 34 0 1 2 3 0 0.9090909 0.0909091 0.0000000 0 1 0.0000000 0.8823529 0.1176471 0 2 0.0000000 0.0000000 1.0000000 0 3 0.0000000 0.0000000 0.0000000 1 Transition matrix for time point nr. 33: 35 0 1 2 3 0 0.9 0.100 0 0.000 1 0.0 0.875 0 0.125 2 0.0 0.000 1 0.000 3 0.0 0.000 0 1.000 Transition matrix for time point nr. 34: 38 0 1 2 3 0 0.7777778 0 0.2222222 0 1 0.0000000 1 0.0000000 0 2 0.0000000 0 1.0000000 0 3 0.0000000 0 0.0000000 1 Transition matrix for time point nr. 35: 39 0 1 2 3 0 0.8571429 0.0000000 0.1428571 0.00000000 1 0.0000000 0.9333333 0.0000000 0.06666667 2 0.0000000 0.0000000 1.0000000 0.00000000 3 0.0000000 0.0000000 0.0000000 1.00000000 Transition matrix for time point nr. 36: 40 0 1 2 3 0 0.8333333 0.1666667 0.00000000 0 1 0.0000000 0.9285714 0.07142857 0 2 0.0000000 0.0000000 1.00000000 0 3 0.0000000 0.0000000 0.00000000 1 Transition matrix for time point nr. 37: 41 0 1 2 3 0 1 0.0000000 0.0000000 0 1 0 0.8571429 0.1428571 0 2 0 0.0000000 1.0000000 0 3 0 0.0000000 0.0000000 1 Transition matrix for time point nr. 38: 42 0 1 2 3 0 1 0.0000000 0.0000000 0 1 0 0.8333333 0.1666667 0 2 0 0.0000000 1.0000000 0 3 0 0.0000000 0.0000000 1 Transition matrix for time point nr. 39: 44 0 1 2 3 0 0.8 0.0 0.2 0 1 0.0 0.9 0.1 0 2 0.0 0.0 1.0 0 3 0.0 0.0 0.0 1 Transition matrix for time point nr. 40: 47 0 1 2 3 0 1 0.0000000 0.0000000 0 1 0 0.8888889 0.1111111 0 2 0 0.0000000 1.0000000 0 3 0 0.0000000 0.0000000 1 Transition matrix for time point nr. 41: 50 0 1 2 3 0 0.75 0 0.25 0 1 0.00 1 0.00 0 2 0.00 0 1.00 0 3 0.00 0 0.00 1 Transition matrix for time point nr. 42: 54 0 1 2 3 0 1 0.00 0.000 0.000 1 0 0.75 0.125 0.125 2 0 0.00 1.000 0.000 3 0 0.00 0.000 1.000 Transition matrix for time point nr. 43: 55 0 1 2 3 0 1 0.0000000 0.0000000 0 1 0 0.6666667 0.3333333 0 2 0 0.0000000 1.0000000 0 3 0 0.0000000 0.0000000 1 Transition matrix for time point nr. 44: 61 0 1 2 3 0 0.6666667 0 0.3333333 0 1 0.0000000 1 0.0000000 0 2 0.0000000 0 1.0000000 0 3 0.0000000 0 0.0000000 1 Transition matrix for time point nr. 45: 68 0 1 2 3 0 1 0.00 0.00 0 1 0 0.75 0.25 0 2 0 0.00 1.00 0 3 0 0.00 0.00 1 Transition matrix for time point nr. 46: 69 0 1 2 3 0 0.5 0.0000000 0.0000000 0.5 1 0.0 0.6666667 0.3333333 0.0 2 0.0 0.0000000 1.0000000 0.0 3 0.0 0.0000000 0.0000000 1.0 Transition matrix for time point nr. 47: 74 0 1 2 3 0 1 0.0 0.0 0 1 0 0.5 0.5 0 2 0 0.0 1.0 0 3 0 0.0 0.0 1 Transition matrix for time point nr. 48: 78 0 1 2 3 0 1 0 0 0 1 0 0 1 0 2 0 0 1 0 3 0 0 0 1 Transition matrix for time point nr. 49: 82 0 1 2 3 0 0 0 1 0 1 0 1 0 0 2 0 0 1 0 3 0 0 0 1 The function 'clos' was called: clos(model = my.model, observ = my.observ) > > > > cleanEx(); ..nameEx <- "print.msmodel" > > ### * print.msmodel > > flush(stderr()); flush(stdout()) > > ### Name: print.msmodel > ### Title: Print and summary method for objects of class 'msmodel' > ### Aliases: summary.msmodel print.msmodel > ### Keywords: print > > ### ** Examples > > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > summary(my.model) 4-state model states (internal representation): 1, 2, 3, 4 names of the states: '0', '1', '2', '3' > print(my.model) 4-state model states (internal representation): 1, 2, 3, 4 names of the states: '0', '1', '2', '3' transient states: '0', '1', '2', '3' absorbing states: none censored observations may occurr in states: '0', '1', '2', '3' name of censoring code: 'cens' (internal representation is: 5) the possibles transitions: from to 1 "0" "1" 2 "0" "2" 3 "0" "3" 4 "1" "0" 5 "1" "2" 6 "1" "3" 7 "2" "0" 8 "2" "1" 9 "2" "3" 10 "3" "0" 11 "3" "1" 12 "3" "2" > > > > cleanEx(); ..nameEx <- "print.trans" > > ### * print.trans > > flush(stderr()); flush(stdout()) > > ### Name: print.trans > ### Title: Print method for objects of class 'trans' > ### Aliases: print.trans > ### Keywords: print > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > my.trans <- trans(model=my.model,observ=my.observ) > summary(my.trans) Total number of transitions: from to transitions 0 1 124 0 2 475 0 3 157 1 0 0 1 2 90 1 3 34 2 0 0 2 1 0 2 3 0 3 0 0 3 1 0 3 2 0 the initial distribution: 756 in state '0' 0 in state '1' 0 in state '2' 0 in state '3' > > > > cleanEx(); ..nameEx <- "read.los.data" > > ### * read.los.data > > flush(stderr()); flush(stdout()) > > ### Name: read.los.data > ### Title: Read the data for clos > ### Aliases: read.los.data > ### Keywords: file datasets > > ### ** Examples > > ## los.data <- read.los.data("los.data.txt",pos.id=1,pos.columns=c(2,3,4,5,6,7)) > ## Results in the same data frame as: > data(los.data) > > > > cleanEx(); ..nameEx <- "summary.clos" > > ### * summary.clos > > flush(stderr()); flush(stdout()) > > ### Name: summary.clos > ### Title: Summary method for objects of class 'clos' > ### Aliases: summary.clos print.summary.clos > ### Keywords: print > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > trans <- matrix(FALSE,4,4) > diag(trans) <- TRUE > trans[1,] <- TRUE > trans[2,3:4] <- TRUE > my.model <- msmodel(c("0","1","2","3"),trans,cens.name="cens") > los <- clos(model=my.model,observ=my.observ) Loading required package: survival Loading required package: splines > summary(los) Change in LOS: 1.975314 Total % Number of observed patients 756 100.00 Number of patients being discharged 565 74.74 Number of patients who die 191 25.26 Number of patients being censored 0 0.00 Number of patients who experienced the intermediate event(IE) 124 16.40 Number of patients who experienced the IE being discharged 90 11.90 Number of patients who experienced the IE and died 34 4.50 Number of patients who experienced the IE and were censored 0 0.00 > > > > cleanEx(); ..nameEx <- "summary.trans" > > ### * summary.trans > > flush(stderr()); flush(stdout()) > > ### Name: summary.trans > ### Title: Summary method for objects of class 'trans' > ### Aliases: summary.trans print.summary.trans > ### Keywords: print > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > my.trans <- trans(model=my.model,observ=my.observ) > summary(my.trans) Total number of transitions: from to transitions 0 1 124 0 2 475 0 3 157 1 0 0 1 2 90 1 3 34 2 0 0 2 1 0 2 3 0 3 0 0 3 1 0 3 2 0 the initial distribution: 756 in state '0' 0 in state '1' 0 in state '2' 0 in state '3' > > > > cleanEx(); ..nameEx <- "trans" > > ### * trans > > flush(stderr()); flush(stdout()) > > ### Name: trans > ### Title: transition matrices > ### Aliases: trans > ### Keywords: models > > ### ** Examples > > data(los.data) > my.observ <- prepare.los.data(x=los.data) > my.model <- msmodel(c("0","1","2","3"),cens.name="cens") > my.trans <- trans(model=my.model,observ=my.observ) > my.matrices <- my.trans$matrices > my.times <- my.trans$times > > > > ### *