Skip to content

[Ft] give cox baseline #10

@rimhajal

Description

@rimhajal

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:

function _breslow_est(model::SurvivalModels.CoxModel, t)
    r = 0.0
    exp_pred = exp.(model.des * model.par)
    for ti in model.times
        if ti < t
            num = 0.0
            den = 0.0
            for j in eachindex(model.times)
                num += model.status[j] * (model.times[j]=ti)
                den += exp_pred[j] * (model.times[j]>=ti)
            end
            r += num / den
        end
    end
    return r
end

survival_curve(model::SurvivalModels.CoxModel, t, X) = exp(-_breslow_est(model, t) * exp(X' * model.par))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions