calculate_cov_from_corrse#

pharmpy.modeling.calculate_cov_from_corrse(corr, se)[source]#

Calculate covariance matrix from a correlation matrix and standard errors

Parameters:
  • corr (pd.DataFrame) – Correlation matrix

  • se (pd.Series) – Standard errors

Returns:

pd.DataFrame – Covariance matrix

Examples

>>> from pharmpy.modeling import calculate_cov_from_corrse
>>> from pharmpy.tools import load_example_modelfit_results
>>> results = load_example_modelfit_results("pheno")
>>> corr = results.correlation_matrix
>>> se = results.standard_errors
>>> corr
           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
>>> calculate_cov_from_corrse(corr, se)
               POP_CL        POP_VC   COVAPGR    IIV_CL        IIV_VC         SIGMA
POP_CL   4.408614e-08  4.761939e-08 -0.000002 -0.000001  1.552153e-07  8.042458e-08
POP_VC   4.761939e-08  7.233195e-04 -0.000804  0.000050  7.174494e-05  1.467293e-05
COVAPGR -1.679562e-06 -8.041749e-04  0.007015 -0.000108 -3.935789e-05  2.922264e-05
IIV_CL  -1.090293e-06  4.989586e-05 -0.000108  0.000180 -1.863212e-05  5.049924e-06
IIV_VC   1.552153e-07  7.174494e-05 -0.000039 -0.000019  5.588923e-05 -4.497600e-07
SIGMA    8.042458e-08  1.467293e-05  0.000029  0.000005 -4.497600e-07  5.197990e-06

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_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