FREM#

Pharmpy handles the postprocessing, plotting and creation of model_3b of the PsN FREM [Yngman] tool.

\[\]

The FREM postprocessing and results#

The postprocessing starts after estimating the parameters \(P\) of the FREM model together with their uncertainty covariance matrix \(\operatorname{Cov}(P)\). Let us denote the random variables representing the model parameters \(\eta_i\) for \(1 \leq i \leq n_{par}\) and the random variables for the covariates \(\eta_k\) for \(n_{par} + 1 \leq k \leq n_{cov} + n_{par}\). Then

\[\begin{split}\begin{bmatrix} \eta_1 \\ \vdots \\ \eta_{n_{par}} \\ \eta_{n_{par} + 1} \\ \vdots \\ \eta_{n_{par} + n_{cov}} \\ \end{bmatrix} \sim \mathcal{N}(\mu, \Omega)\end{split}\]

where

\[\begin{split} \mu = \begin{bmatrix} 0 \\ \vdots \\ 0 \\ \overline{C}_{1} \\ \vdots \\ \overline{C}_{n_{cov}} \\ \end{bmatrix} = \begin{bmatrix} \mu_1 \\ \mu_2 \\ \end{bmatrix}\end{split}\]

and

\[\begin{split} \Omega = \begin{bmatrix} \omega_{11} & \omega_{21} & \cdots & \omega_{n1} \\ \omega_{21} & \omega_{22} & \cdots & \omega_{n2} \\ \vdots & \vdots & \ddots & \vdots \\ \omega_{n1} & \omega_{n2} & \cdots & \omega_{nn} \\ \end{bmatrix} = \begin{bmatrix} \Omega_{11} & \Omega_{12} \\ \Omega_{21} & \Omega_{22} \\ \end{bmatrix}\end{split}\]

\(\overline{C}_k\) is the covariate reference. For continuous covariates the reference is the mean of the baselines and for categoricals it is the non-mode value of the baselines. The latter partition being for parameters (index 1) and covariates (index 2), i.e. \(\Omega_{11}\) is the original parameter matrix, \(\Omega_{22}\) is the covariate matrix and \(\Omega_{21}\) and \(\Omega_{12}^T\) is the parameter-covariate covariance block.

Covariate effects#

The effects of each covariate on each parameter is calculated with uncertainty and summarized in the covariate_effects table.

p5 mean p95
parameter covariate condition
CL APGR 5th 0.630859 0.868770 1.176754
95th 0.925602 1.082310 1.244607
WGT 5th 0.569077 0.600360 0.632538
95th 2.532478 2.824355 3.138312
V APGR 5th 0.577861 0.761430 0.991915
95th 1.003863 1.148763 1.297579
WGT 5th 0.600771 0.631260 0.661025
95th 2.315965 2.549669 2.811532

The effects are given as fractions where 1 means no effect and are calculated conditioned on the 5th and 95th percentile of the covariate values respectively.

Assume that the estimated parameter vector is joint normally distributed with mean vector \(P\) and covariance matrix \(\operatorname{Cov}(P)\). Then the marginal distribution of the \(\omega_{ij}\) of \(\Omega\) will also be joint normal. Sample 1000 times from this marginal distribution to get \(\omega_{ijk}\) and \(\Omega_k\) for \(1\leq k \leq 1000\).

If the covariate etas were scaled in the FREM model the scaling needs to be applied to all \(\Omega_k\) by first creating the scaling matrix

\[\begin{split} S= \begin{bmatrix} 1 & & & & \\ & 1 & & & \\ & & \ddots & &\\ & & & \sigma_1 &\\ & & & & \sigma_2 \\ \end{bmatrix}\end{split}\]

where \(\sigma_i\) is the standard deviation of the i:th covariate in the data, and then get each scaled matrix as \(S \Omega_k S\).

Do for each sample: For each covariate \(k\) create the marginal distribution of all parameters and that single covariate. Calculate the means of the parameters given the covariate values in the 5th and 95th percentile of the dataset in turn. The vector of the means would be given by the conditional joint normal distribution as:

\[\bar{\mu} = \mu_1 + \Omega_{12}\Omega_{22}^{-1}(a - \mu_2)\]

where \(a\) is the given value of the covariate.

For each parameter and covariate calculate the mean, 5:th and 95:th percentile over all conditional parameter means. These are the covariate effects and their uncertainties. I.e. the conditional mean of the parameter given in turn the 5th and the 95th percentile of the covariate data. Since we currently assume log-normally distributed individual parameters each mean is exponentiated.

The covariate effect plots give the covariate effects in percent with uncertainty for each parameter and covariate in turn. The red figures are the 5th and 95th percentile covariate values.

Parameter covariate coefficients#

The parameter covariate coefficients for each covariate separately and for all taken together are available in coefficients. The definition for one coefficient is Cov(Par, Covariate) / Var(Covariate) and generalized for all together by the matrix \(\Sigma_{12}\Sigma_{22}^{-1}\)

APGR WGT
condition parameter
all CL -0.020503 0.628814
V 0.009309 0.544459
each CL 0.026950 0.613127
V 0.050396 0.551581

Individual covariate effects#

The combined effects of all covariates on the parameters of each individual is calculated with uncertainty and summarized in the individual_effects table.

observed p5 p95
ID parameter
1.0 CL 0.913307 0.899565 0.923297
V 0.939015 0.926632 0.948404
2.0 CL 0.933506 0.894967 0.970755
V 1.010192 0.973823 1.047109
3.0 CL 0.992728 0.986142 0.999404
... ... ... ... ...
57.0 V 1.361911 1.322628 1.418737
58.0 CL 0.894772 0.868658 0.917333
V 0.947797 0.923656 0.969732
59.0 CL 0.771958 0.748072 0.790423
V 0.790120 0.768277 0.806911

118 rows × 3 columns

The conditional distribution as above is calculated for the estimated parameters (observed in the table) and the samples (that gives p5 and p95). The same \(\mu\) and \(\Omega\) are used, but the given condition is instead the covariate baseline as estimated from the model for each individual.

The plot shows the individuals with the lowest and the highest percentual covariate effect and the uncertainty.

Unexplained variability#

The unexplained variability is calculated and summarized in the unexplained_variability table.

sd_observed sd_5th sd_95th
parameter covariate
CL none 0.469535 0.359934 0.547612
APGR 0.465490 0.352335 0.538174
WGT 0.165502 0.141580 0.190726
all 0.159149 0.134989 0.183613
V none 0.420471 0.327104 0.490419
APGR 0.404440 0.306148 0.467046
WGT 0.143317 0.122348 0.166012
all 0.141826 0.120282 0.163610

For each sample the conditional distribution is calculated given no covariates, each covariate in turn and all covariates at the same time. The variability will be given by the conditional covariance matrix that can be calculated as:

\[\bar{\Omega} = \Omega_{11} - \Omega_{12} \Omega_{22}^{-1} \Omega_{21} = \Omega_{11} - \Omega_{21}^T \Omega_{22}^{-1} \Omega_{21}\]

The presented results are the 5th and 95th percetiles of the standard deviations of the parameters from \(\bar{\Omega}\). The observed standard deviation is the conditional.

The plot display the original unexplained variability with the uncertainty for all parameter and covariate combinations.

All variability parameters given the estimated parameters conditioned on each covariate in turn can be found in parameter_variability.

CL V
condition parameter
all CL 0.025328 0.022571
V 0.022571 0.020115
APGR CL 0.216681 0.188254
V 0.188254 0.163572
WGT CL 0.027391 0.021634
V 0.021634 0.020540

Parameter estimates#

The parameter initial estimates and final estimates of the base model (model_1), all intermediate models and the FREM model (model_4) are tabled in parameter_inits_and_estimates.

TVCL TVV IVCL OMEGA(2,1) IVV OMEGA(3,1) OMEGA(3,2) BSV_APGR OMEGA(4,1) OMEGA(4,2) OMEGA(4,3) BSV_WGT SIGMA(1,1)
model type
model_1 init 0.004693 1.00916 0.030963 NaN 0.031128 NaN NaN NaN NaN NaN NaN NaN 0.013241
estimate 0.005818 1.44555 0.111053 NaN 0.201526 NaN NaN NaN NaN NaN NaN NaN 0.016418
model_2 init NaN NaN NaN NaN NaN NaN NaN 1.000000 NaN NaN 0.244579 1.000000 NaN
estimate NaN NaN NaN NaN NaN NaN NaN 1.000000 NaN NaN 0.244579 1.000000 NaN
model_3 init NaN NaN 0.115195 0.007066 0.209016 -0.010583 0.107027 1.000008 0.171529 0.404278 0.244448 1.002173 NaN
estimate NaN NaN 0.115195 0.007066 0.209016 -0.010583 0.107027 1.000010 0.171529 0.404278 0.244448 1.002170 NaN
model_3b init 0.005818 1.44555 0.125999 0.020191 0.224959 -0.012042 0.115427 1.000032 0.208475 0.415588 0.244080 1.007763 0.016418
estimate 0.005818 1.44555 0.126000 0.020191 0.224959 -0.012042 0.115427 1.000030 0.208475 0.415588 0.244080 1.007760 0.016418
model_4 init 0.005818 1.44555 0.126000 0.020191 0.224959 -0.012042 0.115427 1.000030 0.208475 0.415588 0.244080 1.007760 0.016418
estimate 0.007084 1.38635 0.220463 0.195326 0.176796 0.062712 0.117271 1.039930 0.446939 0.402075 0.249237 1.034610 0.015250

Relative difference between of the base model parameters estimates and the final model parameter estimates are calculated in base_parameter_change.

relative_change
TVCL 21.773218
TVV -4.095327
IVCL 98.520526
IVV -12.271369
SIGMA(1,1) -7.110618

OFV#

OFV of the base model, all intermediate models and the final FREM model are collected into ofv.

ofv
model_name
model_1 730.894727
model_2 896.974324
model_3 868.657803
model_3b 852.803483
model_4 753.302743

Estimated covariate values#

The FREM model also gives an estimate of the covariate values themselves. Ideally these values should be close to the ones in the dataset. Summary statistics for the estimated covariate values are put into estimated_covariates.

mean stdev
APGR 6.423728 2.237640
WGT 1.525424 0.704565

References#

[Yngman]

Yngman G, Nyberg HB, Nyberg J, Jonsson EN, Karlsson MO. An introduction to the full random effects model. CPT Pharmacometrics Syst Pharmacol. 2021;00:1– 12. https://doi.org/10.1002/psp4.12741