This code contains an example of running the glmm
function.
# Libraries
library(glmmPen)
## Warning: package 'glmmPen' was built under R version 4.1.3
## Loading required package: lme4
## Warning: package 'lme4' was built under R version 4.1.2
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.1.2
## Loading required package: bigmemory
## Warning: package 'bigmemory' was built under R version 4.1.2
## Loading required package: Rcpp
## Warning: package 'Rcpp' was built under R version 4.1.2
library(stringr)
## Warning: package 'stringr' was built under R version 4.1.2
# Example of running glmm() function on basal dataset - fit a single model with
# no variable selection
# basal data from glmmPen package
data("basal")
# Extract response
y = basal$y
# Select a sampling of 10 TSP covariates from the total 50 covariates
set.seed(1618)
idx = sample(1:50, size = 10, replace = FALSE)
# Selected column index values:
(idx = idx[order(idx)])
## [1] 3 6 16 18 27 28 29 30 34 41
X = basal$X[,idx]
# Selected predictors:
colnames(X)
## [1] "GPR160_CD109" "SPDEF_MFI2" "CHST6_CAPN9" "SLC40A1_CDH3"
## [5] "PLEK2_HSD17B2" "GPX2_ERO1L" "CYP3A5_B3GNT5" "LY6D_ATP2C2"
## [9] "MYO1A_FGFBP1" "CTSE_COL17A1"
group = basal$group
# Levels of the grouping variable:
levels(group)
## [1] "UNC_PDAC" "TCGA_PDAC" "TCGA_Bladder" "UNC_Breast"
start_glmm = proc.time()
set.seed(1618)
fit_glmm = glmm(formula = y ~ X + (X | group),
family = "binomial", covar = "independent",
optim_options = optimControl())
## recommended starting variance: 0.500000
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1 250 100 10 10
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 2 275 100 10 10
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 3.000000 302.000000 0.024135 10.000000 10.000000
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 4.000000 332.000000 0.015629 10.000000 10.000000
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 5.000000 365.000000 0.011229 10.000000 10.000000
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 6.000e+00 4.020e+02 8.108e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 7.000e+00 4.420e+02 6.299e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 8.000e+00 4.860e+02 5.482e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 9.000e+00 5.350e+02 4.416e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.000e+01 5.880e+02 3.419e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.100e+01 6.470e+02 3.096e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.20e+01 7.12e+02 2.34e-03 1.00e+01 1.00e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.300e+01 7.830e+02 1.772e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.400e+01 8.610e+02 1.977e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.500e+01 9.470e+02 2.098e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.600e+01 1.042e+03 1.674e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.700e+01 1.250e+03 1.234e-03 1.000e+01 1.000e+01
## Iter nMC EM conv Non0 Fixef Non0 Ranef
## 1.800e+01 1.500e+03 1.001e-03 1.000e+01 1.000e+01
## Start of sampling from posterior
## Finished sampling from posterior
## Pajor Log-Likelihood Calculation
end_glmm = proc.time()
end_glmm - start_glmm
## user system elapsed
## 151.48 24.35 180.55
sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] stringr_1.4.0 glmmPen_1.5.3.4 Rcpp_1.0.7 bigmemory_4.5.36
## [5] lme4_1.1-27.1 Matrix_1.3-4
##
## loaded via a namespace (and not attached):
## [1] bdsmatrix_1.3-6 mvtnorm_1.1-3 lattice_0.20-44
## [4] prettyunits_1.1.1 ps_1.6.0 V8_3.6.0
## [7] digest_0.6.29 utf8_1.2.2 R6_2.5.1
## [10] plyr_1.8.6 stats4_4.1.1 bigmemory.sri_0.1.3
## [13] evaluate_0.14 ggplot2_3.4.2 pillar_1.6.4
## [16] rlang_1.1.0 curl_4.3.2 rstudioapi_0.13
## [19] minqa_1.2.4 callr_3.7.0 nloptr_1.2.2.3
## [22] jquerylib_0.1.4 rmarkdown_2.11 splines_4.1.1
## [25] loo_2.4.1 munsell_0.5.0 compiler_4.1.1
## [28] xfun_0.28 rstan_2.21.2 pkgconfig_2.0.3
## [31] pkgbuild_1.3.0 rstantools_2.1.1 htmltools_0.5.4
## [34] tidyselect_1.1.1 gridExtra_2.3 tibble_3.1.6
## [37] codetools_0.2-18 matrixStats_0.61.0 fansi_0.5.0
## [40] withr_2.5.0 crayon_1.4.2 dplyr_1.0.9
## [43] MASS_7.3-54 grid_4.1.1 nlme_3.1-152
## [46] jsonlite_1.7.2 gtable_0.3.0 lifecycle_1.0.3
## [49] magrittr_2.0.1 StanHeaders_2.21.0-7 scales_1.2.1
## [52] RcppParallel_5.1.4 cli_3.3.0 stringi_1.7.6
## [55] cachem_1.0.6 reshape2_1.4.4 coxme_2.2-18.1
## [58] bslib_0.4.2 ellipsis_0.3.2 generics_0.1.2
## [61] vctrs_0.6.2 boot_1.3-28 tools_4.1.1
## [64] ncvreg_3.13.0 glue_1.6.2 purrr_0.3.4
## [67] parallel_4.1.1 processx_3.5.2 fastmap_1.1.0
## [70] survival_3.5-5 yaml_2.2.1 inline_0.3.19
## [73] colorspace_2.0-2 knitr_1.36 sass_0.4.4