I'm doing some survival analysis and I got the idea to change a binary variable into three-category variable by sub-dividing one category of the binary variable into two new categories. Here's a script to produce a comparable dataset:
df = data.frame(Sample = c(1:20), OS_Months = sample(c(1:100),size = 20, replace = TRUE), OS_Event = sample(c(1,0), size = 20, replace = TRUE), Original_Var = sample(c("Yes","No"), size = 20, replace = TRUE), New_Var = sample(c(2,3), size = 20, replace = TRUE)) df[df$Original_Var == "No",]$New_Var = 1
Normally, when I do survival analysis I measure significance using a
log-rank p-value for binary data and a
coxph p-value for continuous data but I don't have a firm understanding of the mathematical basis for either of these test.
At this time, its not clear to me whether or not the new categories I've defined have an ordinal relationship with each other. If they do, I expect I'll have to think about how to scale them but my current hope is that treating them as categorical variables will eliminate this problem.
- If I decide that my variables really are ordinal, what impact will scaling have on my variables if I use the
- If I decide variables are not ordinal and
coxphis inappropriate, what is a more appropriate test to run?
For what its worth, the original binary variable was presence/absence of mutations in a particular gene and the new variable categorizes the mutations as belonging to one of two types. If I were to scale the numeric categories, I would probably change 2 and 3 to numbers closer to each other than to non-mutants, something along the lines of:
df[df$New_Var == 2,]$New_Var = 10 df[df$New_Var == 3,]$New_Var = 11