Why some intermediate variables are not saved in the trace?

I have the following code,

with pm.Model(coords=coords) as baseModel:

    # input data
    xx_ = pm.MutableData("xx_", xx)
    yy_ = pm.MutableData("yy_", yy_obs)
    sm_ = pm.MutableData("sm_", sm_obs)

    #priors
    sigma_obs = 0.1

    A_ = pm.Uniform('A_', 0, 1)
    B_ = pm.Uniform('B_', 0, 1)
    C_ = pm.Uniform('C_', 0, 1)
    D_ = pm.Uniform('D_', 0, 1)
    E_ = pm.Uniform('E_', 0, 1)
    F_ = pm.Uniform('F_', 0, 1)

    x1_ = A_ + B_*xx_
    x2_ = C_ + D_*xx_
    x3_ = E_ + F_*xx_

    def f(x1_ = x1_, x2_ = x2_, x3_ = x3_, sm_ = sm_):
        out = T11(x1_, x2_, x3_ ,sm_)
        return out

    function_pm = pm.Deterministic('s0f', f())

    obs = pm.Normal('obs', mu=function_pm, sigma=sigma_obs, observed=yy_)

where T11 is an external function. As is, the model only samples the variables, Sampling: [A_, B_, C_, D_, E_, F_, obs]. Why not x1, x2 and x3? I know I can recompute them, but I want to follow the scheme proposed here to use the posteriors of A… F once calibrated to do further inference, and the values of A…F are not stored in the posterior predictive.

x1, x2, and x3 need to be set to Deterministics if you want them saved in the trace.

x1_ = pm.Deterministic('x1', A_+B_*xx_)
4 Likes

Thank you!