calculate_corr_from_cov#

pharmpy.modeling.calculate_corr_from_cov(cov)[source]#

Calculate correlation matrix from a covariance matrix

Parameters:

cov (pd.DataFrame) – Covariance matrix

Returns:

pd.DataFrame – Correlation matrix

Examples

>>> from pharmpy.modeling import calculate_corr_from_cov
>>> from pharmpy.tools import load_example_modelfit_results
>>> results = load_example_modelfit_results("pheno")
>>> cov = results.covariance_matrix
>>> cov
               POP_CL        POP_VC  COVAPGR    IIV_CL        IIV_VC         SIGMA
POP_CL   4.408600e-08  4.761930e-08 -0.000002 -0.000001  1.552150e-07  8.042430e-08
POP_VC   4.761930e-08  7.233190e-04 -0.000804  0.000050  7.174490e-05  1.467290e-05
COVAPGR -1.679560e-06 -8.041750e-04  0.007015 -0.000108 -3.935790e-05  2.922260e-05
IIV_CL  -1.090290e-06  4.989580e-05 -0.000108  0.000180 -1.863210e-05  5.049910e-06
IIV_VC   1.552150e-07  7.174490e-05 -0.000039 -0.000019  5.588920e-05 -4.497590e-07
SIGMA    8.042430e-08  1.467290e-05  0.000029  0.000005 -4.497590e-07  5.197970e-06
>>> calculate_corr_from_cov(cov)
           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_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

calculate_corr_from_prec

Correlation matrix from precision matrix