-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Ft] give cox baseline #10
Comments
Thisone looks like it is doing the same thing but a bit faster: function _breslow_est(model::SurvivalModels.CoxModel, t)
r = 0.0
us = unique(model.times)
max_iu = searchsortedfirst(us, t)
contribs = 1 ./ reverse(cumsum(reverse(exp.(model.des * model.par))))
for i_u in 1:(max_iu-1)
u = us[i_u]
iiu = searchsortedfirst(model.times, u)
count = sum(model.status[1:(iiu-1)])
r += count * contribs[iiu]
end
return r
end |
It's still the wrong values no? |
It is the same value, I do not know if it is right or wrong for the moment... |
@rimhajal i do not remember if we had a correctly working verison at the end ? if so, can you copy it here ? |
the results were a lot better (when comparing the Cox survival curve to Kaplan Meier) but they didn't match the values in R i think. function _breslow_est(model::SurvivalModels.CoxModel)
t = unique(model.times)
k = length(t)
h = zeros(k)
elp = exp.(model.des * model.par)
for i in 1:k
risk = elp .* (model.times .>= t[i])
h[i] = sum(model.status .* (model.times .== t[i])) / sum(risk)
end
return cumsum(h)
end |
Ha now i remember, this version is actually OK, TY (even if a bit slow i think). Do you also have the website link we used for future reference ? I do not remember it.. |
you mean this one https://missingdatasolutions.rbind.io/2022/12/cox-baseline-hazard/ ? |
it would be nice to have a function that adds the baseline H_0 function. this is a rough draft of the breslow estimator for that end:
The text was updated successfully, but these errors were encountered: