Last updated: 2022-03-17

Checks: 7 0

Knit directory: ampel-leipzig-meld/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210604) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version ef54ecf. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    _targets/
    Ignored:    container/
    Ignored:    logs/

Untracked files:
    Untracked:  1907.00825.pdf
    Untracked:  METHODS
    Untracked:  TODO
    Untracked:  s12874-018-0482-1.pdf
    Untracked:  scripts/R.sh
    Untracked:  scripts/env.sh

Unstaged changes:
    Modified:   code/01-data.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/elasticnet.Rmd) and HTML (docs/elasticnet.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 057f935 Sebastian Gibb 2022-03-17 feat: add elastic net bootstrap and timeROC evaluations

library("targets")
library("ameld")
library("viridisLite")
tar_load(arcvob)
tar_load(bootrcv)
tar_load(bootarcv)
#tar_load(bootarcv9)
tar_load(amelddata)
tar_load(ameldcfg)
tar_load(zlog_data)

1 Tuning alpha

arcvob

Call: arcv.glmnet(x = amelddata$x, y = amelddata$y, alpha = ameldcfg$alpha,      nrepcv = ameldcfg$nrepcv, nfolds = ameldcfg$nfolds, balanced = TRUE,      family = "cox", standardize = ameldcfg$standardize, trace.it = FALSE) 

Models: 11
Alpha: 0 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 1
Number of CV for Lambda: 3
Number of repeated CV for Lambda: 100


Measure: Partial Likelihood Deviance 

Lambda min:
      Alpha  Lambda Index Measure     SE Nonzero
 [1,] 0.000 1.09708    71   9.024 0.2846      42
 [2,] 0.001 1.09708    71   9.024 0.2844      37
 [3,] 0.008 0.96746    50   9.022 0.2844      26
 [4,] 0.027 0.79764    39   9.024 0.2838      19
 [5,] 0.064 0.53581    34   9.039 0.2858      18
 [6,] 0.125 0.39801    30   9.059 0.2860      16
 [7,] 0.216 0.27743    28   9.076 0.2868      12
 [8,] 0.343 0.19174    27   9.092 0.2880      11
 [9,] 0.512 0.14098    26   9.107 0.2877       9
[10,] 0.729 0.09901    26   9.120 0.2900       9
[11,] 1.000 0.07218    26   9.129 0.2919       9

Lambda 1se:
      Alpha Lambda Index Measure     SE Nonzero
 [1,] 0.000 4.4290    56   9.286 0.2606      42
 [2,] 0.001 4.4290    56   9.297 0.2598      33
 [3,] 0.008 3.5587    36   9.274 0.2601      23
 [4,] 0.027 2.6734    26   9.297 0.2575      17
 [5,] 0.064 1.7958    21   9.301 0.2576      12
 [6,] 0.125 1.2155    18   9.323 0.2579      10
 [7,] 0.216 0.7720    17   9.307 0.2621       9
 [8,] 0.343 0.5335    16   9.328 0.2633       8
 [9,] 0.512 0.3923    15   9.370 0.2635       6
[10,] 0.729 0.2755    15   9.364 0.2649       6
[11,] 1.000 0.2008    15   9.364 0.2658       6
plot(arcvob)

plot(arcvob, what = "lambda.min")

plot(arcvob, what = "lambda.1se")

2 Bootstrapping

2.1 rcv.glmnet

plot(bootrcv, what = "calibration")

ps <- lapply(
    zlog_data[paste0("SurvProbMeld", c("Unos", "NaUnos", "Plus7"))],
    function(p) {
        ctpnts <- cutpoints(p, n = ameldcfg$m)
        f <- cut(p, ctpnts, include.lowest = TRUE)
        list(
            predicted = groupmean(p, f = f),
            observed = observed_survival(
                amelddata$y, f = f, times = ameldcfg$times
            )
        )
    }
)
names(ps) <- c("MELD", "MELD-Na", "MELD-Plus7")
col <- viridisLite::viridis(6)[4:6]

for (i in seq_along(ps)) {
    lines(
        ps[[i]]$predicted, ps[[i]]$observed, col = col[i], type = "b", pch = 19
    )
}
legend("topleft", col = col, legend = names(ps), pch = 19, bty = "n")

plot(bootrcv, what = "selected", cex = 0.5)

plot(bootrcv$fit$glmnet.fit, xvar = "norm")

plot(bootrcv$fit$glmnet.fit, xvar = "lambda")

plot(bootrcv$fit$glmnet.fit, xvar = "dev")

2.2 arcv.glmnet

a <- c(table(sapply(bootarcv$models, function(m)m$fit$alpha)))
plot(bootarcv, what = "calibration")

plot(bootarcv, what = "selected")

plot_dots(a, main = "Selected Alpha Values")

2.3 arcv9.glmnet

#a <- c(table(sapply(bootarcv9$models, function(m)m$fit$alpha)))
#plot(bootarcv9 , what = "calibration")
#plot(bootarcv9, what = "selected")
#plot_dots(a, main = "Selected Alpha Values")

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-unknown-linux-gnu (64-bit)

Matrix products: default
BLAS/LAPACK: /gnu/store/ras6dprsw3wm3swk23jjp8ww5dwxj333-openblas-0.3.18/lib/libopenblasp-r0.3.18.so

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] viridisLite_0.4.0 ameld_0.0.20      survival_3.2-13   glmnet_4.1-3     
[5] Matrix_1.4-0      targets_0.10.0   

loaded via a namespace (and not attached):
 [1] shape_1.4.6       tidyselect_1.1.1  xfun_0.29         purrr_0.3.4      
 [5] splines_4.1.2     lattice_0.20-45   vctrs_0.3.8       htmltools_0.5.2  
 [9] yaml_2.2.2        utf8_1.2.2        rlang_1.0.0       jquerylib_0.1.4  
[13] later_1.3.0       pillar_1.6.5      glue_1.6.1        withr_2.4.3      
[17] foreach_1.5.1     lifecycle_1.0.1   stringr_1.4.0     workflowr_1.7.0  
[21] codetools_0.2-18  evaluate_0.14     knitr_1.37        callr_3.7.0      
[25] fastmap_1.1.0     httpuv_1.6.5      ps_1.6.0          fansi_1.0.2      
[29] highr_0.9         Rcpp_1.0.8        promises_1.2.0.1  backports_1.4.1  
[33] fs_1.5.2          digest_0.6.29     stringi_1.7.6     bookdown_0.24    
[37] processx_3.5.2    rprojroot_2.0.2   grid_4.1.2        cli_3.1.1        
[41] tools_4.1.2       magrittr_2.0.2    base64url_1.4     tibble_3.1.6     
[45] crayon_1.4.2      whisker_0.4       pkgconfig_2.0.3   ellipsis_0.3.2   
[49] data.table_1.14.2 rmarkdown_2.11    iterators_1.0.13  R6_2.5.1         
[53] igraph_1.2.11     git2r_0.29.0      compiler_4.1.2