Hi - I did some time to event simulations using the following code and I am looking to make Kaplan-Meier curves. Can someone please let me know how to build these in Pumas? Thanks!

Code:

ttd_exp_model = @model begin
@param begin
λ₁ ∈ RealDomain(lower=0)
end
@pre begin
λ = λ₁
end
@dynamics begin
Λ' = λ
end
@derived begin
DROPPED ~ @. TimeToEvent(λ, Λ)
end
end
z = Pumas.simobstte(
ttd_exp_model,
map(i -> Subject(id = i, observations = (DROPPED = nothing,),), 1:10000),
(λ₁ = 0.01,), maxT = 8.0)
z2 = @rsubset DataFrame(z) !ismissing(:DROPPED)

hi @rahul
you can just fit a KaplanMeir using the Survival package. Here is a reproducer using your example
In the last part of the code, you can also overlay the observed KM by fitting the observed data

using Pumas
using DataFramesMeta
using CairoMakie
using Survival
using PumasUtilities
ttd_exp_model = @model begin
@param begin
λ₁ ∈ RealDomain(lower = 0)
end
@pre begin
λ = λ₁
end
@dynamics begin
Λ' = λ
end
@derived begin
DROPPED ~ @. TimeToEvent(λ, Λ)
end
end
z = Pumas.simobstte(
ttd_exp_model,
map(i -> Subject(id = i, observations = (DROPPED = nothing,)), 1:10000),
(λ₁ = 0.01,),
maxT = 8.0,
)
z2 = @rsubset DataFrame(z) !ismissing(:DROPPED)
### fit K-M on simulated data
simkm = fit(KaplanMeier, z2.time, Int.(z2.DROPPED))
lines(
simkm.times,
simkm.survival
)