I am trying to plot a survival curve with interval censor data. I have been able to successfully plot the survival curve using the interval censor data (shown below), although I am not sure if I coded the events right, such as if I should even use 1?
Here is the code I used to generate the survival curve.
simafit <- survfit(Surv(Time1, Time2, Event, type = c('interval')) ~
Treatment, data = sima)
ggsurvplot(simafit, conf.int = TRUE,
legend.labs=c("Control","Drought","Water+"), ggtheme = theme_bw(),
legend.title = "Treatment", title ="Sidalcea malviflora", palette =
c("gray47","orangered","deepskyblue"),xlim=c(0,838), ylim=c(0,1), xlab="Days
Since Planting")+scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0))
Next I am trying to use the survreg
function to test for differences between treatments and get p-values.
Here is my code:
survreg(Surv(Time1d, Time2d, Event, type = c('interval')) ~ Treatment,
dist="weibull", data = sima)
but I keep getting the error:
Error in survreg(Surv(Time1d, Time2d, Event, type = c("interval")) ~ Treatment, :
Invalid survival times for this distribution
I originally tried with Time1 and Time2 but then I read that 0s don't work in the function so I made an extra copy to test. I've tried presenting the data in many different ways but I can't find any that work with survreg
but this format worked well with ggsurvplot
, but maybe the format needs to be different for the two functions?
I'd appreciate any help, thanks ahead of time.
Here is the data:
Plot ID Subplot Treatment Column Row Species Time1 Time2 Event Time1d Time2d
PS1 1 shelter A 7 SIMA Inf 0 0 1 1
PS1 2 shelter C 2 SIMA Inf 0 0 1 1
PS1 3 shelter D 2 SIMA Inf 0 0 1 1
PS2 1 shelter A 7 SIMA Inf 0 0 1 1
PS2 2 shelter C 2 SIMA Inf 0 0 1 1
PS2 3 shelter D 2 SIMA Inf 0 0 1 1
PS3 1 shelter A 7 SIMA Inf 0 0 1 1
PS3 2 shelter C 2 SIMA Inf 0 0 1 1
PS3 3 shelter D 2 SIMA Inf 0 0 1 1
PS4 1 shelter A 7 SIMA Inf 0 0 1 1
PS4 2 shelter C 2 SIMA Inf 0 0 1 1
PS4 3 shelter D 2 SIMA Inf 0 0 1 1
PS5 1 shelter A 7 SIMA Inf 0 0 1 1
PS5 2 shelter C 2 SIMA Inf 0 0 1 1
PS5 3 shelter D 2 SIMA Inf 0 0 1 1
PC1 1 control A 7 SIMA Inf 0 0 1 1
PC1 2 control C 2 SIMA Inf 0 0 1 1
PC1 3 control D 2 SIMA Inf 0 0 1 1
PC2 1 control A 7 SIMA Inf 0 0 1 1
PC2 2 control C 2 SIMA Inf 0 0 1 1
PC2 3 control D 2 SIMA Inf 0 0 1 1
PC3 1 control A 7 SIMA Inf 0 0 1 1
PC3 2 control C 2 SIMA Inf 0 0 1 1
PC3 3 control D 2 SIMA Inf 0 0 1 1
PC4 1 control A 7 SIMA Inf 0 0 1 1
PC4 2 control C 2 SIMA Inf 0 0 1 1
PC4 3 control D 2 SIMA Inf 0 0 1 1
PC5 1 control A 7 SIMA Inf 0 0 1 1
PC5 2 control C 2 SIMA Inf 0 0 1 1
PC5 3 control D 2 SIMA Inf 0 0 1 1
PW1 1 watered A 7 SIMA Inf 0 0 1 1
PW1 2 watered C 2 SIMA Inf 0 0 1 1
PW1 3 watered D 2 SIMA Inf 0 0 1 1
PW2 1 watered A 7 SIMA Inf 0 0 1 1
PW2 2 watered C 2 SIMA Inf 0 0 1 1
PW2 3 watered D 2 SIMA Inf 0 0 1 1
PW3 1 watered A 7 SIMA Inf 0 0 1 1
PW3 2 watered C 2 SIMA Inf 0 0 1 1
PW3 3 watered D 2 SIMA Inf 0 0 1 1
PW4 1 watered A 7 SIMA Inf 0 0 1 1
PW4 2 watered C 2 SIMA Inf 0 0 1 1
PW4 3 watered D 2 SIMA Inf 0 0 1 1
PW5 1 watered A 7 SIMA Inf 0 0 1 1
PW5 2 watered C 2 SIMA Inf 0 0 1 1
PW5 3 watered D 2 SIMA Inf 0 0 1 1
PS1 1 shelter A 7 SIMA 0 26 0 1 26
PS1 2 shelter C 2 SIMA 0 26 0 1 26
PS1 3 shelter D 2 SIMA 0 26 0 1 26
PS2 1 shelter A 7 SIMA 0 26 0 1 26
PS2 2 shelter C 2 SIMA 0 26 0 1 26
PS2 3 shelter D 2 SIMA 0 26 0 1 26
PS3 1 shelter A 7 SIMA 0 26 0 1 26
PS3 2 shelter C 2 SIMA 0 26 0 1 26
PS3 3 shelter D 2 SIMA 0 26 0 1 26
PS4 1 shelter A 7 SIMA 0 26 0 1 26
PS4 2 shelter C 2 SIMA 0 26 0 1 26
PS4 3 shelter D 2 SIMA 0 26 0 1 26
PS5 1 shelter A 7 SIMA 0 26 0 1 26
PS5 2 shelter C 2 SIMA 0 26 0 1 26
PS5 3 shelter D 2 SIMA 0 26 0 1 26
PC1 1 control A 7 SIMA 0 26 0 1 26
PC1 2 control C 2 SIMA 0 26 0 1 26
PC1 3 control D 2 SIMA 0 26 0 1 26
PC2 1 control A 7 SIMA 0 26 0 1 26
PC2 2 control C 2 SIMA 0 26 0 1 26
PC2 3 control D 2 SIMA 0 26 0 1 26
PC3 1 control A 7 SIMA 0 26 0 1 26
PC3 2 control C 2 SIMA 0 26 0 1 26
PC3 3 control D 2 SIMA 0 26 0 1 26
PC4 1 control A 7 SIMA 0 26 0 1 26
PC4 2 control C 2 SIMA 0 26 0 1 26
PC4 3 control D 2 SIMA 0 26 0 1 26
PC5 1 control A 7 SIMA 0 26 1 1 26
PC5 2 control C 2 SIMA 0 26 0 1 26
PC5 3 control D 2 SIMA 0 26 0 1 26
PW1 1 watered A 7 SIMA 0 26 0 1 26
PW1 2 watered C 2 SIMA 0 26 0 1 26
PW1 3 watered D 2 SIMA 0 26 0 1 26
PW2 1 watered A 7 SIMA 0 26 0 1 26
PW2 2 watered C 2 SIMA 0 26 0 1 26
PW2 3 watered D 2 SIMA 0 26 0 1 26
PW3 1 watered A 7 SIMA 0 26 0 1 26
PW3 2 watered C 2 SIMA 0 26 0 1 26
PW3 3 watered D 2 SIMA 0 26 0 1 26
PW4 1 watered A 7 SIMA 0 26 0 1 26
PW4 2 watered C 2 SIMA 0 26 0 1 26
PW4 3 watered D 2 SIMA 0 26 0 1 26
PW5 1 watered A 7 SIMA 0 26 0 1 26
PW5 2 watered C 2 SIMA 0 26 0 1 26
PW5 3 watered D 2 SIMA 0 26 0 1 26
PS1 1 shelter A 7 SIMA 26 92 0 26 92
PS1 2 shelter C 2 SIMA 26 92 0 26 92
PS1 3 shelter D 2 SIMA 26 92 0 26 92
PS2 1 shelter A 7 SIMA 26 92 0 26 92
PS2 2 shelter C 2 SIMA 26 92 0 26 92
PS2 3 shelter D 2 SIMA 26 92 0 26 92
PS3 1 shelter A 7 SIMA 26 92 0 26 92
PS3 2 shelter C 2 SIMA 26 92 0 26 92
PS3 3 shelter D 2 SIMA 26 92 0 26 92
PS4 1 shelter A 7 SIMA 26 92 0 26 92
PS4 2 shelter C 2 SIMA 26 92 0 26 92
PS4 3 shelter D 2 SIMA 26 92 0 26 92
PS5 1 shelter A 7 SIMA 26 92 0 26 92
PS5 2 shelter C 2 SIMA 26 92 0 26 92
PS5 3 shelter D 2 SIMA 26 92 0 26 92
PC1 1 control A 7 SIMA 26 92 0 26 92
PC1 2 control C 2 SIMA 26 92 0 26 92
PC1 3 control D 2 SIMA 26 92 0 26 92
PC2 1 control A 7 SIMA 26 92 0 26 92
PC2 2 control C 2 SIMA 26 92 0 26 92
PC2 3 control D 2 SIMA 26 92 0 26 92
PC3 1 control A 7 SIMA 26 92 0 26 92
PC3 2 control C 2 SIMA 26 92 0 26 92
PC4 1 control A 7 SIMA 26 92 0 26 92
PC4 2 control C 2 SIMA 26 92 0 26 92
PC4 3 control D 2 SIMA 26 92 0 26 92
PC5 1 control A 7 SIMA 26 92 3 26 92
PC5 2 control C 2 SIMA 26 92 0 26 92
PC5 3 control D 2 SIMA 26 92 0 26 92
PW1 1 watered A 7 SIMA 26 92 0 26 92
PW1 2 watered C 2 SIMA 26 92 0 26 92
PW1 3 watered D 2 SIMA 26 92 0 26 92
PW2 1 watered A 7 SIMA 26 92 0 26 92
PW2 2 watered C 2 SIMA 26 92 0 26 92
PW2 3 watered D 2 SIMA 26 92 0 26 92
PW3 1 watered A 7 SIMA 26 92 0 26 92
PW3 2 watered C 2 SIMA 26 92 0 26 92
PW3 3 watered D 2 SIMA 26 92 0 26 92
PW4 1 watered A 7 SIMA 26 92 0 26 92
PW4 2 watered C 2 SIMA 26 92 0 26 92
PW4 3 watered D 2 SIMA 26 92 0 26 92
PW5 1 watered A 7 SIMA 26 92 0 26 92
PW5 2 watered C 2 SIMA 26 92 0 26 92
PW5 3 watered D 2 SIMA 26 92 0 26 92
PS1 1 shelter A 7 SIMA 92 120 0 92 120
PS1 2 shelter C 2 SIMA 92 120 0 92 120
PS1 3 shelter D 2 SIMA 92 120 0 92 120
PS2 1 shelter A 7 SIMA 92 120 0 92 120
PS2 2 shelter C 2 SIMA 92 120 0 92 120
PS2 3 shelter D 2 SIMA 92 120 0 92 120
PS3 1 shelter A 7 SIMA 92 120 0 92 120
PS3 2 shelter C 2 SIMA 92 120 0 92 120
PS3 3 shelter D 2 SIMA 92 120 0 92 120
PS4 1 shelter A 7 SIMA 92 120 0 92 120
PS4 2 shelter C 2 SIMA 92 120 0 92 120
PS4 3 shelter D 2 SIMA 92 120 0 92 120
PS5 1 shelter A 7 SIMA 92 120 0 92 120
PS5 2 shelter C 2 SIMA 92 120 0 92 120
PS5 3 shelter D 2 SIMA 92 120 0 92 120
PC1 1 control A 7 SIMA 92 120 0 92 120
PC1 2 control C 2 SIMA 92 120 0 92 120
PC1 3 control D 2 SIMA 92 120 0 92 120
PC2 1 control A 7 SIMA 92 120 0 92 120
PC2 2 control C 2 SIMA 92 120 0 92 120
PC2 3 control D 2 SIMA 92 120 0 92 120
PC3 1 control A 7 SIMA 92 120 0 92 120
PC3 2 control C 2 SIMA 92 120 0 92 120
PC3 3 control D 2 SIMA 92 120 0 92 120
PC4 1 control A 7 SIMA 92 120 0 92 120
PC4 2 control C 2 SIMA 92 120 1 92 120
PC4 3 control D 2 SIMA 92 120 1 92 120
PC5 1 control A 7 SIMA 92 120 2 92 120
PC5 2 control C 2 SIMA 92 120 0 92 120
PC5 3 control D 2 SIMA 92 120 0 92 120
PW1 1 watered A 7 SIMA 92 120 0 92 120
PW1 2 watered C 2 SIMA 92 120 0 92 120
PW1 3 watered D 2 SIMA 92 120 0 92 120
PW2 1 watered A 7 SIMA 92 120 0 92 120
PW2 2 watered C 2 SIMA 92 120 0 92 120
PW2 3 watered D 2 SIMA 92 120 0 92 120
PW3 1 watered A 7 SIMA 92 120 0 92 120
PW3 2 watered C 2 SIMA 92 120 1 92 120
PW3 3 watered D 2 SIMA 92 120 0 92 120
PW4 1 watered A 7 SIMA 92 120 1 92 120
PW4 2 watered C 2 SIMA 92 120 0 92 120
PW4 3 watered D 2 SIMA 92 120 0 92 120
PW5 1 watered A 7 SIMA 92 120 0 92 120
PW5 2 watered C 2 SIMA 92 120 0 92 120
PW5 3 watered D 2 SIMA 92 120 0 92 120
PS1 1 shelter A 7 SIMA 120 152 0 120 152
PS1 2 shelter C 2 SIMA 120 152 0 120 152
PS1 3 shelter D 2 SIMA 120 152 0 120 152
PS2 1 shelter A 7 SIMA 120 152 0 120 152
PS2 2 shelter C 2 SIMA 120 152 0 120 152
PS2 3 shelter D 2 SIMA 120 152 0 120 152
PS3 1 shelter A 7 SIMA 120 152 0 120 152
PS3 2 shelter C 2 SIMA 120 152 1 120 152
PS3 3 shelter D 2 SIMA 120 152 0 120 152
PS4 1 shelter A 7 SIMA 120 152 0 120 152
PS4 2 shelter C 2 SIMA 120 152 0 120 152
PS4 3 shelter D 2 SIMA 120 152 0 120 152
PS5 1 shelter A 7 SIMA 120 152 1 120 152
PS5 2 shelter C 2 SIMA 120 152 0 120 152
PS5 3 shelter D 2 SIMA 120 152 0 120 152
PC1 1 control A 7 SIMA 120 152 0 120 152
PC1 2 control C 2 SIMA 120 152 0 120 152
PC1 3 control D 2 SIMA 120 152 0 120 152
PC2 1 control A 7 SIMA 120 152 0 120 152
PC2 2 control C 2 SIMA 120 152 0 120 152
PC2 3 control D 2 SIMA 120 152 0 120 152
PC3 1 control A 7 SIMA 120 152 1 120 152
PC3 2 control C 2 SIMA 120 152 1 120 152
PC3 3 control D 2 SIMA 120 152 1 120 152
PC4 1 control A 7 SIMA 120 152 1 120 152
PC4 2 control C 2 SIMA 120 152 3 120 152
PC4 3 control D 2 SIMA 120 152 3 120 152
PC5 1 control A 7 SIMA 120 152 2 120 152
PC5 2 control C 2 SIMA 120 152 1 120 152
PC5 3 control D 2 SIMA 120 152 0 120 152
PW1 1 watered A 7 SIMA 120 152 0 120 152
PW1 2 watered C 2 SIMA 120 152 0 120 152
PW1 3 watered D 2 SIMA 120 152 0 120 152
PW2 1 watered A 7 SIMA 120 152 0 120 152
PW2 2 watered C 2 SIMA 120 152 0 120 152
PW2 3 watered D 2 SIMA 120 152 0 120 152
PW3 1 watered A 7 SIMA 120 152 1 120 152
PW3 2 watered C 2 SIMA 120 152 3 120 152
PW3 3 watered D 2 SIMA 120 152 1 120 152
PW4 1 watered A 7 SIMA 120 152 3 120 152
PW4 2 watered C 2 SIMA 120 152 0 120 152
PW4 3 watered D 2 SIMA 120 152 1 120 152
PW5 1 watered A 7 SIMA 120 152 0 120 152
PW5 2 watered C 2 SIMA 120 152 0 120 152
PW5 3 watered D 2 SIMA 120 152 0 120 152
PS1 1 shelter A 7 SIMA 152 535 0 152 535
PS1 2 shelter C 2 SIMA 152 535 0 152 535
PS1 3 shelter D 2 SIMA 152 535 0 152 535
PS2 1 shelter A 7 SIMA 152 535 0 152 535
PS2 2 shelter C 2 SIMA 152 535 0 152 535
PS2 3 shelter D 2 SIMA 152 535 0 152 535
PS3 1 shelter A 7 SIMA 152 535 0 152 535
PS3 2 shelter C 2 SIMA 152 535 3 152 535
PS3 3 shelter D 2 SIMA 152 535 0 152 535
PS4 1 shelter A 7 SIMA 152 535 0 152 535
PS4 2 shelter C 2 SIMA 152 535 1 152 535
PS4 3 shelter D 2 SIMA 152 535 0 152 535
PS5 1 shelter A 7 SIMA 152 535 0 152 535
PS5 2 shelter C 2 SIMA 152 535 1 152 535
PS5 3 shelter D 2 SIMA 152 535 1 152 535
PC1 1 control A 7 SIMA 152 535 1 152 535
PC1 2 control C 2 SIMA 152 535 0 152 535
PC1 3 control D 2 SIMA 152 535 1 152 535
PC2 1 control A 7 SIMA 152 535 0 152 535
PC2 2 control C 2 SIMA 152 535 0 152 535
PC2 3 control D 2 SIMA 152 535 1 152 535
PC3 1 control A 7 SIMA 152 535 3 152 535
PC3 2 control C 2 SIMA 152 535 0 152 535
PC3 3 control D 2 SIMA 152 535 0 152 535
PC4 1 control A 7 SIMA 152 535 3 152 535
PC4 2 control C 2 SIMA 152 535 2 152 535
PC4 3 control D 2 SIMA 152 535 2 152 535
PC5 1 control A 7 SIMA 152 535 2 152 535
PC5 2 control C 2 SIMA 152 535 3 152 535
PC5 3 control D 2 SIMA 152 535 0 152 535
PW1 1 watered A 7 SIMA 152 535 0 152 535
PW1 2 watered C 2 SIMA 152 535 0 152 535
PW1 3 watered D 2 SIMA 152 535 0 152 535
PW2 1 watered A 7 SIMA 152 535 0 152 535
PW2 2 watered C 2 SIMA 152 535 0 152 535
PW2 3 watered D 2 SIMA 152 535 0 152 535
PW3 1 watered A 7 SIMA 152 535 3 152 535
PW3 2 watered C 2 SIMA 152 535 2 152 535
PW3 3 watered D 2 SIMA 152 535 3 152 535
PW4 1 watered A 7 SIMA 152 535 2 152 535
PW4 2 watered C 2 SIMA 152 535 0 152 535
PW4 3 watered D 2 SIMA 152 535 3 152 535
PW5 1 watered A 7 SIMA 152 535 0 152 535
PW5 2 watered C 2 SIMA 152 535 1 152 535
PW5 3 watered D 2 SIMA 152 535 0 152 535
PS1 1 shelter A 7 SIMA 535 829 0 535 829
PS1 2 shelter C 2 SIMA 535 829 1 535 829
PS1 3 shelter D 2 SIMA 535 829 0 535 829
PS2 1 shelter A 7 SIMA 535 829 0 535 829
PS2 2 shelter C 2 SIMA 535 829 0 535 829
PS2 3 shelter D 2 SIMA 535 829 0 535 829
PS3 1 shelter A 7 SIMA 535 829 0 535 829
PS3 2 shelter C 2 SIMA 535 829 0 535 829
PS3 3 shelter D 2 SIMA 535 829 0 535 829
PS4 1 shelter A 7 SIMA 535 829 0 535 829
PS4 2 shelter C 2 SIMA 535 829 3 535 829
PS4 3 shelter D 2 SIMA 535 829 0 535 829
PS5 1 shelter A 7 SIMA 535 829 0 535 829
PS5 2 shelter C 2 SIMA 535 829 0 535 829
PS5 3 shelter D 2 SIMA 535 829 0 535 829
PC1 1 control A 7 SIMA 535 829 3 535 829
PC1 2 control C 2 SIMA 535 829 0 535 829
PC1 3 control D 2 SIMA 535 829 3 535 829
PC2 1 control A 7 SIMA 535 829 0 535 829
PC2 2 control C 2 SIMA 535 829 1 535 829
PC2 3 control D 2 SIMA 535 829 3 535 829
PC3 1 control A 7 SIMA 535 829 2 535 829
PC3 2 control C 2 SIMA 535 829 0 535 829
PC3 3 control D 2 SIMA 535 829 0 535 829
PC4 1 control A 7 SIMA 535 829 2 535 829
PC4 2 control C 2 SIMA 535 829 2 535 829
PC4 3 control D 2 SIMA 535 829 2 535 829
PC5 1 control A 7 SIMA 535 829 2 535 829
PC5 2 control C 2 SIMA 535 829 2 535 829
PC5 3 control D 2 SIMA 535 829 1 535 829
PW1 1 watered A 7 SIMA 535 829 1 535 829
PW1 2 watered C 2 SIMA 535 829 0 535 829
PW1 3 watered D 2 SIMA 535 829 0 535 829
PW2 1 watered A 7 SIMA 535 829 0 535 829
PW2 2 watered C 2 SIMA 535 829 0 535 829
PW2 3 watered D 2 SIMA 535 829 1 535 829
PW3 1 watered A 7 SIMA 535 829 0 535 829
PW3 2 watered C 2 SIMA 535 829 2 535 829
PW3 3 watered D 2 SIMA 535 829 0 535 829
PW4 1 watered A 7 SIMA 535 829 2 535 829
PW4 2 watered C 2 SIMA 535 829 1 535 829
PW4 3 watered D 2 SIMA 535 829 2 535 829
PW5 1 watered A 7 SIMA 535 829 1 535 829
PW5 2 watered C 2 SIMA 535 829 0 535 829
PW5 3 watered D 2 SIMA 535 829 0 535 829
PS1 1 shelter A 7 SIMA 829 Inf 0 829 Inf
PS1 2 shelter C 2 SIMA 829 Inf 3 829 Inf
PS1 3 shelter D 2 SIMA 829 Inf 0 829 Inf
PS2 1 shelter A 7 SIMA 829 Inf 0 829 Inf
PS2 2 shelter C 2 SIMA 829 Inf 0 829 Inf
PS2 3 shelter D 2 SIMA 829 Inf 0 829 Inf
PS3 1 shelter A 7 SIMA 829 Inf 0 829 Inf
PS3 2 shelter C 2 SIMA 829 Inf 0 829 Inf
PS3 3 shelter D 2 SIMA 829 Inf 0 829 Inf
PS4 1 shelter A 7 SIMA 829 Inf 0 829 Inf
PS4 2 shelter C 2 SIMA 829 Inf 2 829 Inf
PS4 3 shelter D 2 SIMA 829 Inf 0 829 Inf
PS5 1 shelter A 7 SIMA 829 Inf 0 829 Inf
PS5 2 shelter C 2 SIMA 829 Inf 0 829 Inf
PS5 3 shelter D 2 SIMA 829 Inf 0 829 Inf
PC1 1 control A 7 SIMA 829 Inf 2 829 Inf
PC1 2 control C 2 SIMA 829 Inf 0 829 Inf
PC1 3 control D 2 SIMA 829 Inf 2 829 Inf
PC2 1 control A 7 SIMA 829 Inf 0 829 Inf
PC2 2 control C 2 SIMA 829 Inf 3 829 Inf
PC2 3 control D 2 SIMA 829 Inf 2 829 Inf
PC3 1 control A 7 SIMA 829 Inf 2 829 Inf
PC3 2 control C 2 SIMA 829 Inf 0 829 Inf
PC3 3 control D 2 SIMA 829 Inf 0 829 Inf
PC4 1 control A 7 SIMA 829 Inf 2 829 Inf
PC4 2 control C 2 SIMA 829 Inf 2 829 Inf
PC4 3 control D 2 SIMA 829 Inf 2 829 Inf
PC5 1 control A 7 SIMA 829 Inf 2 829 Inf
PC5 2 control C 2 SIMA 829 Inf 2 829 Inf
PC5 3 control D 2 SIMA 829 Inf 3 829 Inf
PW1 1 watered A 7 SIMA 829 Inf 3 829 Inf
PW1 2 watered C 2 SIMA 829 Inf 0 829 Inf
PW1 3 watered D 2 SIMA 829 Inf 0 829 Inf
PW2 1 watered A 7 SIMA 829 Inf 0 829 Inf
PW2 2 watered C 2 SIMA 829 Inf 0 829 Inf
PW2 3 watered D 2 SIMA 829 Inf 3 829 Inf
PW3 1 watered A 7 SIMA 829 Inf 0 829 Inf
PW3 2 watered C 2 SIMA 829 Inf 2 829 Inf
PW3 3 watered D 2 SIMA 829 Inf 0 829 Inf
PW4 1 watered A 7 SIMA 829 Inf 2 829 Inf
PW4 2 watered C 2 SIMA 829 Inf 3 829 Inf
PW4 3 watered D 2 SIMA 829 Inf 2 829 Inf
PW5 1 watered A 7 SIMA 829 Inf 3 829 Inf
PW5 2 watered C 2 SIMA 829 Inf 0 829 Inf
PW5 3 watered D 2 SIMA 829 Inf 0 829 Inf
Ok per the comments and more background research I found that I could actually represent the data as right censored data:
Plot ID Subplot Treatment Column Row Species Time Event
PS1 1 shelter A 7 SIMA 829 0
PS1 2 shelter C 2 SIMA 829 1
PS1 3 shelter D 2 SIMA 829 0
PS2 1 shelter A 7 SIMA 829 0
PS2 2 shelter C 2 SIMA 829 0
PS2 3 shelter D 2 SIMA 829 0
PS3 1 shelter A 7 SIMA 829 0
PS3 2 shelter C 2 SIMA 829 0
PS3 3 shelter D 2 SIMA 829 0
PS4 1 shelter A 7 SIMA 829 0
PS4 2 shelter C 2 SIMA 535 1
PS4 3 shelter D 2 SIMA 829 0
PS5 1 shelter A 7 SIMA 829 0
PS5 2 shelter C 2 SIMA 829 0
PS5 3 shelter D 2 SIMA 829 0
PC1 1 control A 7 SIMA 535 1
PC1 2 control C 2 SIMA 829 0
PC1 3 control D 2 SIMA 535 1
PC2 1 control A 7 SIMA 829 0
PC2 2 control C 2 SIMA 829 1
PC2 3 control D 2 SIMA 535 1
PC3 1 control A 7 SIMA 152 1
PC3 2 control C 2 SIMA 829 0
PC3 3 control D 2 SIMA 829 0
PC4 1 control A 7 SIMA 152 1
PC4 2 control C 2 SIMA 120 1
PC4 3 control D 2 SIMA 120 1
PC5 1 control A 7 SIMA 92 1
PC5 2 control C 2 SIMA 152 1
PC5 3 control D 2 SIMA 829 1
PW1 1 watered A 7 SIMA 829 1
PW1 2 watered C 2 SIMA 829 0
PW1 3 watered D 2 SIMA 829 0
PW2 1 watered A 7 SIMA 829 0
PW2 2 watered C 2 SIMA 829 0
PW2 3 watered D 2 SIMA 829 1
PW3 1 watered A 7 SIMA 829 0
PW3 2 watered C 2 SIMA 120 1
PW3 3 watered D 2 SIMA 829 0
PW4 1 watered A 7 SIMA 120 1
PW4 2 watered C 2 SIMA 829 1
PW4 3 watered D 2 SIMA 152 1
PW5 1 watered A 7 SIMA 829 1
PW5 2 watered C 2 SIMA 535 1
PW5 3 watered D 2 SIMA 829 0
Which I then applied this code to:
rsimafit <- survfit(Surv(Time, Event, type = c('right')) ~ Treatment, data = rsima)
ggsurvplot(rsimafit, conf.int = TRUE, pval = TRUE, legend.labs=c("Control","Drought","Water+"), ggtheme = theme_bw(), legend.title = "Treatment", title ="Sidalcea malviflora", palette = c("gray47","orangered","deepskyblue"),xlim=c(0,838), ylim=c(0,1), xlab="Days Since Planting")
I got this output:
Now my biggest question is deciding upon which is the most appropriate model to use: survdiff
survreg
or coxph
I have done some background research but I do not have a strong background in statistical models or programming - from what I can tell:
survreg
is parametric
survdiff
is nonparametric
coxph
is semiparametric (not sure what that means) for testing multiple treatments and there interactions. Further, they all output similar p-values
I think all of these use some type of log-rank test to compare against a null hypothesis, which in my case would be control? Further I can't figure if post-hoc pairwise comparisons are feasible or appropriate in this situation. Any input or guidance would be appreciated. I have read many other examples on stackoverflow, statsexchange and crossvalidated, but am still stumped.
Function survreg()
from the survival package fits parameteric accelerated failure time (AFT) models. AFT models are the analogue of simple linear regression applied to survival times (actually the log survival times), and accounting for censoring in the estimation. Because these are parametric models, indeed when you use them you’re making an assumption for the distribution of your survival times.
Function coxph()
fits the semi-parametric Cox proportional hazards model. This is a model for the hazard function, and assumes a multiplicative effect of the covariates in the hazard scale. This models does not assume any particular distribution for your survival times, but it does make the proportional hazards assumption (i.e., the effect of covariates in the hazard scale is constant over time).
Function survdiff()
perorms the log-rank test, and the Gehan-Wilcoxon test (if you set argument rho
to 1). These tests test if the distribution of survival times of specific groups (e.g., males vs females) are equal. The log-rank test is equivalent to score test of a Cox model in which you including the group variable as a covariate.