Constraining Random effects?

Hi in the online example -> I see you are giving initial values to random effects using Ω. You have:


mymodel = @model begin
  @param   begin
    tvcl ∈ RealDomain(lower=0, init = 1.0)
    tvv ∈ RealDomain(lower=0, init = 20)
    tvka ∈ RealDomain(lower = 0, init= 1)
    Ω ∈ PDiagDomain(init=[0.09,0.09, 0.09])
    σ_prop ∈ RealDomain(lower=0,init=0.04)
  end

  @random begin
    η ~ MvNormal(Ω)
  end

I am trying to do something similar:


SEABCMAWhy2 = @model begin

    @param begin
      θ ∈ VectorDomain(3,lower=zeros(3).+0.01, 
                          init=[10, 3, 50], upper=[100, 5, 100]) 
#       Ω ∈ PSDDomain(init=0.04I(3), lower=0.01I(3), upper=0.5I(3))
#       Ω ∈ PDiagDomain(init=[0.09,0.09, 0.09], lower=[0.01, 0.01, 0.01], upper=[0.5, 0.5,0.5])
        Ω ∈ PSDDomain(3)
      σ_prop ∈ RealDomain(init=0.04, lower=0.01, upper=0.2)
    end

    @random begin
#       η ~ MvNormal(Matrix{Float64}(0.04I, 3, 3))
      η ~ MvNormal(Ω)
    end

The way the code is written here my model run, however if I try to init or constrain Ω using PDiagDomain(init=…) or PSDDomain=(init=…) as in the code abovem whcih I assumed possible from your example. The model gives an error:

From the errors am I safe to assume that random effects are fixed? Or can they be optimized? If so how - clearly upper and lower are not accepted as arguments in PDiagDomain, and they are not accepted in PSDDomain (is init accepted there?)

Thanks,

A

PSDDomain:

MethodError: no method matching PSDDomain(; init=[0.04 0.0 0.0; 0.0 0.04 0.0; 0.0 0.0 0.04], lower=[0.01 0.0 0.0; 0.0 0.01 0.0; 0.0 0.0 0.01], upper=[0.5 0.0 0.0; 0.0 0.5 0.0; 0.0 0.0 0.5])
Closest candidates are:
PSDDomain(; init) at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\models\params.jl:59 got unsupported keyword arguments “lower”, “upper”
PSDDomain(!Matched::Int64) at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\models\params.jl:60 got unsupported keyword arguments “init”, “lower”, “upper”
PSDDomain(!Matched::T) where T at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\models\params.jl:57 got unsupported keyword arguments “init”, “lower”, “upper”

Stacktrace:
[1] kwerr(::NamedTuple{(:init, :lower, :upper),Tuple{Diagonal{Float64,Array{Float64,1}},Diagonal{Float64,Array{Float64,1}},Diagonal{Float64,Array{Float64,1}}}}, ::Type) at .\error.jl:125
[2] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:init, :lower, :upper),Tuple{Diagonal{Float64,Array{Float64,1}},Diagonal{Float64,Array{Float64,1}},Diagonal{Float64,Array{Float64,1}}}}, ::Type{PSDDomain}) at .\none:0
[3] top-level scope at In[104]:1

PDiagDomain:

MethodError: no method matching PDiagDomain(; init=[0.09, 0.09, 0.09], lower=[0.01, 0.01, 0.01], upper=[0.5, 0.5, 0.5])
Closest candidates are:
PDiagDomain(; init) at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\models\params.jl:74 got unsupported keyword arguments “lower”, “upper”
PDiagDomain(!Matched::Int64) at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\models\params.jl:75 got unsupported keyword arguments “init”, “lower”, “upper”
PDiagDomain(!Matched::T) where T at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\models\params.jl:72 got unsupported keyword arguments “init”, “lower”, “upper”

Stacktrace:
[1] kwerr(::NamedTuple{(:init, :lower, :upper),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}}}, ::Type) at .\error.jl:125
[2] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:init, :lower, :upper),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}}}, ::Type{PDiagDomain}) at .\none:0
[3] top-level scope at In[109]:1

Also in the same line - Is it possible to leave some of the initial conditions as a parameter to be optimized?

I have an initial condition - which is unknown, so this would be very helpful.

ie:


@param begin
      θ ∈ VectorDomain(3,lower=zeros(4).+0.01, 
                          init=[10, 3, 1, 100], upper=[100, 50, 5, 200]) 
#       Ω ∈ PSDDomain(init=0.04I(3), lower=0.01I(3), upper=0.5I(3))
      Ω ∈ PDiagDomain(init=[0.09,0.09, 0.09, 0.09])#, lower=[0.01, 0.01, 0.01], upper=[0.5, 0.5,0.5])
#         Ω ∈ PSDDomain(3)
      σ_prop ∈ RealDomain(init=0.04, lower=0.01, upper=0.2)
    end

    @random begin
#       η ~ MvNormal(Matrix{Float64}(0.04I, 3, 3))
      η ~ MvNormal(Ω)
    end

    @pre begin

        p1  = θ[1]*exp(η[1]) #          


       @init begin
              x=p1

....
end

Thanks,

A

init should work with both of PDiagDomain and PSDomain. Specifying init is not fixing them. The values provided in the init are starting values and these will be optimized. I usually never think of specifying bounds for omegas.

yes, this is commonly done. In your example, is x a compartment with a differential equation where the initial value is parameter p1, i.e. the initial condition of x is p1 in which case, I would rename x as x0 just to be specific

2 Likes