comparison-tables
comparison-tables.Rmd
library(hyperion.tables)
library(hyperion)
#>
#>
#> ── pharos configuration ────────────────────────────────────────────────────────
#> ✔ pharos.toml found: /data/user-homes/tariq/projects/prism-pkgdocs-build/installed-pkgs/2026-03-02/hyperion.tables_0.3.0/vignettes/pharos.toml
#> ── hyperion options ────────────────────────────────────────────────────────────
#> ✔ hyperion.significant_number_display : 4
#> ── hyperion nonmem object options ──────────────────────────────────────────────
#> ✔ hyperion.nonmem_model.show_included_columns : FALSE
#> ✔ hyperion.nonmem_summary.rse_threshold : 50
#> ✔ hyperion.nonmem_summary.shrinkage_threshold : 30
library(gt)
library(flextable)
model_dir <- system.file("extdata", "models", "onecmt", package = "hyperion.tables")
model_run <- "run003"Model Comparison
spec <- TableSpec() |>
set_spec_transforms(omega = "cv") |>
set_spec_sections(
kind == "THETA" ~ "Structural model parameters",
kind == "OMEGA" & diagonal ~ "Interindividual variance parameters",
kind == "OMEGA" & !diagonal ~ "Interindividual covariance parameters",
kind == "SIGMA" ~ "Residual variance",
TRUE ~ "Other"
) |>
set_spec_sigfig(3) |>
drop_spec_columns("variability", "shrinkage", "rse") |>
set_spec_pvalue(scientific = FALSE)
child_mod <- read_model(file.path(model_dir, paste0(model_run, ".mod")))
child_sum <- summary(child_mod)
child_info <- get_model_parameter_info(child_mod)
parent_mod <- read_model(file.path(model_dir, "run002.mod"))
mod_sum <- summary(parent_mod)
info <- get_model_parameter_info(parent_mod)
get_parameters(parent_mod) |>
apply_table_spec(spec, info) |>
add_summary_info(mod_sum) |>
compare_with(
get_parameters(child_mod) |>
apply_table_spec(spec, child_info) |>
add_summary_info(child_sum),
labels = c("run002", "run003")
) |>
make_comparison_table()
#> LRT suppressed for run002 vs run003: no lineage attached
#> ℹ Both OFVs and matching observation counts are present, but LRT conditions are not met.| Model Parameters | |||||||||
| Parameter |
run002
|
run003
|
|||||||
|---|---|---|---|---|---|---|---|---|---|
| Symbol | Unit | Estimate | 95% CI | Symbol | Unit | Estimate | 95% CI | % Change | |
| Structural model parameters | |||||||||
| TVCL | L/hr | 1.25 | [0.994, 1.50] | L/hr | 1.33 | [1.11, 1.54] | 6.31 | ||
| TVV | L | 40.8 | [34.9, 46.8] | L | 40.2 | [34.6, 45.7] | -1.68 | ||
| TVKA | 1/hr | 1.24 | [1.02, 1.47] | 1/hr | 1.21 | [0.997, 1.43] | -2.59 | ||
| Interindividual variance parameters | |||||||||
| OM1 TVCL | 0.130 | [0.0125, 0.248] | 0.122 | [0.0236, 0.221] | -6.19 | ||||
| OM2 TVV | 0.136 | [0.0585, 0.214] | 0.124 | [0.0519, 0.196] | -9.14 | ||||
| OM3 TVKA | 0.114 | [-0.00602, 0.235] | 0.122 | [0.0121, 0.233] | 7.00 | ||||
| Interindividual covariance parameters | |||||||||
| OM1,2 TVCL, TVV | 0.0745 | [0.0131, 0.136] | |||||||
| Residual variance | |||||||||
| SIG1 | 0.0372 | [0.0145, 0.0600] | 0.0375 | [0.0257, 0.0494] | 0.820 | ||||
| SIG2 | 0.00661 | [-0.0481, 0.0613] | 0.00527 | [-0.0128, 0.0233] | -20.2 | ||||
| Condition Number: 29.6 (run002), 6.17 (run003) | |||||||||
| No. of Observations: 210 (run002), 210 (run003) | |||||||||
| OFV: -103.468 (run002), -109.826 (run003) | |||||||||
| 95% CI: | |||||||||
| % Change: | |||||||||
| Abbreviations: | |||||||||
| CI = confidence intervals; RSE = relative standard error; SE = standard error; | |||||||||
| OFV = Objective Function Value | |||||||||
Multiple Comparison Table
spec <- TableSpec() |>
set_spec_transforms(omega = "cv") |>
set_spec_sections(
kind == "THETA" ~ "Structural model parameters",
kind == "OMEGA" & diagonal ~ "Interindividual variance parameters",
kind == "OMEGA" & !diagonal ~ "Interindividual covariance parameters",
kind == "SIGMA" ~ "Residual error",
TRUE ~ "Other"
) |>
set_spec_sigfig(3) |>
set_spec_columns("symbol", "estimate", "ci", "rse", "pct_change") |>
set_spec_hide_empty(FALSE)
mod1 <- read_model(file.path(model_dir, "run002.mod"))
mod_sum1 <- summary(mod1)
info1 <- get_model_parameter_info(mod1)
mod2 <- read_model(file.path(model_dir, "run003.mod"))
mod_sum2 <- summary(mod2)
info2 <- get_model_parameter_info(mod2)
mod3 <- read_model(file.path(model_dir, "run003b1.mod"))
mod_sum3 <- summary(mod3)
info3 <- get_model_parameter_info(mod3)
comp <- get_parameters(mod1) |>
apply_table_spec(spec, info1) |>
add_summary_info(mod_sum1) |>
compare_with(
get_parameters(mod2) |>
apply_table_spec(spec, info2) |>
add_summary_info(mod_sum2),
labels = c("run002", "run003")
) |>
compare_with(
get_parameters(mod3) |>
apply_table_spec(spec, info3) |>
add_summary_info(mod_sum3),
labels = c("run003b1")
)
comp |>
make_comparison_table()
#> LRT suppressed for run002 vs run003: no lineage attached
#> ℹ Both OFVs and matching observation counts are present, but LRT conditions are not met.
#> LRT suppressed for run003 vs run003b1: no lineage attached
#> ℹ Both OFVs and matching observation counts are present, but LRT conditions are not met.| Model Parameters | ||||||||||||||
| Parameter |
run002
|
run003
|
run003b1
|
|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Symbol | Estimate | 95% CI | RSE (%) | Symbol | Estimate | 95% CI | RSE (%) | % Change vs run002 | Symbol | Estimate | 95% CI | RSE (%) | % Change vs run003 | |
| Structural model parameters | ||||||||||||||
| TVCL | 1.25 | [0.994, 1.50] | 10.3 | 1.33 | [1.11, 1.54] | 8.41 | 6.31 | 1.25 | -5.67 | |||||
| TVV | 40.8 | [34.9, 46.8] | 7.41 | 40.2 | [34.6, 45.7] | 7.07 | -1.68 | 40.3 | 0.296 | |||||
| TVKA | 1.24 | [1.02, 1.47] | 9.12 | 1.21 | [0.997, 1.43] | 9.06 | -2.59 | 1.22 | 0.490 | |||||
| WT-on-CL | 0.545 | |||||||||||||
| Interindividual variance parameters | ||||||||||||||
| OM1 TVCL | 0.130 | [0.0125, 0.248] | 46.1 | 0.122 | [0.0236, 0.221] | 41.2 | -6.19 | 0.123 | 0.756 | |||||
| OM2 TVV | 0.136 | [0.0585, 0.214] | 29.1 | 0.124 | [0.0519, 0.196] | 29.7 | -9.14 | 0.125 | 0.587 | |||||
| OM3 TVKA | 0.114 | [-0.00602, 0.235] | 53.7 | 0.122 | [0.0121, 0.233] | 46.0 | 7.00 | 0.124 | 1.20 | |||||
| Interindividual covariance parameters | ||||||||||||||
| OM1,2 TVCL, TVV | 0.0745 | [0.0131, 0.136] | 42.0 | 0.0722 | -3.17 | |||||||||
| Residual error | ||||||||||||||
| SIG1 | 0.0372 | [0.0145, 0.0600] | 31.2 | 0.0375 | [0.0257, 0.0494] | 16.1 | 0.820 | 0.0374 | -0.496 | |||||
| SIG2 | 0.00661 | [-0.0481, 0.0613] | 423 | 0.00527 | [-0.0128, 0.0233] | 175 | -20.2 | 0.00589 | 11.8 | |||||
| Condition Number: 29.6 (run002), 6.17 (run003) | ||||||||||||||
| No. of Observations: 210 (run002), 210 (run003) | ||||||||||||||
| OFV: -103.468 (run002), -109.826 (run003) | ||||||||||||||
| Condition Number: 6.17 (run003), N/A (run003b1) | ||||||||||||||
| No. of Observations: 210 (run003), 210 (run003b1) | ||||||||||||||
| OFV: -109.826 (run003), -108.889 (run003b1) | ||||||||||||||
| 95% CI: | ||||||||||||||
| % Change: | ||||||||||||||
| Abbreviations: | ||||||||||||||
| CI = confidence intervals; RSE = relative standard error; SE = standard error; | ||||||||||||||
| OFV = Objective Function Value | ||||||||||||||
Structural model comparison
spec <- TableSpec() |>
set_spec_transforms(omega = "cv") |>
set_spec_sections(
kind == "THETA" ~ "Structural model parameters",
kind == "OMEGA" & diagonal ~ "Interindividual variance parameters",
kind == "OMEGA" & !diagonal ~ "Interindividual covariance parameters",
kind == "SIGMA" ~ "Residual error",
TRUE ~ "Other"
) |>
set_spec_sigfig(3) |>
set_spec_columns("symbol", "fixed", "estimate") |>
set_spec_title("Structural Model Parameter Comparison")
mod1 <- read_model(file.path(model_dir, "run001.mod"))
mod_sum1 <- summary(mod1)
info1 <- get_model_parameter_info(mod1)
mod2 <- read_model(file.path(model_dir, "run002.mod"))
mod_sum2 <- summary(mod2)
info2 <- get_model_parameter_info(mod2)
mod3 <- read_model(file.path(model_dir, "run003.mod"))
mod_sum3 <- summary(mod3)
info3 <- get_model_parameter_info(mod3)
mod4 <- read_model(file.path(model_dir, "run003b1.mod"))
mod_sum4 <- summary(mod4)
info4 <- get_model_parameter_info(mod4)
comp <- get_parameters(mod1) |>
apply_table_spec(spec, info1) |>
add_summary_info(mod_sum1) |>
compare_with(
get_parameters(mod2) |>
apply_table_spec(spec, info2) |>
add_summary_info(mod_sum2),
labels = c("run001", "run002")
) |>
compare_with(
get_parameters(mod3) |>
apply_table_spec(spec, info3) |>
add_summary_info(mod_sum3),
labels = c("run003")
) |>
compare_with(
get_parameters(mod4) |>
apply_table_spec(spec, info4) |>
add_summary_info(mod_sum4),
labels = c("run004")
)
comp |>
make_comparison_table()
#> LRT suppressed for run001 vs run002: no lineage attached
#> ℹ Both OFVs and matching observation counts are present, but LRT conditions are not met.
#> LRT suppressed for run002 vs run003: no lineage attached
#> ℹ Both OFVs and matching observation counts are present, but LRT conditions are not met.
#> LRT suppressed for run003 vs run004: no lineage attached
#> ℹ Both OFVs and matching observation counts are present, but LRT conditions are not met.| Structural Model Parameter Comparison | ||||||||||||
| Parameter |
run001
|
run002
|
run003
|
run004
|
||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Symbol | Fixed | Estimate | Symbol | Fixed | Estimate | Symbol | Fixed | Estimate | Symbol | Fixed | Estimate | |
| Structural model parameters | ||||||||||||
| TVCL | 1.24 | 1.25 | 1.33 | 1.25 | ||||||||
| TVV | 40.9 | 40.8 | 40.2 | 40.3 | ||||||||
| TVKA | 1.24 | 1.24 | 1.21 | 1.22 | ||||||||
| WT-on-CL | 0.545 | |||||||||||
| Interindividual variance parameters | ||||||||||||
| OM1 TVCL | 0.131 | 0.130 | 0.122 | 0.123 | ||||||||
| OM2 TVV | 0.136 | 0.136 | 0.124 | 0.125 | ||||||||
| OM3 TVKA | Fixed | 0.100 | 0.114 | 0.122 | 0.124 | |||||||
| Interindividual covariance parameters | ||||||||||||
| OM1,2 TVCL, TVV | 0.0745 | 0.0722 | ||||||||||
| Residual error | ||||||||||||
| Proportional | 0.0364 | |||||||||||
| Additive | Fixed | 0.0100 | ||||||||||
| SIG1 | 0.0372 | 0.0375 | 0.0374 | |||||||||
| SIG2 | 0.00661 | 0.00527 | 0.00589 | |||||||||
| Condition Number: 1.98 (run001), 29.6 (run002) | ||||||||||||
| No. of Observations: 210 (run001), 210 (run002) | ||||||||||||
| OFV: -103.299 (run001), -103.468 (run002) | ||||||||||||
| Condition Number: 29.6 (run002), 6.17 (run003) | ||||||||||||
| No. of Observations: 210 (run002), 210 (run003) | ||||||||||||
| OFV: -103.468 (run002), -109.826 (run003) | ||||||||||||
| Condition Number: 6.17 (run003), N/A (run004) | ||||||||||||
| No. of Observations: 210 (run003), 210 (run004) | ||||||||||||
| OFV: -109.826 (run003), -108.889 (run004) | ||||||||||||
| % Change: | ||||||||||||
| Abbreviations: | ||||||||||||
| OFV = Objective Function Value | ||||||||||||