# Covariates in log space 2-stage Model

**URL:** <https://discourse.pumas.ai/t/covariates-in-log-space-2-stage-model/1171>\
**Category:** Estimation\
**Created:** [April 16, 2025, 11:32pm UTC](https://discourse.pumas.ai/t/covariates-in-log-space-2-stage-model/1171 "2025-04-16T23:32:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KVTobin333](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/kvtobin333/32/401_2.png) [@KVTobin333](https://discourse.pumas.ai/u/KVTobin333)\
**Post date:** [April 16, 2025, 11:32pm UTC](https://discourse.pumas.ai/t/covariates-in-log-space-2-stage-model/1171/1 "2025-04-16T23:32:14Z")

</div>

I am running 2 stage analysis on my PK data.  
I have the individual parameter estimates and am now estimating BSV and covariate effects.  
Since my CL/F and Vc/F individual parameter estimates show a log normal distribution I am feeding in log transformed individual parameters and am estimating the mean (log form) and variance (proportional to the mean). The other two parameters are not distributed nicely, so I am feeding those in as raw values and then estimating the normal distribution. The issue is that the estimated covariate effects do not make sense.  
Here is my model:

```auto
model_2stage_wt_cl = @model begin
    @param begin
        tv_dur ∈ RealDomain(lower=0.0000001, upper=24)
        tv_ka ∈ RealDomain(lower=0.0000001, upper =50)
        tv_vc_F ∈ RealDomain(lower=0.1)
        tv_cl_F ∈ RealDomain(lower=0.1)
        # BSV
        Ω²_dur ∈ RealDomain(lower = 0.0001) 
        Ω²_ka ∈ RealDomain(lower = 0.0001) 
        Ω²_vc_F ∈ RealDomain(lower = 0.0001) 
        Ω²_cl_F ∈ RealDomain(lower = 0.0001) 
        # Covariates Effects
        Eff_PM_cl ∈ RealDomain()
        Eff_IM_cl ∈ RealDomain()
        Eff_UM_cl ∈ RealDomain()
        # RUV
        tv_σ²_add ∈ RealDomain(lower = 0.0001)
        tv_σ²_prop ∈ RealDomain(lower = 0.0001)
    end
    @covariates STUDY DOSE VISIT VISIT_NUM WEIGHT AGE_AT_VISIT OBESE SEX RACE CYP2D6_PHENOTYPE CYP2C19_PHENOTYPE
    @pre begin  
        dur_expec = tv_dur
        ka_expec = tv_ka
        Eff_2D6_cl = CYP2D6_PHENOTYPE == "PM" ? Eff_PM_cl : 
                     CYP2D6_PHENOTYPE == "IM" ? Eff_IM_cl : 
                     CYP2D6_PHENOTYPE == "UM" ? Eff_UM_cl : 0
        vcF_expec = log(tv_vc_F * ((WEIGHT/70)^1.0))
        clF_expec = log(tv_cl_F * ((WEIGHT/70)^0.75) * (1+Eff_2D6_cl))
        σ²_prop_expec = log(tv_σ²_prop)
    end
    @derived begin
        i_dur ~ @. Normal(dur_expec, sqrt(dur_expec^2 * Ω²_dur))
        i_ka ~ @. Normal(ka_expec, sqrt(ka_expec^2 * Ω²_ka))
        log_i_vc_F ~ @. Normal(vcF_expec, sqrt(vcF_expec^2 * Ω²_vc_F))
        log_i_cl_F ~ @. Normal(clF_expec, sqrt(clF_expec^2 * Ω²_cl_F))
    end
end

```

When I remove the vcF\_expec^2 and clF\_expec^2 terms from the variance for the log transformed parameters, the covariate estimates make more sense, but if I remove the dur\_expec^2 or ka\_expec^2 terms for the other parameters, the omegas skyrocket. Is this to do with me already taking the log transform of the mean value? My end goal is to get the individual subject etas from the individual etas and typical values. Is there a better way I am supposed to estimate the covariates in 2 stage?

---

<div class="post-metadata">

**Author:** ![jess-woj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/jess-woj/32/511_2.png) [@jess-woj](https://discourse.pumas.ai/u/jess-woj)\
**Post date:** [April 22, 2025, 1:06pm UTC](https://discourse.pumas.ai/t/covariates-in-log-space-2-stage-model/1171/2 "2025-04-22T13:06:05Z")

</div>

Hi @KVTobin333,

I’m not sure on the rationale of the using the 2-stage approach here over developing a population PK model where population and individual parameters are estimated simultaneously. The limitations of a 2-stage approach are briefly discussed in the following tutorial in CPT:PSP:

_Mould D, Upton R. Basic Concepts in Population Modeling, Simulation, and Model-Based Drug Development—Part 2: Introduction to Pharmacokinetic Modeling Methods. CPT: Pharmacometrics & Systems Pharmacology. 2013;2(4):38. [https://onlinelibrary.wiley.com/doi/abs/10.1038/psp.2013.14](https://onlinelibrary.wiley.com/doi/abs/10.1038/psp.2013.14)_

You are correct - because your values for clF and vcF are in the log-domain, then the standard deviation for the normal distribution should be represented as “additive” not “proportional” to the value for clF and vcF. This is why your covariate estimates made more sense when you removed the vcF\_expec^2 and clF\_expec^2 terms.
