stephenslab / mashr

An R package for multivariate adaptive shrinkage.
https://stephenslab.github.io/mashr
Other
88 stars 19 forks source link

warning: solve(): system is singular (rcond: 1.34847e-17); attempting approx solution #110

Closed GabrielHoffman closed 1 year ago

GabrielHoffman commented 1 year ago

When I run this code from the man page for mash_estimate_corr_em():

library(mash)
simdata = simple_sims(100,5,1)
m.1by1 = mash_1by1(mash_set_data(simdata$Bhat,simdata$Shat))
strong.subset = get_significant_results(m.1by1,0.05)
random.subset = sample(1:nrow(simdata$Bhat),20)
data.strong = mash_set_data(simdata$Bhat[strong.subset,], simdata$Shat[strong.subset,])
data.tmp = mash_set_data(simdata$Bhat[random.subset,], simdata$Shat[random.subset,])
U_pca = cov_pca(data.strong, 3)
U_ed = cov_ed(data.strong, U_pca)
Vhat = mash_estimate_corr_em(data.tmp, U_ed)

I get many lines saying

warning: solve(): system is singular (rcond: 1.34847e-17); attempting approx solution

with very small record values. This is a new warning that I didn't notice until recently.

sessionInfo()

R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin19.6.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] mashr_0.2.57 ashr_2.2-54 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       lattice_0.20-45  invgamma_1.1     mvtnorm_1.1-3   
 [5] assertthat_0.2.1 truncnorm_1.0-8  grid_4.2.0       plyr_1.8.7      
 [9] irlba_2.3.5.1    Matrix_1.5-1     rmeta_3.0        tools_4.2.0     
[13] softImpute_1.4-1 mixsqp_0.3-43    abind_1.4-5      compiler_4.2.0  
[17] SQUAREM_2021.1 
pcarbo commented 1 year ago

@GabrielHoffman Can you install the latest version of mixsqp from GitHub, and make sure you have the latest version of RcppArmadillo installed?

GabrielHoffman commented 1 year ago

Hi @pcarbo, Thanks for the fix. Can you push the new mixsqp to CRAN?

Best, Gabriel

pcarbo commented 1 year ago

Sure, I'll do that soon.

pcarbo commented 1 year ago

@GabrielHoffman mixsqp has been updated on CRAN.