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
                  PTVCL          PTVV       THETA_3           IVCL           IVV      SIGMA_1_1
PTVCL      2.995567e+07  22660.028196  16057.855248  203511.614428 -39474.250514 -820118.299536
PTVV       2.266003e+04   2129.904642    260.176234    -375.266233  -2800.816246   -7718.769557
THETA_3    1.605786e+04    260.176234    187.038903     177.207683   -205.808480   -2225.150449
IVCL       2.035116e+05   -375.266233    177.207683    7527.530027   2462.974821   -9977.488860
IVV       -3.947425e+04  -2800.816246   -205.808480    2462.974821  22343.198618    9370.758371
SIGMA_1_1 -8.201183e+05  -7718.769557  -2225.150449   -9977.488860   9370.758371  249847.177845
>>> calculate_corr_from_prec(prec)
              PTVCL      PTVV   THETA_3      IVCL       IVV  SIGMA_1_1
PTVCL      1.000000  0.007099 -0.094640 -0.388059  0.097981   0.170820
PTVV       0.007099  1.000000 -0.356899  0.138062  0.356662   0.238441
THETA_3   -0.094640 -0.356899  1.000000 -0.096515 -0.062991   0.153616
IVCL      -0.388059  0.138062 -0.096515  1.000000 -0.185111   0.159170
IVV        0.097981  0.356662 -0.062991 -0.185111  1.000000  -0.027495
SIGMA_1_1  0.170820  0.238441  0.153616  0.159170 -0.027495   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