calculate_corr_from_prec#

pharmpy.modeling.calculate_corr_from_prec(precision_matrix)[source]#

Calculate correlation matrix from a precision matrix

Parameters:

precision_matrix (pd.DataFrame) – Precision matrix

Returns:

pd.DataFrame – Correlation matrix

Examples

>>> from pharmpy.modeling import calculate_corr_from_prec
>>> from pharmpy.tools import load_example_modelfit_results
>>> results = load_example_modelfit_results("pheno")
>>> prec = results.precision_matrix
>>> prec
               POP_CL        POP_VC       COVAPGR         IIV_CL        IIV_VC          SIGMA
POP_CL   2.993428e+07  22261.039122  16027.859538  203633.930854 -39113.269503 -817314.801755
POP_VC   2.226104e+04   2129.852212    260.115313    -373.896066  -2799.330946   -7697.921603
COVAPGR  1.602786e+04    260.115313    187.053488     177.987340   -205.261483   -2224.522815
IIV_CL   2.036339e+05   -373.896066    177.987340    7542.279597   2472.034556  -10209.416944
IIV_VC  -3.911327e+04  -2799.330946   -205.261483    2472.034556  22348.216559    9193.203130
SIGMA   -8.173148e+05  -7697.921603  -2224.522815  -10209.416944   9193.203130  249978.454601
>>> calculate_corr_from_prec(prec)
           POP_CL    POP_VC   COVAPGR    IIV_CL    IIV_VC     SIGMA
POP_CL   1.000000  0.008433 -0.095506 -0.387063  0.098882  0.168004
POP_VC   0.008433  1.000000 -0.357003  0.138290  0.356831  0.239295
COVAPGR -0.095506 -0.357003  1.000000 -0.095767 -0.062857  0.153034
IIV_CL  -0.387063  0.138290 -0.095767  1.000000 -0.185775  0.165104
IIV_VC   0.098882  0.356831 -0.062857 -0.185775  1.000000 -0.026388
SIGMA    0.168004  0.239295  0.153034  0.165104 -0.026388  1.000000

See also

calculate_se_from_cov

Standard errors from covariance matrix

calculate_se_from_prec

Standard errors from precision matrix

calculate_corr_from_cov

Correlation matrix from covariance matrix

calculate_cov_from_prec

Covariance matrix from precision matrix

calculate_cov_from_corrse

Covariance matrix from correlation matrix and standard errors

calculate_prec_from_cov

Precision matrix from covariance matrix

calculate_prec_from_corrse

Precision matrix from correlation matrix and standard errors