xmed issues (related to penalty.factor?).

36 views
Skip to first unread message

Jamie Hanson

unread,
Jan 26, 2022, 8:16:19 PM1/26/22
to regsem
Hello all,

I was trying to run xmed using the minimal example in CRAN reference manual, but keep running into issues. I basically run the exact code, then get this error:

> out <- xmed(Data,iv,mediators,dv)
Error in glmnet(x, y, weights = weights, offset = offset, lambda = lambda,  :
  the length of penalty.factor does not match the number of variables

Here's my R sessionInfo--
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 12.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.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 utils     datasets  methods   base    

other attached packages:
[1] regsem_1.8.3  Rsolnp_1.16   Rcpp_1.0.8    lavaan_0.6-10 ISLR_1.4    

loaded via a namespace (and not attached):
 [1] lubridate_1.8.0      lattice_0.20-44      listenv_0.8.0        class_7.3-19        
 [5] glmnet_4.1-3         assertthat_0.2.1     digest_0.6.29        ipred_0.9-12        
 [9] foreach_1.5.1        utf8_1.2.2           parallelly_1.30.0    truncnorm_1.0-8    
[13] R6_2.5.1             plyr_1.8.6           stats4_4.1.0         ggplot2_3.3.5      
[17] pillar_1.6.4         rlang_0.4.12         caret_6.0-90         data.table_1.14.2  
[21] rpart_4.1-15         Matrix_1.3-3         pbivnorm_0.6.0       splines_4.1.0      
[25] gower_0.2.2          stringr_1.4.0        munsell_0.5.0        compiler_4.1.0      
[29] pkgconfig_2.0.3      mnormt_2.0.2         shape_1.4.6          tmvnsim_1.0-2      
[33] globals_0.14.0       nnet_7.3-16          tidyselect_1.1.1     tibble_3.1.6        
[37] prodlim_2019.11.13   codetools_0.2-18     fansi_1.0.2          future_1.23.0      
[41] crayon_1.4.2         dplyr_1.0.7          withr_2.4.3          MASS_7.3-54        
[45] recipes_0.1.17       ModelMetrics_1.2.2.2 grid_4.1.0           nlme_3.1-152        
[49] gtable_0.3.0         lifecycle_1.0.1      DBI_1.1.2            magrittr_2.0.1      
[53] pROC_1.18.0          scales_1.1.1         future.apply_1.8.1   stringi_1.7.6      
[57] reshape2_1.4.4       timeDate_3043.102    ellipsis_0.3.2       generics_0.1.1      
[61] vctrs_0.3.8          lava_1.6.10          iterators_1.0.13     tools_4.1.0        
[65] glue_1.6.0           purrr_0.3.4          parallel_4.1.0       survival_3.2-11    
[69] colorspace_2.0-2    

Have others run into this issue? Many thanks for any suggestions of workarounds, etc. 

All the best,
Jamie.


rcja...@gmail.com

unread,
Jan 28, 2022, 12:43:09 PM1/28/22
to regsem
Hi Jamie,

Thanks for pointing this out. I've fixed the issue, which has been uploaded to github (1.8.4). I'm going to wait with CRAN until I know why we had it that way in the first place.

Ross

Jamie Hanson

unread,
Jan 30, 2022, 1:49:33 PM1/30/22
to regsem
Oh many thanks for this help! I got the example to work! But follow-up question-- what leads to running into this error? I was trying to use xmed with real data and got the same error.

Jamie Hanson

unread,
Jan 30, 2022, 1:55:15 PM1/30/22
to regsem
Apologies for the multiple notes, but is that error due to xmed trying to pull all the variables from the data frame I'm pointing to? I isolated *just* the IV, DV, and mediators and that error didn't seem to pop up. 
Reply all
Reply to author
Forward
0 new messages