Attachment | Size |
---|---|
test_data.csv | 16.62 KB |
I am trying to run simulations on an Amazon linux instance and get the following error when I use mxAutoStart()
to generate starting values :
library(devtools) #install_github("sciarraseb/nonlinSims", dependencies = T, force=T) library(easypackages) library(nonlinSims) library(parallel) library(tidyverse) library(OpenMx) library(data.table) test_data <- read_csv(file = 'test_data.csv') model <- create_logistic_growth_model(data_wide = test_data, model_name = 'test') model <- mxAutoStart(model) Error in solve.default(I - A) : system is computationally singular: reciprocal condition number = 0
Here is the output provided when calling traceback()
:
12: solve.default(I - A) 11: solve(I - A) 10: genericGetExpected(model[[subname]]$expectation, model, component, defvar.row, subname) 9: genericGetExpected(model[[subname]]$expectation, model, component, defvar.row, subname) 8: mxGetExpected(model, c("covariance", "means", "thresholds"), subname = subname) 7: autoStartDataHelper(model, type = type) 6: mxModel(model, autoStartDataHelper(model, type = type)) 5: omxBuildAutoStartModel(model, type) 4: is(model, "MxModel") 3: warnModelCreatedByOldVersion(model) 2: mxRun(omxBuildAutoStartModel(model, type), silent = TRUE) 1: mxAutoStart(model)
I have provided other pertinent information below (i.e., R version, optimizer used in OpenMx, etc.):
OpenMx version: 2.19.8 [GIT v2.19.8] R version: R version 4.0.2 (2020-06-22) Platform: x86_64-koji-linux-gnu Default optimizer: SLSQP NPSOL-enabled?: No OpenMP-enabled?: Yes
Interestingly, the error appearing on the Amazon instance does not appear when I run the code offline in RStudio (on either Mac or Windows). Here is the output provided by mxVersion()
in the offline version of R that I am using:
OpenMx version: 2.19.8 [GIT v2.19.8] R version: R version 4.0.5 (2021-03-31) Platform: x86_64-apple-darwin17.0 MacOS: 12.0.1 Default optimizer: SLSQP NPSOL-enabled?: No OpenMP-enabled?: No
I have also attached the data set (test_data.csv
). I have written create_logistic_growth_model()
and posted it in a GitHub repository (hopefully you can download the package to use the function). I can provide more information about this function if necessary.
Under Amazon Linux, what do you get from running
sessionInfo()
at the R prompt? I'm primarily curious about the 'Matrix products', 'BLAS', and 'LAPACK'.Here is the output from
SessionInfo()
:At any rate, I do not reproduce the error on my system. My
mxVersion()
output:I am using the default BLAS and LAPACK implementations.
As a workaround, try adjusting the initial values your function uses for some of your MxPaths and MxMatrix elements.
I have experimented starting values but had no success (unfortunately). I also posted the output from
SessionInfo()
above for you to look at the matrix products.Yes, I saw. My suspicion was that your instance of Amazon linux was building R with non-default implementations of BLAS/LAPACK, which might have a different tolerance for when a matrix is considered "computationally singular". Evidently, that's not what's going on.
Can you make any headway under Amazon Linux if you don't use
mxAutoStart()
?You might need to run your script under R's debugger on an Amazon Linux instance.
I did my best to understand where the error may be occurring (using the debugging link you posted). It appears that the error is a result of
NaN
s appearing in the A matrix (which contains the factor loadings from the latent variables to the manifest variables; see output below). The outputs from environments 9–10 are shown below (I can provide more output if necessary).At this point, it may be important to mention the model I am running. In short, I am running a three-parameter logistic curve model (with the growth parameters treated as latent variables). I have provided a relevant code chunk (from
create_logistic_growth_model()
and attached a path diagram showing the specific model that I am using. Seven parameters are estimated: fixed- and random-effects parameters for $diff$, $\beta$, and $\gamma$ and one residual component for each time point ($\epsilon$). Note that a structured latent curve model is implemented.