userModel.R - error with code for standardized model producing warnings

82 views
Skip to first unread message

Stephen Dorn

unread,
Sep 8, 2023, 3:51:23 PM9/8/23
to Genomic SEM Users
My code using the userModel function was working previously but after downloading a new version of GenomicSEM today I get the following error which halts my code:

Error in if (emptystand$warning$message[1] != 0) { :
  argument is of length zero

It appears the line of code this corresponds to in userModel.R was added 4 hours ago, so I think this may be a bug that was just introduced. It seems that when indexing into this array there is no object so NULL is returned which is causing this error in your code. 

The issue is line 710 of the userModel.R file:
if(emptystand$warning$message[1] != 0){
      warning(paste0("The standardized model produced the following warning: ", emptystand$warning$message[1],sep=""))
   } 

Please let me know if this is indeed a bug in your code or if I should send you further information on my code to help diagnose the issue.

Thanks!

JE Savage

unread,
Sep 12, 2023, 6:55:47 AM9/12/23
to Genomic SEM Users
Hi,

I encountered the same issue with models that were working previously and now produce the same error and no output. When running a model with DWLS estimation that has no convergence problems, the warning message for emptystand is NULL rather than 0 so it seems to fail the check on line 710.

I was able to do a quick fix by adjusting the code on lines 481-483 of usermodel.R from

      if (estimation == "DWLS") {
        emptystand <- .tryCatch.W.E(Fit_stand <- sem(Model1,
                                                     sample.cov = S_Stand, estimator = "DWLS", WLS.V = W_stand,
                                                     std.lv = std.lv, sample.nobs = 2, optim.dx.tol = +Inf))
      }

to

      if (estimation == "DWLS") {
        emptystand <- .tryCatch.W.E(Fit_stand <- sem(Model1,
                                                     sample.cov = S_Stand, estimator = "DWLS", WLS.V = W_stand,
                                                     std.lv = std.lv, sample.nobs = 2, optim.dx.tol = +Inf))
        if (is.null(emptystand$warning$message[1])) {
          emptystand$warning$message[1] <- 0
        }
      }

But I think this is a bug that needs to be fixed because there were otherwise no issues with the model solution.

Michel Nivard

unread,
Sep 12, 2023, 7:30:27 AM9/12/23
to Genomic SEM Users
Hm yeah that looks like a bug, lets see if we can patch it (with your solution now, perhaps more durable asap).

Thanks,

mIchel 

Michel Nivard

unread,
Sep 12, 2023, 7:32:32 AM9/12/23
to JE Savage, Genomic SEM Users
Fixed for now, ill coordinate with Andrew on a real fix.

--
You received this message because you are subscribed to the Google Groups "Genomic SEM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to genomic-sem-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/genomic-sem-users/27314c41-52ac-4e72-a13b-24232649690dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages