install.packages("devtools")
library(devtools)
install_github("jinseob2kim/jskm")
library(jskm)
#Load dataset
library(survival)
data(colon)
#> Warning in data(colon): data set 'colon' not found
<- survfit(Surv(time,status)~rx, data=colon)
fit
#Plot the data
jskm(fit)
jskm(fit, table = T, pval = T, label.nrisk = "No. at risk", size.label.nrisk = 8,
xlabs = "Time(Day)", ylabs = "Survival", ystratalabs = c("Obs", "Lev", "Lev + 5FU"), ystrataname = "rx",
marks = F, timeby = 365, xlims = c(0, 3000), ylims = c(0.25, 1), showpercent = T)
#> Warning: Removed 16 row(s) containing missing values (geom_path).
#> Warning: Removed 3 rows containing missing values (geom_text).
jskm(fit, ci = T, cumhaz = T, mark = F, ylab = "Cumulative incidence (%)", surv.scale = "percent", pval =T, pval.size = 6, pval.coord = c(300, 0.7))
jskm(fit, mark = F, surv.scale = "percent", pval =T, table = T, cut.landmark = 500, showpercent = T)
svykm.object
in survey packagelibrary(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
data(pbc, package="survival")
$randomized <- with(pbc, !is.na(trt) & trt>0)
pbc<- glm(randomized~age*edema,data=pbc)
biasmodel $randprob <- fitted(biasmodel)
pbc
<-svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
dpbc
<-svykm(Surv(time,status>0) ~ 1, design = dpbc)
s1 <-svykm(Surv(time,status>0) ~ sex, design = dpbc)
s2
svyjskm(s1)
svyjskm(s2)
svyjskm(s2, cumhaz = T, ylab = "Cumulative incidence(%)", surv.scale = "percent", showpercent = T)
If you want to get confidence interval, you should apply se = T
option to svykm
object.
<- svykm(Surv(time,status>0) ~ sex, design=dpbc, se = T)
s3 svyjskm(s3)
svyjskm(s3, ci = F, showpercent = T)
svyjskm(s3, ci = F, surv.scale = "percent", pval = T, table = T, cut.landmark = 1000)