Unable to interpret the fitting error

Hi Vaibhavdixit02,

  1. For question 1, I used fit(). Please see the code below:
 using Distributions, Pumas, CSV, TableView, StatsPlots, DataFrames

ped_mod = @model begin

    @param   begin
      θ ∈ VectorDomain(8,lower=[0,0,0,0,-Inf,-Inf,-Inf,-Inf])
      Ω  ∈ PDiagDomain(3)
      σ_prop ∈ RealDomain(lower = 0)
    end

    @random begin
      η ~ MvNormal(Ω)
    end

    @covariates WTKG  CRCL

    @pre begin
    #--INSERT COVARIATE EFFECTS
    COV1=(CRCL/100)^θ[5]
    COV2=(WTKG/70)^θ[6]
    COV3=(WTKG/70)^θ[7]
    COV4=(WTKG/70)^θ[8]


    TVCLI = θ[1]*COV1*COV4
    TVCL  = TVCLI

    TVV1I = θ[2]*COV2
    TVV1  = TVV1I

    TVQI  = θ[3]
    TVQ   = TVQI

    TVV2I = θ[4]*COV3
    TVV2  = TVV2I

    CL  = TVCL*exp(η[1])
    V1  = TVV1*exp(η[2])
    Q   = TVQ
    V2  = TVV2*exp(η[3])

    Vc = V1
    Vp = V2

    S1 = V1

    #CALCULATION OF SECONDARY PARAMETERS
    KE  = CL/V1
    K12 = Q/V1
    K21 = Q/V2
    AA = KE+K12+K21
    ALPH = (AA+sqrt(AA*AA-4*KE*K21))/2
    BETA = (AA-sqrt(AA*AA-4*KE*K21))/2
 
    end

    @dynamics Central1Periph1 #a two compartment model

    #@dynamics begin
  #Central'    = -(CL+Q)/Vc*Central + Q/Vp*Peripheral
  #Peripheral' =        Q/Vc*Central - Q/Vp*Peripheral
#end

    @derived begin
        cp = @. 1000*(Central/Vc)
        DV ~ @. Normal(cp, sqrt((cp^2*σ_prop)))
      end
  end



  ## Read Dataset
  inputDataset = CSV.read("dat.csv")


  ## Convert the dataset into a pumas object
  ## Pumas expects a dvs and id column. So map the names of the columns
  df = read_pumas(inputDataset, id = :ID, dvs =[:DV],  cvs=[:WTKG, :CRCL], evid=:EVID, amt=:AMT,cmt=:CMT, rate=:RATE, time=:TIME)


#Initla value for parameters
param = (
    θ=([18,14.2,2.13,4.29,1,1,1,1]),
    Ω  = Diagonal([0.25,0.25,0.25]),
    σ_prop = 0.04)

  ## Fit the data with model specified above
  pkres = fit(ped_mod, df, param, Pumas.FOCEI(),
              optimize_fn=Pumas.DefaultOptimizeFN(show_trace=true, extended_trace=false))
  1. For 2, yes I forgot to mention DV in the derive block, thank you. But after adding DV in the derive block, it returned a similar error as in “1”:
LoadError: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(!Matched::Core.SimpleVector) at essentials.jl:603
  iterate(!Matched::Core.SimpleVector, !Matched::Any) at essentials.jl:603
  iterate(!Matched::ExponentialBackOff) at error.jl:253
  ...

The code in “2” is almost the same as in “1”, the only difference is theta is a distribution:

    @param   begin
      Ω  ∈ PDiagDomain(3)
      σ_prop ∈ RealDomain(lower = 0)
      θ ~ MvNormal([16.6,13.1,4.05,4.89,0.623,0,0,0],
                  Diagonal([0.0895,0.0655,0.0238,0.0161,0.0016,1000^2,1000^2,1000^2]))

    end
  1. There’s another issue is that I am not able to specify a diagonal of initials in the @param block, which I think is doable according to the examples.
    codes:
    @param   begin
      θ ∈ VectorDomain(8,lower=[0,0,0,0,-Inf,-Inf,-Inf,-Inf],init=[18,14.2,2.13,4.29,1,1,1,1])
      Ω  ∈ PDiagDomain(3,init=[0.25,0.25,0.25])
      σ_prop ∈ RealDomain(lower = 0,init=0.04)
    end

error:

LoadError: MethodError: no method matching PDiagDomain(::Int64; init=[0.25 0.0 0.0; 0.0 0.25 0.0; 0.0 0.0 0.25])
got unsupported keyword argument "init"

Thanks in advance!

Best,
Anqi