A minimal example

Matthew Stephens

2025-06-03

In this short vignette, we fit a sparse linear regression model with up to \(L > 0\) non-zero effects. Generally, there is no harm in over-stating \(L\) (that is, the method is pretty robust to overfitting), except that computation will grow as \(L\) grows.

Here is a minimal example:

library(susieR)
set.seed(1)
n    <- 1000
p    <- 1000
beta <- rep(0,p)
beta[c(1,2,300,400)] <- 1
X   <- matrix(rnorm(n*p),nrow=n,ncol=p)
y   <- X %*% beta + rnorm(n)
res <- susie(X,y,L=10)
plot(coef(res)[-1],pch = 20)
&nbsp;

 

Plot the ground-truth outcomes vs. the predicted outcomes:

plot(y,predict(res),pch = 20)
&nbsp;

 

Session information

Here are some details about the computing environment, including the versions of R, and the R packages, used to generate these results.

sessionInfo()
# R version 4.3.3 (2024-02-29)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS 15.4.1
# 
# Matrix products: default
# BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
# LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
# 
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# 
# time zone: America/Chicago
# tzcode source: internal
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
# [1] susieR_0.14.1
# 
# loaded via a namespace (and not attached):
#  [1] Matrix_1.6-5        gtable_0.3.4        jsonlite_1.8.8     
#  [4] highr_0.10          dplyr_1.1.4         compiler_4.3.3     
#  [7] crayon_1.5.2        tidyselect_1.2.1    Rcpp_1.0.12        
# [10] parallel_4.3.3      jquerylib_0.1.4     scales_1.3.0       
# [13] yaml_2.3.8          fastmap_1.1.1       lattice_0.22-5     
# [16] ggplot2_3.5.0       R6_2.5.1            plyr_1.8.9         
# [19] generics_0.1.3      mixsqp_0.3-54       knitr_1.45         
# [22] tibble_3.2.1        RcppZiggurat_0.1.6  munsell_0.5.0      
# [25] bslib_0.6.1         pillar_1.9.0        rlang_1.1.5        
# [28] utf8_1.2.4          cachem_1.0.8        reshape_0.8.9      
# [31] xfun_0.42           sass_0.4.9          RcppParallel_5.1.10
# [34] cli_3.6.4           magrittr_2.0.3      digest_0.6.34      
# [37] grid_4.3.3          irlba_2.3.5.1       lifecycle_1.0.4    
# [40] vctrs_0.6.5         Rfast_2.1.0         evaluate_1.0.3     
# [43] glue_1.8.0          fansi_1.0.6         colorspace_2.1-0   
# [46] rmarkdown_2.26      matrixStats_1.2.0   tools_4.3.3        
# [49] pkgconfig_2.0.3     htmltools_0.5.8.1