Created
May 14, 2020 20:38
-
-
Save dwoll/dda5f2b52af90d6de016744a915ca91a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(survival) | |
##---------- | |
## example 1 | |
set.seed(123) | |
group <- factor(rep(LETTERS[1:2], each=100)) | |
Xbeta <- c(-1, 1)[unclass(group)] + rnorm(200, 0, 2) | |
weibA <- 1.5 | |
weibB <- 100 | |
U <- runif(200, 0, 1) | |
dat1 <- data.frame(tobs=ceiling((-log(U)*weibB*exp(-Xbeta))^(1/weibA)), | |
status=1, group=group) | |
fit1 <- survfit(Surv(tobs, status) ~ group, type="kaplan-meier", data=dat1) | |
## error | |
summary(fit1, times=2000) | |
##---------- | |
## example 2 | |
text <- 'tobs status group | |
1.18 1 B | |
1.15 1 B | |
0.20 1 A | |
0.08 1 A | |
0.27 0 A | |
0.02 0 B | |
1.09 0 A | |
0.80 0 B | |
0.63 0 B | |
0.67 1 B | |
0.10 1 B | |
0.30 1 A | |
1.03 1 B | |
0.18 1 B | |
0.12 0 A | |
0.38 0 A | |
0.74 1 B | |
0.09 1 A | |
1.95 1 B | |
0.75 1 A | |
0.10 1 A | |
0.10 1 A | |
0.15 1 A | |
0.08 1 A | |
0.34 1 B | |
2.43 1 B | |
0.45 1 B | |
0.09 1 A | |
0.41 1 A | |
0.21 1 A | |
0.44 1 B | |
0.02 1 A | |
0.12 1 A | |
0.28 1 A | |
0.02 1 A | |
1.26 1 B | |
0.15 1 A | |
0.41 1 A | |
0.05 1 A | |
7.08 1 B | |
0.32 1 A | |
1.32 1 B | |
0.74 1 B | |
0.04 1 A | |
0.76 1 B | |
0.03 1 A | |
0.23 1 A | |
1.19 1 B | |
1.47 0 B | |
0.54 1 A | |
0.59 1 A | |
1.02 0 B | |
0.15 1 A | |
0.12 1 A | |
0.40 1 A | |
0.60 1 B | |
0.32 1 A | |
0.37 1 A | |
1.54 1 B | |
0.18 1 B | |
1.03 0 B | |
1.43 0 B | |
0.75 0 B | |
0.04 1 A | |
1.98 1 A | |
1.00 1 B' | |
dat2 <- read.table(text=text, header=TRUE) | |
fit2 <- survfit(Surv(tobs, status) ~ group, data=dat2) | |
## result in different errors | |
summary(fit2, times=6) | |
summary(fit2, times=c(3, 6)) | |
## sessionInfo() | |
## > sessionInfo() | |
## R version 4.0.0 (2020-04-24) | |
## Platform: x86_64-w64-mingw32/x64 (64-bit) | |
## Running under: Windows 10 x64 (build 18362) | |
## | |
## Matrix products: default | |
## | |
## locale: | |
## [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 | |
## [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C | |
## [5] LC_TIME=German_Germany.1252 | |
## | |
## attached base packages: | |
## [1] stats graphics grDevices utils datasets methods base | |
## | |
## other attached packages: | |
## [1] survival_3.2-2 | |
## | |
## loaded via a namespace (and not attached): | |
## [1] compiler_4.0.0 Matrix_1.2-18 splines_4.0.0 grid_4.0.0 | |
## [5] lattice_0.20-41 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment