hi -
My first post here I understand from the documentation that ConstDomain() is equivalent to fixing a parameter during estimation. I am confused on how to use it, especially if I follow the example in the Readme of the github page. Let’s say I would like to fix pmoncl in that example model here . So, instead of
note that I fixed the value to -0.6. My main question is how to specify the parameter for pmoncl in the parameter vector that is used outside the model.
During simulation, this should not matter. But what do I specify for pmoncl (or should I specify anything at all) when passing this parameter vector into a fit object? Should I use ConstDomain here too? What will take precedence?
I think that you should just avoid ConstDomain to be completely honest. Here is a simple example where I simulate using a value of 1 for the volume of distribution estimate. Then I estimate using no restrictions, and after that I restrict the parameter for volume of distribution to be 4.0 instead. I use NaivePooled() because there are no random effects.
I hope it helps!
using Pumas, Query
model = @model begin
@param begin
θCL ∈ RealDomain(lower=0.01, upper=10.0)
θV ∈ RealDomain(lower=0.01, upper=10.0)
σ ∈ RealDomain(init= 0.10, lower=0.01, upper = 1.0)
end
@pre begin
CL = θCL
V = θV
end
@dynamics ImmediateAbsorptionModel
@derived begin
cp = @. (Central / (V/1000))
dv ~ @. Normal(cp, sqrt(σ))
end
end
param = (θCL=1.0, θV = 1.0, σ = 0.06)
D = DosageRegimen(40, cmt=1, time=0, ii=12, addl=0, rate=0)
pop = Population(map(i -> Subject(id=i, evs=D),1:15))
_simobs = simobs(model, pop, param)
simdf = DataFrame(_simobs) |> @filter(!(_.evid == 0 &&_.time==0)) |> DataFrame
data = read_pumas(simdf)
fpm = fit(model, data, param, Pumas.NaivePooled())
fpm = fit(model, data, param, Pumas.NaivePooled(); constantcoef=(θV=4.0,))
It should output something like:
julia> fpm = fit(model, data, param, Pumas.NaivePooled())
FittedPumasModel
Successful minimization: true
Likelihood approximation: Pumas.NaivePooled
Objective function value: 11.050267
Total number of observation records: 360
Number of active observation records: 360
Number of subjects: 15
------------------
Estimate
------------------
θCL 1.0
θV 0.99999
σ 0.062257
------------------
julia> fpm = fit(model, data, param, Pumas.NaivePooled(); constantcoef=(θV=4.0,))
FittedPumasModel
Successful minimization: true
Likelihood approximation: Pumas.NaivePooled
Objective function value: 5.1780445e8
Total number of observation records: 360
Number of active observation records: 360
Number of subjects: 15
-----------------
Estimate
-----------------
θCL 1.4347
θV 4.0
σ 1.0
-----------------
Thanks for the response,@pkofod! I am using JuliaPro with Pumas at v0.5 I think. Is this constantcoef feature available? From what I am reading, I see that there is no way to assign the value of a variable to be a constant in the model? e.g. can I set the value of Vc to be 1 in the @pre block as Vc=1 and use it downstream in the model and never worry about using constantcoef or ConstantDomain?
Okay, then you’d want to use ConstDomain, but if you do that, then you cannot use another value later, that sort of goes with the name And maybe this is what you’re asking: yes you have to include it in param with the same value (also slightly annoying imo, that’s why I prefer the constantcoef).
I’d just put it in pre then I guess
model = @model begin
@param begin
θCL ∈ RealDomain(lower=0.01, upper=10.0)
σ ∈ RealDomain(init= 0.10, lower=0.01, upper = 1.0)
end
@pre begin
CL = θCL
V = 1.0
end
@dynamics ImmediateAbsorptionModel
@derived begin
cp = @. (Central / (V/1000))
dv ~ @. Normal(cp, sqrt(σ))
end
end
param = (θCL=1.0, θV = 1.0, σ = 0.06)
D = DosageRegimen(40, cmt=1, time=0, ii=12, addl=0, rate=0)
pop = Population(map(i -> Subject(id=i, evs=D),1:15))
_simobs = simobs(model, pop, param)
simdf = DataFrame(_simobs) |> @filter(!(_.evid == 0 &&_.time==0)) |> DataFrame
data = read_pumas(simdf)
fpm = fit(model, data, param, Pumas.NaivePooled())