ML Covariate Screening With Synthetic PK Parameters

Purpose

This vignette demonstrates the public pharmax.ml workflow using synthetic data with a known covariate signal.

The example is exploratory decision support only. It is not regulatory validation and does not use proprietary clinical data.

library(pharmax.ml)

Synthetic Data

set.seed(2026)
n <- 120
demo <- data.frame(
  COV_WT = rnorm(n, 70, 10),
  COV_AGE = rnorm(n, 55, 12),
  COV_ALB = rnorm(n, 4.2, 0.4)
)
demo$ETA_CL <- 0.7 * scale(demo$COV_WT)[, 1] + rnorm(n, sd = 0.3)
demo$ETA_V <- 0.5 * scale(demo$COV_ALB)[, 1] + rnorm(n, sd = 0.4)

Data Quality

quality <- px_data_quality(demo)
quality
#> pharmax data quality report
#> 
#> # A tibble: 5 × 3
#>   column  missing_n missing_pct
#>   <chr>       <int>       <dbl>
#> 1 COV_WT          0           0
#> 2 COV_AGE         0           0
#> 3 COV_ALB         0           0
#> 4 ETA_CL          0           0
#> 5 ETA_V           0           0
#> 
#> # A tibble: 5 × 5
#>   column  outlier_n lower upper max_isolation_score
#>   <chr>       <int> <dbl> <dbl>               <dbl>
#> 1 COV_WT          0 38.7  98.1                 2.48
#> 2 COV_AGE         2 27.3  85.2                 2.82
#> 3 COV_ALB         0  3.13  5.28                2.64
#> 4 ETA_CL          0 -2.18  2.26                2.10
#> 5 ETA_V           0 -1.64  1.83                2.42

Covariate Screening

screen <- px_covariate(demo, method = "auto", n_top = 3)
screen
#> pharmax covariate screening
#> Method: auto 
#> 
#> Parameters: ETA_CL, ETA_V
#> Covariates: COV_WT, COV_AGE, COV_ALB
#> # A tibble: 6 × 6
#>   parameter covariate importance methods                  method_agreement  rank
#>   <chr>     <chr>          <dbl> <chr>                               <int> <int>
#> 1 ETA_CL    COV_WT       0.986   aalasso, cor, elastic_n…                5     1
#> 2 ETA_CL    COV_ALB      0.0111  aalasso, cor, elastic_n…                5     2
#> 3 ETA_CL    COV_AGE      0.00261 aalasso, cor, elastic_n…                5     3
#> 4 ETA_V     COV_ALB      0.972   aalasso, cor, elastic_n…                5     1
#> 5 ETA_V     COV_AGE      0.0159  aalasso, cor, elastic_n…                5     2
#> 6 ETA_V     COV_WT       0.0123  aalasso, cor, elastic_n…                5     3

Conformal Prediction

calibration_truth <- demo$ETA_CL[1:80]
calibration_pred <- calibration_truth + rnorm(80, sd = 0.2)
new_pred <- c(-0.5, 0, 0.5)

px_conformal(calibration_truth, calibration_pred, new_pred, alpha = 0.1)
#> # A tibble: 3 × 6
#>   prediction  lower  upper alpha method interval_width
#>        <dbl>  <dbl>  <dbl> <dbl> <chr>           <dbl>
#> 1       -0.5 -0.794 -0.206   0.1 split           0.588
#> 2        0   -0.294  0.294   0.1 split           0.588
#> 3        0.5  0.206  0.794   0.1 split           0.588

Interpretation

The known signal in this synthetic example is COV_WT for ETA_CL. A useful screening method should rank COV_WT highly. This is a functional demonstration, not proof of real-world clinical validity.