Convergence problem and high variance estimate

104 views
Skip to first unread message

Sarfaraz Serang

unread,
Dec 21, 2016, 4:05:46 PM12/21/16
to regsem
Hi,

In trying regsem, I came across a problem which regsem had a great deal of difficulty estimating. There were convergence issues even at lambda = 0, which I thought should just produce the maximum likelihood estimates. Additionally, the estimate of the outcome, Enroll, was over 8, which is far too high for a standardized variable. Here's the relevant code.

library(ISLR)
library(regsem)
data(College)
College1 = College[which(College$Private=="Yes"),]
Data = data.frame(scale(College1[c(3,4,9:12,15,17)]))

model1 <-
' Enroll ~ c*Accept
Outstate ~ a1*Accept
Room.Board ~ a2*Accept
Books ~ a3*Accept
Personal ~ a4*Accept
S.F.Ratio ~ a5*Accept
Expend ~ a6*Accept
Enroll ~ b1*Outstate + b2*Room.Board + b3*Books + b4*Personal + b5*S.F.Ratio + b6*Expend
a1b1 := a1*b1
a2b2 := a2*b2
a3b3 := a3*b3
a4b4 := a4*b4
a5b5 := a5*b5
a6b6 := a6*b6
total := c + (a1*b1) + (a2*b2) + (a3*b3) + (a4*b4) + (a5*b5) + (a6*b6)
'

fit.delta = sem(model1,data=Data,fixed.x=T)

fit.reg1 = regsem(fit.delta,lambda=0,type="lasso",gradFun="ram",pars_pen=c(2:13),optMethod="coord_desc")
summary(fit.reg1)

Any help would be much appreciated. Thanks!

Sarfaraz Serang

Ross Jacobucci

unread,
Dec 22, 2016, 8:59:34 AM12/22/16
to regsem, mindover...@gmail.com
Thanks for pointing out a problem with estimation. This has recently been fixed in 0.5.0, which can either be installed from my github: devtools::install_github("Rjacobucci/regsem"), or from CRAN (submitted and should be up in next day). 

In running your example with the new version, the variance estimate for Enroll stays in a reasonable zone (0.16-0.19) across values of lambda.

fit.reg.tune = cv_regsem(fit.delta,type="lasso",pars_pen = c(2:13),jump=0.01,multi.iter=4,mult.start=TRUE,lambda.start=0,
                         n.lambda=50,tol=1e-6,fit.ret=c("BIC"),fit.ret2="train",optMethod="coord_desc",gradFun="ram",
                         warm.start=T,full=TRUE) 

Note that most of the arguments are not necessary, as they are the defaults. The important aspect is that now "full=TRUE" is the default, fixing previous problems with convergence and inflated variance parameters.

Best,
Ross

Jamie Hanson

unread,
Apr 27, 2021, 11:50:12 AM4/27/21
to regsem
Hello, 

Apologies if I missed this or was making an error in this space, but I kept running into an error when trying to get this code (from either the original article, or the uploaded version here) to run. When I run--

fit.reg.tune=cv_regsem(fit.delta,type="lasso",pars_pen=c(2:13),jump=0.01,multi.iter=4,mult.start=TRUE,lambda.start=0,n.lambda=50,tol=1e-6,fit.ret=c("BIC"),fit.ret2="train",optMethod="coord_desc",gradFun="ram",warm.start=T,full=TRUE)

I get out the following error--
Error: $ operator is invalid for atomic vectors

Here's my R sessionInfo() for reference--

----
> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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.6.2 Rsolnp_1.16  Rcpp_1.0.6   lavaan_0.6-8 ISLR_1.2    

loaded via a namespace (and not attached):
[1] compiler_4.0.4  parallel_4.0.4  tools_4.0.4     tmvnsim_1.0-2   mnormt_2.0.2    pbivnorm_0.6.0 
[7] truncnorm_1.0-8 stats4_4.0.4   

-----
Have others run into this issue? Is there an attached library that's causing the problem? 
Any thoughts are much appreciated! 
(Of note, all the other commands/inputs are the same from Serang et al. 2017 paper) .

All the best,
Jamie.

Jamie Hanson

unread,
Apr 27, 2021, 9:04:50 PM4/27/21
to regsem
Hmmm, I updated things, and still no luck. Thoughts?

I run--
fit.reg.tune = cv_regsem(fit.delta,type="lasso",pars_pen = c(2:13),jump=0.01,multi.iter=4,mult.start=TRUE,lambda.start=0,n.lambda=50,tol=1e-6,fit.ret=c("BIC"),fit.ret2="train",optMethod="coord_desc",gradFun="ram",warm.start=T,full=TRUE) 
  |==                                                                                                    |   2%

And get the output--
Error in multi_optim(model = model, max.try = multi.iter, lambda = SHRINK,  : 
  object 'fit1' not found
I'm confused/not sure where fit1 is coming from (?), it's not in other code I'm using.

Here's my sessionInfo()--
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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.7.0   Rsolnp_1.16    Rcpp_1.0.6     ISLR_1.2       lavaan_0.6-8   semtree_0.9.15 OpenMx_2.19.5 

loaded via a namespace (and not attached):
 [1] compiler_4.0.4    sets_1.0-18       bitops_1.0-7      prettyunits_1.1.1 remotes_2.2.0     tools_4.0.4      
 [7] rpart_4.1-15      testthat_3.0.2    digest_0.6.27     pkgbuild_1.2.0    pkgload_1.2.1     lattice_0.20-41  
[13] memoise_1.1.0     lifecycle_1.0.0   rlang_0.4.10      Matrix_1.3-2      cli_2.5.0         rstudioapi_0.13  
[19] curl_4.3          parallel_4.0.4    pbivnorm_0.6.0    withr_2.4.2       desc_1.3.0        fs_1.5.0         
[25] devtools_2.3.2    grid_4.0.4        stats4_4.0.4      rprojroot_2.0.2   glue_1.4.2        R6_2.5.0         
[31] processx_3.5.1    sessioninfo_1.1.1 callr_3.7.0       purrr_0.3.4       magrittr_2.0.1    ps_1.6.0         
[37] ellipsis_0.3.1    usethis_2.0.0     MASS_7.3-53       assertthat_0.2.1  mnormt_2.0.2      strucchange_1.5-2
[43] sandwich_3.0-0    truncnorm_1.0-8   tmvnsim_1.0-2     crayon_1.4.1      zoo_1.8-9  

It looks like fit1 is in the code for multi_optim and regsem... but wasn't sure what to edit? Thoughts?

Many thanks for the help and assistance!
Jamie.

rcja...@gmail.com

unread,
Apr 28, 2021, 11:54:45 AM4/28/21
to regsem
Thanks for pointing this out. There are a couple things going on here:

- a bug with multi_optim(), which is used in the backend in when mult.start=T. This is fixed now in version 1.7.1 on github. 

- The main thing is an issue with the code from past google group discussions, namely the use of coordinate descent (optMethod="coord_desc"). We recommend the use of a different solver. Changing this and removing some other aspects of the code gets it to run quickly with no errors:

fit.reg.tune = cv_regsem(fit.delta,type="lasso",pars_pen = c(2:13),jump=0.01)

Thanks for pointing this out!

Ross

Reply all
Reply to author
Forward
0 new messages