I am looking at using Cox Hazard in R using survivor, I have either (mo) 1=died, 0=censored, time in hours (hour), the temperature treatment (temp_c, 3 groups), condition factor (CF, continuous var).
I am confused about handling the temperature group variable and have trialled 2 methods:
data <- read.delim("coxnew.txt", header=TRUE) data$SurvObj <- with(data, Surv(hour, mo == 1))
(i) I have seen that in example models online, sex: m=0, f=1 or similar, so I used L=1,M=2,H=3 as the groups.
mod <- coxph(SurvObj ~ temp_c + CF , data = data)
and this gave me a summary with two outputs, one for temp_c and one for CF.
(ii) I have also made temperature treatment a factor
data$temp_c <- factor(data$temp_c) data$temp_c<- relevel(data$temp_c, ref="H") mod <- coxph(SurvObj ~ temp_c +CF , data = data)
and this gave me a summary with three outputs, one for temp_cL, one for temp_cM and one for CF
I am not sure which is the correct to use, as (ii) requires that you then input one group as a reference? The confusion comes into play when I try and see what temperature plots like, when CF is held at a mean value, as the output graphs look different for the two different methods?
temp_new <- with(data, data.frame(temp_c= c(1,2,3), CF = rep(mean(CF, na.rm = TRUE), 3)))
temp_new <- with(data, data.frame(temp_c= c("L","M","H"), CF = rep(mean(CF, na.rm = TRUE), 3)))
Does it matter which I use- is it personal preference - or does one version make more statistical sense? I was inclined to go with the first (i) as this compared to the m=0, f=1 style and I assume uses a comparison of three groups among themselves and not just two groups compared to the reference level assigned?
Many thanks, Bekah