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