UUPharmacometrics / xpose

Graphical diagnostics for pharmacometric models
https://uupharmacometrics.github.io/xpose
GNU Lesser General Public License v3.0
55 stars 28 forks source link

How to read OMEGA - COV MATRIX FOR RANDOM EFFECTS - ETAS #202

Closed mark0935git closed 2 years ago

mark0935git commented 2 years ago

Dear XPOSE developer,

get_prm() and prm_table read "OMEGA - CORR MATRIX FOR RANDOM EFFECTS - ETAS" rather than "OMEGA - COV MATRIX FOR RANDOM EFFECTS - ETAS" by default.

Is there a way to read OMEGA - COV MATRIX FOR RANDOM EFFECTS - ETAS using XPOSE functions?

Thanks!

bguiastr commented 2 years ago

Hello,

Yes xpose's strength is that it consolidates the NONMEM outputs into a tidy format i.e. the xpdb. From the xpdb you can access the content of the NONMEM tables, files and code.

I have created a small example to show you how you can access the files of interest for you:

library(xpose)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'xpose'
#> The following object is masked from 'package:stats':
#> 
#>     filter

## Check which files are available in the xpdb
list_files(xpdb_ex_pk)
#> Files:
#>   name       extension problem subprob method data               modified
#>   <chr>      <chr>       <dbl>   <dbl> <chr>  <list>             <lgl>   
#> 1 run001.cor cor             1       0 foce   <tibble [14 × 15]> FALSE   
#> 2 run001.cov cov             1       0 foce   <tibble [14 × 15]> FALSE   
#> 3 run001.ext ext             1       0 foce   <tibble [28 × 16]> FALSE   
#> 4 run001.grd grd             1       0 foce   <tibble [21 × 11]> FALSE   
#> 5 run001.phi phi             1       0 foce   <tibble [74 × 12]> FALSE   
#> 6 run001.shk shk             1       0 foce   <tibble [7 × 5]>   FALSE

## Get the correlation matrix
get_file(xpdb_ex_pk, ext  = "cor")
#> Returning data from run001.cor, $prob no.1, subprob no.0, method foce
#> # A tibble: 14 × 15
#>    NAME        THETA1  THETA2 THETA3  THETA4  THETA5   THETA6   THETA7 SIGMA(1…¹
#>    <chr>        <dbl>   <dbl>  <dbl>   <dbl>   <dbl>    <dbl>    <dbl>     <dbl>
#>  1 THETA1      0.891   0.525   0.100 -0.246   0.0435  0.193   -0.218           0
#>  2 THETA2      0.525   0.0438 -0.234 -0.0932  0.257  -0.0198   0.0734          0
#>  3 THETA3      0.100  -0.234   0.809  0.253  -0.259  -0.220   -0.229           0
#>  4 THETA4     -0.246  -0.0932  0.253  0.0157 -0.164  -0.266    0.0924          0
#>  5 THETA5      0.0435  0.257  -0.259 -0.164   0.0224 -0.383    0.0827          0
#>  6 THETA6      0.193  -0.0198 -0.220 -0.266  -0.383   0.00366 -0.255           0
#>  7 THETA7     -0.218   0.0734 -0.229  0.0924  0.0827 -0.255    0.00170         0
#>  8 SIGMA(1,1)  0       0       0      0       0       0        0               0
#>  9 OMEGA(1,1) -0.115  -0.145   0.165 -0.139  -0.293   0.246   -0.0780          0
#> 10 OMEGA(2,1)  0       0       0      0       0       0        0               0
#> 11 OMEGA(2,2) -0.111  -0.0232 -0.131 -0.0750 -0.366   0.222    0.0787          0
#> 12 OMEGA(3,1)  0       0       0      0       0       0        0               0
#> 13 OMEGA(3,2)  0       0       0      0       0       0        0               0
#> 14 OMEGA(3,3)  0.155  -0.296   0.829  0.204  -0.228   0.00578 -0.268           0
#> # … with 6 more variables: `OMEGA(1,1)` <dbl>, `OMEGA(2,1)` <dbl>,
#> #   `OMEGA(2,2)` <dbl>, `OMEGA(3,1)` <dbl>, `OMEGA(3,2)` <dbl>,
#> #   `OMEGA(3,3)` <dbl>, and abbreviated variable name ¹​`SIGMA(1,1)`

## Get the covariance matrix
get_file(xpdb_ex_pk, ext  = "cov")
#> Returning data from run001.cov, $prob no.1, subprob no.0, method foce
#> # A tibble: 14 × 15
#>    NAME     THETA1   THETA2   THETA3   THETA4   THETA5   THETA6   THETA7 SIGMA…¹
#>    <chr>     <dbl>    <dbl>    <dbl>    <dbl>    <dbl>    <dbl>    <dbl>   <dbl>
#>  1 THETA1  7.95e-1  2.05e-2  7.22e-2 -3.45e-3  8.71e-4  6.30e-4 -3.30e-4       0
#>  2 THETA2  2.05e-2  1.92e-3 -8.30e-3 -6.42e-5  2.53e-4 -3.17e-6  5.46e-6       0
#>  3 THETA3  7.22e-2 -8.30e-3  6.55e-1  3.22e-3 -4.71e-3 -6.52e-4 -3.15e-4       0
#>  4 THETA4 -3.45e-3 -6.42e-5  3.22e-3  2.47e-4 -5.79e-5 -1.53e-5  2.46e-6       0
#>  5 THETA5  8.71e-4  2.53e-4 -4.71e-3 -5.79e-5  5.04e-4 -3.14e-5  3.15e-6       0
#>  6 THETA6  6.30e-4 -3.17e-6 -6.52e-4 -1.53e-5 -3.14e-5  1.34e-5 -1.58e-6       0
#>  7 THETA7 -3.30e-4  5.46e-6 -3.15e-4  2.46e-6  3.15e-6 -1.58e-6  2.88e-6       0
#>  8 SIGMA…  0        0        0        0        0        0        0             0
#>  9 OMEGA… -1.29e-3 -7.97e-5  1.68e-3 -2.75e-5 -8.26e-5  1.13e-5 -1.66e-6       0
#> 10 OMEGA…  0        0        0        0        0        0        0             0
#> 11 OMEGA… -1.23e-3 -1.27e-5 -1.33e-3 -1.47e-5 -1.03e-4  1.02e-5  1.67e-6       0
#> 12 OMEGA…  0        0        0        0        0        0        0             0
#> 13 OMEGA…  0        0        0        0        0        0        0             0
#> 14 OMEGA…  7.69e-2 -7.23e-3  3.74e-1  1.79e-3 -2.85e-3  1.18e-5 -2.54e-4       0
#> # … with 6 more variables: `OMEGA(1,1)` <dbl>, `OMEGA(2,1)` <dbl>,
#> #   `OMEGA(2,2)` <dbl>, `OMEGA(3,1)` <dbl>, `OMEGA(3,2)` <dbl>,
#> #   `OMEGA(3,3)` <dbl>, and abbreviated variable name ¹​`SIGMA(1,1)`

Created on 2022-10-21 with reprex v2.0.2