Esimated parameters is equal to initial value & inspect() function didn't work

Hi Pumas team,
I have an issue that the estimated param is equal to the initial value. But when I tested to fit with FOCEi in nlmixr package in R, it work.

Thank you for help! Tien Nguyen.

Here is my code:

CV_to_omega = function (CV)
    return(log((CV/100)^2 + 1))
end

model= @model begin
    @param begin
      tvcl ∈ RealDomain(lower = 0, init = 4.6)
      tvv  ∈ RealDomain(lower = 0, init = 58.4)
      tvvp ∈ RealDomain(lower = 0, init = 38.4)
      tvq  ∈ RealDomain(lower = 0, init = 6.5)
      beta_Cl ∈ RealDomain(lower = 0, init = 0.8)
      #
      Ω    ∈ PDiagDomain(init = [CV_to_omega(39.8), CV_to_omega(81.6), CV_to_omega(57.1)])
      σ_add  ∈ RealDomain(lower = 0.0001, init = 3.4)
      σ_prop ∈ RealDomain(lower = 0.0001, init = 22.7/100)
    end

    @random begin
      η ~ MvNormal(Ω)
    end

    @pre begin
        CL = tvcl*(CLCR/120)^beta_Cl*exp(η[1])
        Vc = tvv*(WT/70)*exp(η[2])
        Vp = tvvp*(WT/70)*exp(η[3])
        Q  = tvq
      end
    
    @covariates WT CLCR
    
    @dynamics Central1Periph1
    
    @derived begin
        # The conditional mean
        μ := @. Central / Vc
        # Additive error model
        DV ~ @. Normal(μ, sqrt(σ_add^2 + (μ*σ_prop)^2))  
    end
  end  
  
# Read data 
mydata= CSV.read("mydata.csv", DataFrame)
insertcols!(vanco_train, :route => "inf")

data = read_pumas(
  mydata;
  id = :ID_NEW, time = :time_hour, amt = :AMT, rate = :RATE, observations = [:DV], evid = :EVID, 
  cmt = :CMT, route = :route, covariates = [:WT, :CLCR]
)

FOCEI_model = fit(model, data, init_params(model), Pumas.FOCE()) 
julia> 
Iter     Function value   Gradient norm 
     0              Inf     3.520410e+02
 * time: 0.024431943893432617
FittedPumasModel

Successful minimization:                      true

Likelihood approximation:               Pumas.FOCE
Log-likelihood value:                         -Inf
Number of subjects:                            285
Number of parameters:         Fixed      Optimized
                                  0             10
Observation records:         Active        Missing
    DV:                         285              0
    Total:                      285              0

---------------------
            Estimate
---------------------
tvcl         4.6
tvv         58.4
tvvp        38.4
tvq          6.5
beta_Cl      0.8
Ω₁,₁         0.14704
Ω₂,₂         0.51034
Ω₃,₃         0.2822
σ_add        3.4
σ_prop       0.227
---------------------

inspect() function: FOCE_inspect = inspect(FOCEI_model )

<output>:
[ Info: Calculating predictions.
ERROR: MethodError: no method matching _unwrap(::Nothing)
Closest candidates are:
  _unwrap(::Pumas.LikelihoodApproximation) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/XHa5R/src/estimation/likelihoods.jl:22
  _unwrap(::Pumas.MAP) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/XHa5R/src/estimation/likelihoods.jl:23
  _unwrap(::Pumas.SAEM) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/XHa5R/src/estimation/likelihoods.jl:59
  ...
Stacktrace: 

Some first rows of mydata. Briefly, it has 1 conc points per patient.

And the estimated results when I fitted in nlmixr package in R.
image

Could you please report the output from findinfluential(FOCEI_model)?

Thank you for response!
That is:

julia> findinfluential(FOCEI_model)
5-element Vector{Tuple{String, Float64}}:
 ("10431", Inf)
 ("11371", Inf)
 ("4773", 7.839117790546311)
 ("5701", 6.583230290774606)
 ("7493", 5.918398653235394)

Would you be able to show us the data frame for the subjects with ID 10431 and 11371?

Oops, the covariate value all are equal 0 for 2 IDs. Sorry for my mistake, I removed 2 IDs then tried again. It works.

------------------------
            Estimate
------------------------
tvcl         4.3386
tvv         20.91
tvvp        78.126
tvq          5.1854
beta_Cl      0.89811
Ω₁,₁         0.16342
Ω₂,₂         1.2843e-7
Ω₃,₃         0.32282
σ_add        0.00010072
σ_prop       0.00010009
------------------------

Could you please explain the function findinfluential() for me? For example, what’s the meaning for the value in ID 4773 ("4773", 7.839117790546311).

Thank you.

We should have explained more here, but it is listed in the docs here Pumas Docstrings · Pumas

@NamTienNguyen the algorithm runs without removing these covariates in nlmixr?

Yepp Prof,

Here is my code and the output had 2 “zero covariates” IDs in the fitted dataframe.

model = function() {
  ini({
    tvCl <- c(0, 4.6, Inf)
    tvVc <- c(0, 58.4, Inf)
    tvVp <- c(0, 38.4, Inf)
    tvQ <- c(0, 6.5, Inf)
    beta.Cl <- c(0, 0.8, Inf) 
    
    eta.Vc ~ CV.to.omega(81.6)
    eta.Cl ~ CV.to.omega(39.8)
    eta.Vp ~ CV.to.omega(57.1)
    prop.sd <- 0.051529     # (22.7/100)^2   
    add.sd <- 11.56         # 3.4^2
  })
  model({
    Cl <- tvCl*(CLCR/120)^beta.Cl*exp(eta.Cl)   
    Vc <- tvVc*(WT/70)*exp(eta.Vc)
    Vp <- tvVp*(WT/70)*exp(eta.Vp)
    Q <- tvQ
    # dynamical system
    linCmt() ~ prop(prop.sd) + add(add.sd)
  })
}

FOCEi_model = nlmixr(model, mydata, list(print=0), est="focei")
FOCEi_model %>% filter(ID %in% c(10431, 11371))

Of course, other IDs have been solved with valuable PRED, IPRED
Tien.

So nlmxir automatically drops subjects with all zero covariates?

I think so, but I am not sure.

What if my covariate is a binary (0,1) ? J

1 Like

I’m not sure I understand. Are you asking about Pumas or nlmixr? Could you clarify?

Nlmixr. I am not sure excluding cov=0 is actually possible.