Skip to content

cv_glm_fitlist and model_stability_glm documentation #4

@mnkwarshie

Description

@mnkwarshie

Hi! I hope you're doing well. I have been trying to use the cv_glm_fitlist and and model_stability_glm() functions and have been unable to find clear documentation on how they should work, nor could I find any working examples. Is there any possibility of getting some more documentation for either of these functions? The code I used is below:

  library(doBy)

  set.seed(1411)
   dat <<- doBy::personality
   train <<- sample(1:nrow(dat), 0.6*nrow(dat))
  dat.training <<- dat[train, ]
   dat.testing <<- dat[-train, ]


   mod1 <- stats::glm(agreebl ~ ., data = dat.training)

   set.seed(1411)
  n.searches <- 12
   mod_stab <- doBy::model_stability_glm(data. = dat.training, model = mod1,
                                         n.searches=n.searches, method="subgroups", trace=0)
   fit_list <- formula(mod_stab, fit=TRUE)
   set.seed(1411)
   (cv.error <- doBy::cv_glm_fitlist(dat.training, fit_list, K=4))
   ## fit_list has 12 fits and for each fit 1 cv is returned and hence the vector length will be 12

   set.seed(1411)
   x1 = boot::cv.glm(dat[train, ], fit_list[[1]], K=4)$delta[1]
   x2 = boot::cv.glm(dat[train, ], fit_list[[2]], K=4)$delta[1]
   x3 = boot::cv.glm(dat[train, ], fit_list[[3]], K=4)$delta[1]
   x4 = boot::cv.glm(dat[train, ], fit_list[[4]], K=4)$delta[1]
   x5 = boot::cv.glm(dat[train, ], fit_list[[5]], K=4)$delta[1]
   x6 = boot::cv.glm(dat[train, ], fit_list[[6]], K=4)$delta[1]
   x7 = boot::cv.glm(dat[train, ], fit_list[[7]], K=4)$delta[1]
   x8 = boot::cv.glm(dat[train, ], fit_list[[8]], K=4)$delta[1]
   x9 = boot::cv.glm(dat[train, ], fit_list[[9]], K=4)$delta[1]
   x10 = boot::cv.glm(dat[train, ], fit_list[[10]], K=4)$delta[1]
   x11 = boot::cv.glm(dat[train, ], fit_list[[11]], K=4)$delta[1]
   x12 = boot::cv.glm(dat[train, ], fit_list[[12]], K=4)$delta[1]

   exp_cv_error <- c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12)

Here is my session info below:

R version 4.5.0 (2025-04-11)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.2 LTS

Matrix products: default
BLAS:   /opt/R/openval/rc_20250900/4.5.0/lib/R/lib/libRblas.so 
LAPACK: /opt/R/openval/rc_20250900/4.5.0/lib/R/lib/libRlapack.so;  LAPACK version 3.12.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [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: Etc/UTC
tzcode source: system (glibc)

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

loaded via a namespace (and not attached):
 [1] microbenchmark_1.5.0 vctrs_0.6.5          cli_3.6.5           
 [4] rlang_1.1.6          cowplot_1.1.3        purrr_1.0.4         
 [7] generics_0.1.4       glue_1.8.0           colorspace_2.1-1    
[10] backports_1.5.0      modelr_0.1.11        rsconnect_1.4.0     
[13] scales_1.4.0         grid_4.5.0           tibble_3.2.1        
[16] MASS_7.3-65          lifecycle_1.0.4      compiler_4.5.0      
[19] dplyr_1.1.4          RColorBrewer_1.1-3   pkgconfig_2.0.3     
[22] tidyr_1.3.1          Deriv_4.1.6          rstudioapi_0.17.1   
[25] farver_2.1.2         lattice_0.22-7       R6_2.6.1            
[28] doBy_4.6.26          dichromat_2.0-0.1    tidyselect_1.2.1    
[31] pillar_1.10.2        magrittr_2.0.3       Matrix_1.7-3        
[34] tools_4.5.0          gtable_0.3.6         boot_1.3-31         
[37] broom_1.0.8          ggplot2_3.5.2      

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions