How do I remove the confidence interval dotted lines from the plot?
For the legend, why is line 2 dotted while line 1 is solid? Is there a way to make both solid lines? I'm not sure what this code does - lty=1:2, cex=0.8
I have attached one of my datasets below with the corresponding commands. Thanks!
> km2 <- survfit(Surv(times_start, times_end, type="interval2")~ 1)
> summary(km2)
Call: survfit(formula = Surv(times_start, times_end, type = "interval2") ~
1)
time n.risk n.event survival std.err lower 95% CI upper 95% CI
1.31 284.0 2.04 0.993 0.00743 0.9782 1.000
2.06 282.0 1.03 0.989 0.00856 0.9724 1.000
2.81 280.9 4.18 0.974 0.01770 0.9395 1.000
3.56 276.7 2.10 0.967 0.01977 0.9278 1.000
4.31 274.7 8.42 0.937 0.03557 0.8659 1.000
5.06 266.2 2.11 0.930 0.03678 0.8556 1.000
5.81 264.1 13.79 0.881 0.05659 0.7642 1.000
6.38 250.3 4.24 0.867 0.05838 0.7440 1.000
7.12 246.1 9.55 0.833 0.06455 0.6940 1.000
7.88 236.5 7.43 0.807 0.06785 0.6577 0.990
8.62 229.1 3.18 0.796 0.06866 0.6432 0.984
9.38 225.9 9.55 0.762 0.07262 0.5963 0.974
10.12 216.4 4.24 0.747 0.07355 0.5769 0.967
10.88 212.1 18.03 0.683 0.08015 0.4883 0.957
11.62 194.1 2.12 0.676 0.08017 0.4793 0.953
12.56 192.0 8.68 0.645 0.08074 0.4415 0.944
13.31 183.3 3.33 0.634 0.08069 0.4274 0.940
14.06 180.0 13.67 0.586 0.08082 0.3690 0.929
14.81 166.3 2.34 0.577 0.08058 0.3595 0.927
15.56 164.0 10.33 0.541 0.07952 0.3176 0.921
16.31 153.6 4.35 0.526 0.07886 0.3005 0.920
17.06 149.3 3.32 0.514 0.07831 0.2875 0.919
17.81 146.0 3.89 0.500 0.07761 0.2724 0.919
18.56 142.1 2.25 0.492 0.07718 0.2638 0.919
19.31 139.8 5.37 0.473 0.07605 0.2435 0.921
20.06 134.5 3.36 0.462 0.07530 0.2309 0.923
20.81 131.1 9.03 0.430 0.07291 0.1983 0.932
21.56 122.1 5.54 0.410 0.07128 0.1790 0.941
23.81 116.5 19.40 0.342 0.06341 0.1182 0.990
24.56 97.1 24.24 0.257 0.05029 0.0575 1.000
5013.31 72.9 72.88 0.000 0.00000 NA NA
> plot(km, xmax=50, xlab="Time", ylab="Log cumulative hazard", col="blue", fun="cloglog")
> lines(km2, xlab="Time", ylab="Log cumulative hazard", col="red", fun="cloglog")
> legend("topleft", legend=c("Line 1", "Line 2"), col=c("red", "blue"), lty=1:2, cex=0.8)
I'm not sure which data you're using, but I did this using lung
(which should be available after doing library(survival)
):
km2 <- survfit(Surv(time, status) ~ 1, data = lung)
plot(km2, xmax=50, xlab="Time",
ylab="Log cumulative hazard",
col="blue", fun="cloglog", conf.int = FALSE)
So for your example you should be able to add conf.int = FALSE
to your plot
function to remove the confidence intervals?
The lty=1:2
in your code means that one line is solid (1
) and the other is dotted (2
). I believe solid is default, so you should remove lty=1:2
if you'd like both to be solid.