Cox proportional hazards models the probability/odds that an event is of type A or of type B, given that an event A or B happened. By doing that it avoids the problem of figuring out the probability of any hazard at all (whether it is A or B), and it only cares about the relative hazard.
So, that other package ignores this and models the events in some way by fitting a distribution for the passage times?
- The advantage of cox-ph is that you do not need to model the total hazard as function of time, and you only look at the relative hazards.
- The disadvantage of cox-ph is that you assume a specific model for the relative hazards (that it is independent of time) and that it contains all the information about the distributions.
If the absolute hazards, can be modeled, then I imagine that a model that does not ignore the absolute hazards might perform better.
Below I simulate 1000 times an observation where there is an effect (so we expect a distribution of p-values that deviates from a uniform distribution, the stronger the deviation the higher the power). The cox model returns the low p-values less often than the exponential model (which models the passage times directly), and has less power.
The effect is very subtle and the difference is not so large. When I model with a glm model using a more general gamma distribution (the lines which have been commented out in the code below), instead of an exponential distribution, then the Cox model performs better and has larger power.
library(survival)
set.seed(1)
n = 20
m = 10^4
pcox = rep(NA,m)
pexp = rep(NA,m)
### a function to
### - fit a nul model
### - fit an alternative model
### and compute p-value based on likelihood ratio
### assuming chi squared distribution for this value
pval_exp = function(time,x) {
mu_0 = mean(time)
mu_a = mean(time[x==0])
mu_b = mean(time[x==1])
lik_0 = sum(dexp(time,1/mu_0, log = 1))
lik_1 = sum(dexp(time[x==0],1/mu_a, log = 1))+
sum(dexp(time[x==1],1/mu_b, log = 1))
D = 2*(lik_1-lik_0)
return(1-pchisq(D,1))
}
### repeatedly simulate data with a non-zero-effect
### and compute p-values according to two models, one of them is Cox proportional hazerss
for (i in 1:m) {
x = c(rep(1,n/2),rep(0,n/2))
time = rexp(n,1+x*0.3)
##### the glm model below doesn't have great power
##### because it has a more flexible dispersion
### mod = glm(time ~ x, family = Gamma(link = "identity"))
### pexp[i] = coef(summary(mod))[,4][2]
### the manual fitting with function pval_exp works better
pexp[i] = pval_exp(time,x)
mod2 = coxph(Surv(time) ~ x)
pcox[i] = coef(summary(mod2))[5]
}
pexp = pexp[order(pexp)]
pcox = pcox[order(pcox)]
plot(pexp,c(1:m)/m, type = "l", ylab = "cumulative distribution of p-values", xlab = "p value", log = "xy")
lines(pcox,c(1:m)/m, col = 2)
lines(10^c(-10,1),10^c(-10,1), lty = 2, col = 1)
legend(0.005,0.9, c("exponential model", "cox model"), lty = 1, col = c(1,2) )
threg
package in detail. The principle explained in my question is just what popped up in my head as a potential possible improvement to a Cox PH model. $\endgroup$