I can’t reproduce this:
julia> coxph(Surv(df.duration, df.event) ~ df.x1 + df.x2, df)
ERROR: MethodError: no method matching ~(::SurvivalAnalysis.IntSurv, ::Vector{Float64})
That said, I’m not sure I understand what you are doing - you seem to be mixing SurvivalAnalysis
with Survival
, two packages which implement similar (and overlapping) functionality, but aren’t meant to be used together as far as I know. SurvivalAnalysis
doesn’t implement a Cox-PH model at present, and Surv
is a type defined in the Survival
package.
In Survival
, a Cox-PH model is fit as follows:
julia> df.event = EventTime.(df.duration, df.event .== 1);
julia> coxph(@formula(event ~ x1 + x2), df)
StatsModels.TableRegressionModel{CoxModel{Float64}, Matrix{Float64}}
event ~ x1 + x2
Coefficients:
─────────────────────────────────────────────
Estimate Std.Error z value Pr(>|z|)
─────────────────────────────────────────────
x1 0.474264 0.590107 0.803691 0.4216
x2 -0.310167 0.497345 -0.623646 0.5329
─────────────────────────────────────────────
See the docs here:
https://juliastats.org/Survival.jl/latest/getting_started/#Fitting-the-model
In Survival
, the syntax is:
f = kaplan_meier(@formula(Surv(Y, D) ~ 1), data)
However as I said above there’s no coxph
method.
Also note that your syntax for calling the fitting procedure is off - the first arugment should be a formula, which you either create by using the @formula
macro or by putting together Term
objects yourself, not by passing the actual data directly.
I recommend you read the docs of both Survival
and SurvivalAnalysis
to understand the correct syntax and the functionality of each package, and maybe the docs of StatsModels
as well to understand how @formula
works.