## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(ReproStat) set.seed(20260324) ## ----pattern1----------------------------------------------------------------- diag_obj <- run_diagnostics( mpg ~ wt + hp + disp, data = mtcars, B = 200, method = "bootstrap" ) reproducibility_index(diag_obj) selection_stability(diag_obj) ## ----pattern2----------------------------------------------------------------- diag_sub <- run_diagnostics( mpg ~ wt + hp + disp, data = mtcars, B = 200, method = "subsample", frac = 0.75 ) reproducibility_index(diag_sub) ## ----pattern3----------------------------------------------------------------- diag_noise <- run_diagnostics( mpg ~ wt + hp + disp, data = mtcars, B = 150, method = "noise", noise_sd = 0.05 ) reproducibility_index(diag_noise) prediction_stability(diag_noise)$mean_variance ## ----pattern4----------------------------------------------------------------- diag_glm <- run_diagnostics( am ~ wt + hp + qsec, data = mtcars, B = 150, backend = "glm", family = stats::binomial() ) reproducibility_index(diag_glm) ## ----pattern5, eval = requireNamespace("MASS", quietly = TRUE)---------------- if (requireNamespace("MASS", quietly = TRUE)) { diag_rlm <- run_diagnostics( mpg ~ wt + hp + disp, data = mtcars, B = 150, backend = "rlm" ) reproducibility_index(diag_rlm) } ## ----pattern6, eval = requireNamespace("glmnet", quietly = TRUE)-------------- if (requireNamespace("glmnet", quietly = TRUE)) { diag_lasso <- run_diagnostics( mpg ~ wt + hp + disp + qsec, data = mtcars, B = 150, backend = "glmnet", en_alpha = 1 ) reproducibility_index(diag_lasso) selection_stability(diag_lasso) } ## ----pattern7----------------------------------------------------------------- models <- list( compact = mpg ~ wt + hp, standard = mpg ~ wt + hp + disp, expanded = mpg ~ wt + hp + disp + qsec ) cv_obj <- cv_ranking_stability(models, mtcars, v = 5, R = 40) cv_obj$summary ## ----pattern8----------------------------------------------------------------- diag_obj <- run_diagnostics( mpg ~ wt + hp + disp, data = mtcars, B = 150, method = "bootstrap" ) ri <- reproducibility_index(diag_obj) ci <- ri_confidence_interval(diag_obj, R = 300, seed = 1) ri ci