QA#
Pharmpy currently both has its own implementation of parts of the QA tool and can read the results from a PsN run.
Running#
The QA tool is available both in Pharmpy/pharmr and from the command line.
from pharmpy.modeling import read_model
from pharmpy.tools import read_modelfit_results, run_qa
model = read_model('path/to/model')
model_results = read_modelfit_results('path/to/model')
res = run_qa(model=model, results=model_results, linearize=False)
model <- read_model('path/to/model')
model_results <- read_modelfit_results('path/to/model')
res <- run_qa(model=model, results=model_results, linearize=FALSE)
Example of running QA from the command line:
pharmpy run qa run1.mod
Arguments#
Argument |
Description |
|---|---|
|
Input model |
|
ModelfitResults for the input model |
|
Whether to linearize input model before analysis |
|
Sections to skip (see Sections for valid options) |
Sections#
Currently, Pharmpy supports parts of the PsN QA tool, and more will be added. See PsN documentation for full description of the QA tool sections.
The following sections are currently supported:
Full OMEGA block (
'fullblock')Box-Cox transformation (
'boxcox')t-distribution (
'tdist')
The QA results#
Note
Since Pharmpy both has its own QA implementation and can read in PsN results, some sections are only applicable to PsN.
Overview#
The overview dofv table lists the most impactful modifications identified by QA.
More details for each result can be found in the individual sections.
The table shows an overview of possible modifications to different model aspects, expected improvements in OFV as well as number of additional parameters used.
| dofv | df | |||
|---|---|---|---|---|
| section | run | dvid | ||
| parameter_variability | fullblock | NaN | 2.592698 | 1.0 |
| boxcox | NaN | 2.197887 | 2.0 | |
| tdist | NaN | 0.007493 | 2.0 | |
| add_etas | NaN | NaN | NaN | |
| iov | NaN | NaN | NaN | |
| covariates | frem | NaN | 4.521171 | 4.0 |
| ET1APGR-2 | NaN | 2.487930 | 1.0 | |
| residual_error_model | dtbs | 1.0 | 13.910000 | 2.0 |
| time_varying | 1.0 | 8.030000 | 2.0 |
Structural bias#
Note
Only available from PsN run.
This section aims at diagnosing the structural component of the model. It does so by estimating the mean difference between model predictions and observations as a function of several independent variables.
The structural_bias table shows the CWRES and CPRED given different bins of the independent variable.
| binmin | binmax | cwres | cpred | |||
|---|---|---|---|---|---|---|
| idv | dvid | binid | ||||
| TIME | 1 | 1 | 0.00 | 2.00 | 0.28 | -6 |
| 2 | 2.00 | 2.55 | 0.12 | -2 | ||
| 3 | 2.55 | 11.00 | -0.29 | 6 | ||
| 4 | 11.00 | 47.25 | 0.04 | -1 | ||
| 5 | 47.25 | 63.50 | -0.39 | 7 | ||
| 6 | 63.50 | 83.10 | 0.20 | -4 | ||
| 7 | 83.10 | 112.30 | 0.11 | -2 | ||
| 8 | 112.30 | 135.50 | -0.29 | 5 | ||
| 9 | 135.50 | 159.80 | 0.19 | -4 | ||
| 10 | 159.80 | 390.00 | -0.02 | 1 | ||
| TAD | 1 | 1 | 0.00 | 1.50 | 0.06 | -1 |
| 2 | 1.50 | 2.00 | 0.41 | -8 | ||
| 3 | 2.00 | 3.00 | -0.13 | 3 | ||
| 4 | 3.00 | 6.00 | -0.06 | 1 | ||
| 5 | 6.00 | 11.00 | -0.18 | 3 | ||
| 6 | 11.00 | 11.50 | 0.54 | -10 | ||
| 7 | 11.50 | 11.70 | -0.24 | 4 | ||
| 8 | 11.70 | 14.00 | 0.06 | -1 | ||
| 9 | 14.00 | 258.00 | 0.07 | -1 | ||
| PRED | 1 | 1 | 8.00 | 17.67 | 0.19 | -5 |
| 2 | 17.67 | 19.50 | 0.10 | -1 | ||
| 3 | 19.50 | 20.13 | -0.17 | 3 | ||
| 4 | 20.13 | 21.39 | -0.01 | 0 | ||
| 5 | 21.39 | 24.32 | 0.24 | -4 | ||
| 6 | 24.32 | 26.63 | 0.06 | -1 | ||
| 7 | 26.63 | 28.70 | 0.05 | -1 | ||
| 8 | 28.70 | 31.28 | -0.05 | 1 | ||
| 9 | 31.28 | 36.34 | 0.07 | 0 | ||
| 10 | 36.34 | 54.00 | -0.47 | 9 |
Fullblock#
This section shows the effect of including a full block correlation structure in the base model.
The fullblock_parameters contains the estimated standard deviation (sd), correlation (corr) and
expected improvement in OFV after inclusion of a full block correlation structure of the random effects.
| new | old | |
|---|---|---|
| IVCL | 0.193808 | 0.171321 |
| IIV_CL_IIV_V | 0.675972 | NaN |
| IVV | 0.148029 | 0.167051 |
Boxcox#
This section shows the effect of applying a Box-Cox transformation to the ETA variables in the base model.
The boxcox_parameters contains the estimated shape parameter (Lambda) and expected improvment in OFV for a
Box-Cox transformation of the random effects.
| lambda | new_sd | old_sd | |
|---|---|---|---|
| ETA_1 | -0.894241 | 0.181988 | 0.171321 |
| ETA_2 | 2.050240 | 0.159271 | 0.167051 |
In Pharmpy, the following plots are generated showing the transformed and untransformed distribution for each eta:
Tdist#
This section shows the effect of applying a t-distribution transformation to the ETA variables in the base model.
The tdist_parameters contains the estimated degrees of freedom and expected improvement in OFV for a
t-distribution transformation of the random effects.
| df | new_sd | old_sd | |
|---|---|---|---|
| ETA(1) | 79.9997 | 0.168477 | 0.171306 |
| ETA(2) | 79.9986 | 0.166469 | 0.167053 |
In Pharmpy, the following plots are generated showing the transformed and untransformed distribution for each eta (sampling values from distribution with 1000 samples):
Residual error#
Note
Only available from PsN run.
This section shows the effect of including extended residual error models in the base model.
The residual_error table contains the residual error models, resulting expected improvement in OFV,
required additional model parameters as well as their estimates.
| dOFV | additional_parameters | parameters | ||
|---|---|---|---|---|
| DVID | model | |||
| 1.0 | dtbs | 13.91 | 2 | {'lambda': 0.242, 'zeta': 0.042} |
| time_varying | 8.03 | 2 | {'sdeps_0-t0': 0.271, 'sdeps_t0-390': 0.956, '... | |
| tdist | 5.53 | 1 | {'df': 5.106} | |
| autocorrelation | 3.34 | 1 | {'half-life': 16.7} | |
| IIV_on_RUV | 1.31 | 1 | {'%CV': 21.772} | |
| power | 0.03 | 1 | {'delta_power': -0.037} |
Covariate effects#
Note
Only available from PsN run.
This section evaluates the impact of supplied covariates.
The covariate_effects table shows the expected improvement when including covariates.
| dofv | coeff | ||
|---|---|---|---|
| parameter | covariate | ||
| ETA(1) | APGR | 2.48793 | -0.033334 |
| WGT | 0.48218 | 0.052342 | |
| ETA(2) | APGR | 0.59034 | 0.008371 |
| WGT | 0.00887 | -0.003273 |