1 Introduction

This vignette shows how iconic stress-tests a causal estimate by replaying the analysis on synthetic data that preserve the observed feature texture while sweeping the strength of unmeasured confounding and instrument exogeneity violations.

2 Installation

iconic is being submitted to Bioconductor. Once accepted, install the release version with:

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("iconic")

The development version is available from GitHub:

BiocManager::install("sbresnahan/iconic")

3 What sensitivity analysis does

Even after diagnosis declares an estimator eligible, its validity rests on the assumption that the genetic instrument is exogenous — that the instrument-confounder correlations \(\rho_{G1}\) and \(\rho_{G2}\) are zero. These correlations cannot be estimated from data (the confounders are unobserved), so iconic_sensitivity() sweeps them over a plausible grid and reports how each estimator’s bias degrades.

The output reports, for each estimator:

  • Maximum absolute bias across the sensitivity surface.
  • Tipping points: the first \(\rho_{G2}\) at \(\rho_{G1} = 0\) where \(|\text{bias}| > 0.10\).
  • Texture source: whether the synthetic data used the generative texture model (GAN + copula) or the parametric benchmark generator.

4 A minimal example

We simulate a small mediation panel, train a texture model briefly, and run the sensitivity sweep.

dat <- generate_toy_data(
    n = 200, n_features = 10, seed = 1,
    phi = 0.8, omega_1 = 0.7, omega_2 = 0.7
)

idat <- iconic_data(
    X = dat$X, Y = dat$Y, M = dat$M,
    G = dat$G, Gm = dat$Gm,
    W1 = dat$W1, W2 = dat$W2,
    covariates = dat$synthetic_data
)
# Train a texture model briefly and attach it to the iconic_data object.
input <- load_real_input_data(
    X_matrix = matrix(dat$X, nrow = 1),
    Y_matrix = t(dat$Y), M_matrix = t(dat$M),
    W_matrix = t(dat$W), covariates_df = dat$synthetic_data
)

idat$trained_gan <- train_gan_on_real_data(
    input$gan_training_data,
    feature_correlations = input$feature_correlations,
    feature_texture = input$feature_texture,
    epochs = 5, seed = 1, verbose = FALSE
)

The sensitivity-sweep chunks in this vignette are skipped because torch is not available. Install torch with install.packages("torch") and run torch::install_torch() to run them.

sens <- iconic_sensitivity(idat, n_iter = 3)
sens

5 Inferring confounding from the data

infer_confounding() estimates the held-fixed confounding parameters from your data, supplying a confounding = "inferred" mode for iconic_sensitivity() and iconic_prospect().

diag <- iconic_diagnose(idat)
est <- iconic_estimate(idat, diagnosis = diag)
conf <- infer_confounding(idat, diag, est)
conf
#> <iconic_confounding>
#>  conf_strength    0.409 (UNADJ-IV2SLS gap (NDE))
#>  mo_confounding   0.025 (IV2SLS-IV2SLS2 NIE gap)
#>  omega_1          0.485 (sqrt(R^2) of W on Y residualized on X+C)
#>  warning: composite: coverage x confounder strength, not pure coverage
#>  omega_2          0.484 (sqrt(R^2) of W on Y residualized on X+C)
#>  warning: composite: coverage x confounder strength, not pure coverage
#>  k                1 [CI: 1, 2] (parallel analysis (Horn, 1965))
#> 
#>  Unavailable: rho_G1, rho_G2

The inferred parameters include:

  • Confounding strength (\(\delta\)): from the gap between unadjusted OLS and IV2SLS estimates.
  • Mediator-outcome confounding (\(\delta_{mo}\)): from the gap between IV2SLS and IV2SLS2 natural indirect effects.
  • Negative-control coverage (\(\omega_1\), \(\omega_2\)): from the \(R^2\) of each NC feature regressed on the outcome residual.
  • Number of latent confounders (\(k\)): via parallel analysis on the residualized outcome correlation matrix.

Parameters that cannot be inferred (the instrument-confounder correlations \(\rho_{G1}\), \(\rho_{G2}\)) fall back to defaults with a warning and are always swept.

6 Inferred vs. default confounding

sens_inf <- iconic_sensitivity(idat, n_iter = 3, confounding = "inferred")
sens_inf

The confounding = "default" mode uses fixed defaults (\(\delta_{mo} = 0.8\), \(\omega_1 = \omega_2 = 0.7\), \(\phi = 0.8\)) and is the recommended starting point. The confounding = "inferred" mode calibrates to your data but uses estimator validity (e.g., that IV2SLS is unbiased) to set up a benchmark whose purpose is to test estimator validity — so inferred values should be read as best-case calibrations under the stated assumptions.

7 Further reading

  • Texture model vignette: vignette("iconic-texture-model") — how the GAN + copula texture model is trained and why it matters for sensitivity.
  • Function reference: ?iconic_sensitivity for the full argument list, including the \(\rho_{G1} \times \rho_{G2}\) grid and the n_iter control.

8 Session information

sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.24-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] MultiAssayExperiment_1.39.1 SummarizedExperiment_1.43.0
#>  [3] Biobase_2.73.2              MatrixGenerics_1.25.0      
#>  [5] matrixStats_1.5.0           GenomicRanges_1.65.4       
#>  [7] Seqinfo_1.3.2               IRanges_2.47.5             
#>  [9] S4Vectors_0.51.10           BiocGenerics_0.59.13       
#> [11] generics_0.1.4              doRNG_1.8.6.3              
#> [13] rngtools_1.5.2              foreach_1.5.2              
#> [15] iconic_0.99.5               BiocStyle_2.41.0           
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.1    bigsnpr_1.12.21     dplyr_1.2.1        
#>  [4] farver_2.1.2        S7_0.2.2            fastmap_1.2.0      
#>  [7] bigassertr_0.2.0    flock_0.7           digest_0.6.39      
#> [10] lifecycle_1.0.5     survival_3.8-12     processx_3.9.0     
#> [13] magrittr_2.0.5      compiler_4.6.1      rlang_1.3.0        
#> [16] sass_0.4.10         tools_4.6.1         yaml_2.3.12        
#> [19] data.table_1.18.6.1 knitr_1.52          S4Arrays_1.13.2    
#> [22] bit_4.6.0           DelayedArray_0.39.8 RColorBrewer_1.1-3 
#> [25] rmio_0.4.0          abind_1.4-8         bigsparser_0.7.3   
#> [28] withr_3.0.3         bigstatsr_1.6.2     grid_4.6.1         
#> [31] ggplot2_4.0.4       scales_1.4.0        iterators_1.0.14   
#> [34] dichromat_2.0-1     cli_3.6.6           rmarkdown_2.32     
#> [37] otel_0.3.0          cachem_1.1.0        splines_4.6.1      
#> [40] parallel_4.6.1      BiocManager_1.30.27 XVector_0.53.0     
#> [43] coro_1.1.0          vctrs_0.7.3         glmnet_5.2         
#> [46] Matrix_1.7-6        jsonlite_2.0.0      bookdown_0.48      
#> [49] callr_3.8.0         bit64_4.8.6         irlba_2.4.1        
#> [52] jquerylib_0.1.4     bigparallelr_0.3.2  glue_1.8.1         
#> [55] codetools_0.2-20    ps_1.9.3            cowplot_1.2.0      
#> [58] gtable_0.3.6        shape_1.4.6.1       tibble_3.3.1       
#> [61] pillar_1.11.1       htmltools_0.5.9     torch_0.17.0       
#> [64] R6_2.6.1            ff_4.5.3            doParallel_1.0.17  
#> [67] evaluate_1.0.5      lattice_0.23-1      bslib_0.12.0       
#> [70] Rcpp_1.1.2          SparseArray_1.13.5  xfun_0.62          
#> [73] pkgconfig_2.0.3