Error when simulating time to event model

Hello Everyone I am trying to simulate from TTE model using the following code:

disease_placebo = @model begin
  @param begin
    θbaseline  ∈ RealDomain(lower = 0.000)
    θPmax      ∈ RealDomain(lower = 0.000)
    θTD        ∈ RealDomain(lower = 0.000, upper = 6)
    θPOW       ∈ RealDomain(lower = 0.000, upper = 3)
    Ω_1        ∈ PDiagDomain(4)
    σ_add      ∈ RealDomain(lower = 0.000)
  end

  @random begin
      η_1 ~ MvNormal(Ω_1)
    end

  @covariates Cavg Site

  @pre begin
    baseline    = θbaseline * exp(η_1[1])
    Pmax        = θPmax   + η_1[3]
    TD          = θTD    * exp(η_1[2])
    POW         = θPOW    + η_1[4]
    average      = Cavg 
  end

  @vars begin
      Placebo = @. Pmax * (1- exp(-(t/TD))^POW)
  end
  @derived begin
    PANSS = @. baseline * (1 - Placebo)
    base = baseline
    Observed ~ @. Normal(PANSS,σ_add)
  end
end

param_peds_placebo = (
      θbaseline = 93.3,
      θPmax = 0.14,
      θTD = 3.6,
      θPOW = 1.68,
      Ω_1  = Diagonal([0.03,0.05,0.06,0.67]),
      σ_add = 4.99
      )
Random.seed!(1234)
choose_covariates_2() = (Cavg = 0,Site = rand(Binomial(1,0.33)))
Random.seed!(1234)
pop_peds_placebo = map(i -> Subject(id = i,
                                    #events = dose,
                                    covariates = choose_covariates_2()), 1:112) 

Random.seed!(1234)
sim_placebo_peds= DataFrame(simobs(disease_placebo,pop_peds_placebo,param_peds_placebo,obstimes = 0:1:6))

sim_placebo_peds[!,:Observed]  = ifelse.(sim_placebo_peds[!,:Observed].<=30,30,sim_placebo_peds[!,:Observed])
sim_placebo_peds[!,:Observed]  = ifelse.(sim_placebo_peds[!,:Observed].>=210,210,sim_placebo_peds[!,:Observed])
df_baseline  = sim_placebo_peds[sim_placebo_peds[!,:time].==0,[:id,:Observed]]
rename!(df_baseline,:Observed => :Baseline)
sim_placebo_peds  = innerjoin(sim_placebo_peds, df_baseline, on=:id)
sim_placebo_peds[!,:CFB] = @. 100*((sim_placebo_peds.Observed - sim_placebo_peds.Baseline)/sim_placebo_peds.Baseline)

df_peds_test_2 = DataFrame(id = repeat(1:1:112),  time = repeat([0],112), is_dropout = repeat([0],112))
t_2 = sim_placebo_peds[ ( sim_placebo_peds.time .== 0 ), [:Site,:Baseline,:CFB]]
df = hcat(df_peds_test_2,t_2)

tte_model = @model begin
  @param begin
    λ₁    ∈ RealDomain(lower=0)
    p     ∈ RealDomain(lower=0)
    β_usa ∈ RealDomain(lower=-0.5)
    β_bslp ∈ RealDomain(lower=-0.5)
    β_cfbp ∈ RealDomain(lower=-0.5)
  end
  @covariates  Baseline CFB Site
  @pre begin
    _p  = p
  _λ₀ = (Site == 1 ? λ₁*exp(β_usa+β_bslp *(Baseline) + β_cfbp * CFB) 
                        : λ₁*exp(β_bslp *(Baseline) + β_cfbp * CFB))
  end
  @vars begin
    λ = (1/_λ₀)*_p*((1/_λ₀)*t + 1e-10)^(_p - 1)
  end
  @dynamics begin
    Λ' = λ
  end
  @derived begin
    is_dropout ~ @. TimeToEvent(λ, Λ)
  end
end

param = (λ₁ = 31.5, p = 1.92, β_usa= -0.34, β_bslp = -0.15,β_cfbp = -0.02)

tte_data = read_pumas(df,
    id = :id, time = :time,
    observations = [:is_dropout],
    covariates = [:Site,:Baseline,:CFB],
    event_data=false)

Random.seed!(1234)

dropout_sims = simobstte(tte_model,
                   tte_data,
                   param,
                   NamedTuple(); 
                   minT = 0, maxT=6, repeated=false)   


But I am getting the following error

ERROR: MethodError: no method matching simobstte(::PumasModel{ParamSet{NamedTuple{(:λ₁, :p, :β_usa, :β_bslp, :β_cfbp), Tuple{RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}, var"#195#209", var"#196#210", var"#198#212", var"#200#214", ODEProblem{Nothing, Tuple{Nothing, Nothing}, false, Nothing, ODEFunction{false, ModelingToolkit.ODEFunctionClosure{var"#201#215", var"#202#216"}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#203#217", var"#206#220", ModelingToolkit.ODESystem}, ::Vector{Subject{NamedTuple{(:is_dropout,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:Site, :Baseline, :CFB), Tuple{Int64, Float64, Float64}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}}, ::NamedTuple{(:λ₁, :p, :β_usa, :β_bslp, :β_cfbp), NTuple{5, Float64}}, ::NamedTuple{(), Tuple{}}; minT=0, maxT=6, repeated=false)
Closest candidates are:
  simobstte(::PumasModel, ::Subject, ::NamedTuple, ::Union{Nothing, NamedTuple}; minT, maxT, nT, repeated, rng, diffeq_options) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/estimation/likelihoods.jl:181
  simobstte(::PumasModel, ::AbstractVector{T} where T<:Subject, ::NamedTuple) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/estimation/likelihoods.jl:281 got unsupported keyword arguments "minT", "maxT", "repeated"
  simobstte(::PumasModel, ::AbstractVector{T} where T<:Subject, ::NamedTuple, ::Vector{var"#s55"} where var"#s55"<:NamedTuple; rng, minT, maxT, repeated, diffeq_options) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/HDuXQ/src/estimation/likelihoods.jl:267
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[73]:1

Any idea how to solve this error ?

Thanks

Can you try without NamedTuple()

e.g. dropout_sims = simobstte(tte_model,tte_data,param;minT = 0, maxT=6, repeated=false)

Hi mjaber,
Thanks for the suggestion. The code is working now but all the subjects are dropped out at very early time point (as shown in the dataset).

224×15 DataFrame
 Row │ id      time         evid    is_dropout  amt        cmt      rate       duration   ss      ii       route       Site    Baseline  CFB       tad         
     │ String  Float64      Int64?  Float64?    Float64?   Int64?   Float64?   Float64?   Int64?  Int64?   NCA.Route?  Int64?  Float64?  Float64?  Float64     
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ 1       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0  115.273        0.0  0.0
   2 │ 1       1.03712e-11       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0  115.273        0.0  1.03712e-11
   3 │ 2       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0  103.971        0.0  0.0
   4 │ 2       1.64157e-10       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0  103.971        0.0  1.64157e-10
   5 │ 3       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0   98.8182       0.0  0.0
   6 │ 3       2.88567e-10       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0   98.8182       0.0  2.88567e-10
   7 │ 4       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0  105.707        0.0  0.0
   8 │ 4       4.56904e-11       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0  105.707        0.0  4.56904e-11
   9 │ 5       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0   85.3996       0.0  0.0
  10 │ 5       2.97415e-8        0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0   85.3996       0.0  2.97415e-8
  11 │ 6       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0  123.584        0.0  0.0
  12 │ 6       1.0601e-12        0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0  123.584        0.0  1.0601e-12
  13 │ 7       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0   54.9109       0.0  0.0
  14 │ 7       0.000102718       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0   54.9109       0.0  0.000102718
  15 │ 8       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        1   92.5432       0.0  0.0
  16 │ 8       5.21623e-10       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        1   92.5432       0.0  5.21623e-10
  17 │ 9       0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0  100.685        0.0  0.0
  18 │ 9       1.16711e-10       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0  100.685        0.0  1.16711e-10
  19 │ 10      0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0  108.041        0.0  0.0
  20 │ 10      2.15748e-11       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0  108.041        0.0  2.15748e-11
  21 │ 11      0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        1  100.959        0.0  0.0
  22 │ 11      9.10644e-11       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        1  100.959        0.0  9.10644e-11
  23 │ 12      0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0   76.6115       0.0  0.0
  24 │ 12      3.06333e-9        0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0   76.6115       0.0  3.06333e-9
  25 │ 13      0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        0   72.674        0.0  0.0
  26 │ 13      8.31481e-8        0         1.0  missing    missing  missing    missing         0  missing  NullRoute        0   72.674        0.0  8.31481e-8
  27 │ 14      0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        1   68.6697       0.0  0.0
  28 │ 14      2.00763e-6        0         1.0  missing    missing  missing    missing         0  missing  NullRoute        1   68.6697       0.0  2.00763e-6
  29 │ 15      0.0               3   missing          0.0        0        0.0        0.0       0        0  NullRoute        1  140.079        0.0  0.0
  30 │ 15      2.72005e-15       0         1.0  missing    missing  missing    missing         0  missing  NullRoute        1  140.079        0.0  2.72005e-15

My understanding is the simulations should show dropping out of subjects between time = 0 and maximum duration of the trial at time = 6 weeks.

I tried to add the whole longitudinal data (7 rows per subject in the simulations) but still getting the same simulation results

896×15 DataFrame
 Row │ id      time         evid     is_dropout  amt        cmt      rate       duration   ss       ii       route       Site    Baseline  CFB          tad         
     │ String  Float64      Int64?   Float64?    Float64?   Int64?   Float64?   Float64?   Int64?   Int64?   NCA.Route?  Int64?  Float64?  Float64?     Float64     
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ 1       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0  115.273     0.0        0.0
   2 │ 1       1.32575e-11        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0  115.273    -6.39407    1.32575e-11
   3 │ 1       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  115.273    -6.39407    1.0
   4 │ 1       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  115.273   -10.9099     2.0
   5 │ 1       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  115.273   -10.9763     3.0
   6 │ 1       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  115.273    -6.96882    4.0
   7 │ 1       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  115.273    -8.45686    5.0
   8 │ 1       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  115.273    -8.81953    6.0
   9 │ 2       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0  103.971     0.0        0.0
  10 │ 2       1.70039e-10        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0  103.971    -0.916769   1.70039e-10
  11 │ 2       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  103.971    -0.916769   1.0
  12 │ 2       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  103.971    -6.32112    2.0
  13 │ 2       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  103.971   -11.8228     3.0
  14 │ 2       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  103.971   -20.5446     4.0
  15 │ 2       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  103.971   -20.013      5.0
  16 │ 2       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  103.971   -21.4493     6.0
  17 │ 3       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0   98.8182    0.0        0.0
  18 │ 3       2.05532e-10        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0   98.8182    8.83661    2.05532e-10
  19 │ 3       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   98.8182    8.83661    1.0
  20 │ 3       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   98.8182    6.30313    2.0
  21 │ 3       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   98.8182   -2.46308    3.0
  22 │ 3       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   98.8182   -2.12339    4.0
  23 │ 3       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   98.8182    8.31288    5.0
  24 │ 3       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   98.8182    7.00215    6.0
  25 │ 4       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0  105.707     0.0        0.0
  26 │ 4       5.94883e-11        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0  105.707    -6.87218    5.94883e-11
  27 │ 4       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  105.707    -6.87218    1.0
  28 │ 4       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  105.707    -0.214863   2.0
  29 │ 4       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  105.707    -9.16558    3.0
  30 │ 4       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  105.707     0.366004   4.0
  31 │ 4       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  105.707    -2.04683    5.0
  32 │ 4       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  105.707    -7.48762    6.0
  33 │ 5       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0   85.3996    0.0        0.0
  34 │ 5       1.732e-8           0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0   85.3996   14.0802     1.732e-8
  35 │ 5       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   85.3996   14.0802     1.0
  36 │ 5       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   85.3996   12.7716     2.0
  37 │ 5       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   85.3996    4.78765    3.0
  38 │ 5       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   85.3996   -4.69796    4.0
  39 │ 5       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   85.3996   -8.16683    5.0
  40 │ 5       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   85.3996   -1.73409    6.0
  41 │ 6       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0  123.584     0.0        0.0
  42 │ 6       1.90298e-12        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0  123.584   -15.2357     1.90298e-12
  43 │ 6       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  123.584   -15.2357     1.0
  44 │ 6       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  123.584   -21.1863     2.0
  45 │ 6       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  123.584   -28.658      3.0
  46 │ 6       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  123.584   -29.2187     4.0
  47 │ 6       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  123.584   -29.0894     5.0
  48 │ 6       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  123.584   -38.8805     6.0
  49 │ 7       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0   54.9109    0.0        0.0
  50 │ 7       0.000218683        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0   54.9109  -19.6736     0.000218683
  51 │ 7       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   54.9109  -19.6736     1.0
  52 │ 7       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   54.9109   -6.24562    2.0
  53 │ 7       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   54.9109  -15.5306     3.0
  54 │ 7       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   54.9109  -17.3781     4.0
  55 │ 7       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   54.9109  -27.547      5.0
  56 │ 7       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   54.9109  -19.2067     6.0
  57 │ 8       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        1   92.5432    0.0        0.0
  58 │ 8       6.11583e-10        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        1   92.5432   -4.14335    6.11583e-10
  59 │ 8       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   92.5432   -4.14335    1.0
  60 │ 8       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   92.5432    6.73053    2.0
  61 │ 8       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   92.5432   18.3039     3.0
  62 │ 8       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   92.5432    2.5405     4.0
  63 │ 8       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   92.5432    6.33268    5.0
  64 │ 8       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   92.5432    6.75503    6.0
  65 │ 9       0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0  100.685     0.0        0.0
  66 │ 9       2.29681e-10        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0  100.685   -17.63       2.29681e-10
  67 │ 9       1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  100.685   -17.63       1.0
  68 │ 9       2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  100.685   -12.2447     2.0
  69 │ 9       3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  100.685   -21.7046     3.0
  70 │ 9       4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  100.685   -25.6919     4.0
  71 │ 9       5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  100.685   -20.869      5.0
  72 │ 9       6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  100.685   -16.3309     6.0
  73 │ 10      0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0  108.041     0.0        0.0
  74 │ 10      2.32359e-11        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0  108.041    -1.9316     2.32359e-11
  75 │ 10      1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  108.041    -1.9316     1.0
  76 │ 10      2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  108.041     7.83971    2.0
  77 │ 10      3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  108.041    -6.36008    3.0
  78 │ 10      4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  108.041     7.26394    4.0
  79 │ 10      5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  108.041     2.44952    5.0
  80 │ 10      6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0  108.041    11.1725     6.0
  81 │ 11      0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        1  100.959     0.0        0.0
  82 │ 11      1.4263e-10         0         1.0  missing    missing  missing    missing          0  missing  NullRoute        1  100.959   -11.6845     1.4263e-10
  83 │ 11      1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  100.959   -11.6845     1.0
  84 │ 11      2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  100.959    -6.83171    2.0
  85 │ 11      3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  100.959    -5.0905     3.0
  86 │ 11      4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  100.959   -11.3362     4.0
  87 │ 11      5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  100.959    -5.8994     5.0
  88 │ 11      6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  100.959    -7.44439    6.0
  89 │ 12      0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0   76.6115    0.0        0.0
  90 │ 12      2.57023e-9         0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0   76.6115    4.57047    2.57023e-9
  91 │ 12      1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   76.6115    4.57047    1.0
  92 │ 12      2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   76.6115  -16.0517     2.0
  93 │ 12      3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   76.6115  -28.0838     3.0
  94 │ 12      4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   76.6115  -18.3919     4.0
  95 │ 12      5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   76.6115  -20.5789     5.0
  96 │ 12      6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   76.6115  -22.7895     6.0
  97 │ 13      0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        0   72.674     0.0        0.0
  98 │ 13      3.04542e-8         0         1.0  missing    missing  missing    missing          0  missing  NullRoute        0   72.674    26.1562     3.04542e-8
  99 │ 13      1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   72.674    26.1562     1.0
 100 │ 13      2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   72.674    15.7378     2.0
 101 │ 13      3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   72.674    21.1612     3.0
 102 │ 13      4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   72.674    32.558      4.0
 103 │ 13      5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   72.674    24.1099     5.0
 104 │ 13      6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          0   72.674    13.1475     6.0
 105 │ 14      0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        1   68.6697    0.0        0.0
 106 │ 14      9.47451e-7         0         1.0  missing    missing  missing    missing          0  missing  NullRoute        1   68.6697   19.5556     9.47451e-7
 107 │ 14      1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   68.6697   19.5556     1.0
 108 │ 14      2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   68.6697   12.8758     2.0
 109 │ 14      3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   68.6697   15.1606     3.0
 110 │ 14      4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   68.6697   12.5753     4.0
 111 │ 14      5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   68.6697    9.87235    5.0
 112 │ 14      6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1   68.6697   16.1136     6.0
 113 │ 15      0.0                3   missing          0.0        0        0.0        0.0        0        0  NullRoute        1  140.079     0.0        0.0
 114 │ 15      5.38458e-15        0         1.0  missing    missing  missing    missing          0  missing  NullRoute        1  140.079   -17.4693     5.38458e-15
 115 │ 15      1.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  140.079   -17.4693     1.0
 116 │ 15      2.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  140.079   -25.5688     2.0
 117 │ 15      3.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  140.079   -36.9779     3.0
 118 │ 15      4.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  140.079   -44.7323     4.0
 119 │ 15      5.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  140.079   -42.1618     5.0
 120 │ 15      6.0          missing   missing    missing    missing  missing    missing    missing  missing  missing          1  140.079   -39.9937     6.0

Any suggestions how to modify the code to get drop outs at intervals between week 0 and week 6?

Thanks

Have you try to modify your simulated parameters? probably a lower value of p?

Thanks for the suggestion. If I tried lower values (for example 0.1), all the subjects will not be dropped out by time of 6 weeks. Also, the parameters that I am using are reported values in a paper and I cannot change them.

You can see that the cumulative hazard becomes very high immediately by computing

julia> DataFrame(solve(
           tte_model,
           tte_data[1],
           param,
           NamedTuple(),
           diffeq_options=(saveat=0.0:0.1:1.0,)
       ))
11×2 DataFrame
 Row │ timestamp  value1    
     │ Float64    Float64   
─────┼──────────────────────
   1 │       0.0  0.0
   2 │       0.1  9.24771e5
   3 │       0.2  3.49955e6
   4 │       0.3  7.62267e6
   5 │       0.4  1.32431e7
   6 │       0.5  2.03262e7
   7 │       0.6  2.88459e7
   8 │       0.7  3.87813e7
   9 │       0.8  5.01149e7
  10 │       0.9  6.28319e7
  11 │       1.0  7.69191e7

so the survival probability is zero right away. Hard to say what needs to be adjusted here without knowing the details. Which paper are you trying to reproduce?

Hi Andreas,
Thanks so much for the reply. I think I figured out the problem where one of the covariates should be normalized by the mean value.

I have a followup question, please. The output is getting me only time zero and time when the dropout happened. Is there a way in formatting the data to get more longitudinal output like time (0,1,2,3,4,5,6). My question also applies to estimating time-to-event models where I have to format my data to only have two rows per subject (time zero and time of dropout)?

Thanks

You can see how to extract the hazard per subject in my previous comment but it’s not as easy as it should be. We are working on a more user friendly solution.

1 Like