Matherion / userfriendlyscience

The R userfriendlyscience package
https://userfriendlyscience.com
14 stars 7 forks source link

Error missing value where TRUE/FALSE needed #14

Open l-psych opened 4 years ago

l-psych commented 4 years ago

Hi! Thanks for this great package. I have been using it for a while now and have never run into problems. However, I am getting an error message when I want to calculate the omega and related interval for the internal consistency of a scale. I get the following error message:

scaleStructure(dat=CALISCrel_6mfu) Error in if (se != "none" && any(errorcheck <= 0)) converged <- FALSE : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan WARNING: the optimizer warns that a solution has NOT been found! 2: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan WARNING: the optimizer warns that a solution has NOT been found! 3: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan WARNING: the optimizer warns that a solution has NOT been found! 4: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, : lavaan WARNING: the optimizer warns that a solution has NOT been found!

The data looks like this:

head(CALISCrel_6mfu) dccalis1 dccalis2a dccalis2b dccalis2c dccalis2d dccalis2e dccalis2f dccalis2g dccalis2h dccalis3 1 1 2 2 2 2 0 0 1 0 1 2 1 0 0 0 0 0 0 0 0 0 3 4 2 3 0 1 2 0 0 3 3 4 2 1 2 0 0 0 0 1 0 1 5 2 1 1 0 2 1 1 2 2 4 6 0 0 0 0 0 0 0 0 0 0

And this is my session info:

sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.15

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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] userfriendlyscience_0.7.2 foreign_0.8-74

loaded via a namespace (and not attached): [1] nlme_3.1-139 MBESS_4.6.0 RColorBrewer_1.1-2 SCRT_1.3.0 data.tree_0.7.8
[6] tools_3.6.0 R6_2.4.1 lazyeval_0.2.2 colorspace_1.4-1 tidyselect_0.2.5
[11] gridExtra_2.3 GGally_1.4.0 mnormt_1.5-5 curl_4.3 compiler_3.6.0
[16] BiasedUrn_1.07 influenceR_0.1.0 diptest_0.75-7 scales_1.1.0 psych_1.9.12
[21] readr_1.3.1 ggridges_0.5.2 stringr_1.4.0 digest_0.6.23 pbivnorm_0.6.0
[26] minqa_1.2.4 rio_0.5.16 pkgconfig_2.0.3 htmltools_0.4.0 lme4_1.1-21
[31] pwr_1.2-2 htmlwidgets_1.5.1 rlang_0.4.3 readxl_1.3.1 rstudioapi_0.10
[36] SuppDists_1.1-9.4 visNetwork_2.0.8 jsonlite_1.6 dplyr_0.8.3 zip_2.0.2
[41] rgexf_0.15.3 car_3.0-6 magrittr_1.5 Matrix_1.2-17 Rcpp_1.0.3
[46] munsell_0.5.0 abind_1.4-5 viridis_0.5.1 lifecycle_0.1.0 stringi_1.4.5
[51] carData_3.0-2 MASS_7.3-51.4 plyr_1.8.5 lavaan_0.6-5 grid_3.6.0
[56] parallel_3.6.0 ggrepel_0.8.1 forcats_0.4.0 crayon_1.3.4 lattice_0.20-38
[61] haven_2.1.0 splines_3.6.0 pander_0.6.3 hms_0.4.2 knitr_1.23
[66] pillar_1.4.3 igraph_1.2.4.2 boot_1.3-24 stats4_3.6.0 XML_3.98-1.20
[71] GPArotation_2014.11-1 glue_1.3.1 downloader_0.4 data.table_1.12.2 vctrs_0.2.2
[76] nloptr_1.2.1 cellranger_1.1.0 gtable_0.3.0 purrr_0.3.3 tidyr_1.0.0
[81] reshape_0.8.8 assertthat_0.2.1 ggplot2_3.2.1 xfun_0.12 openxlsx_4.1.0.1
[86] xtable_1.8-4 viridisLite_0.3.0 minpack.lm_1.2-1 tibble_2.1.3 Rook_1.1-1
[91] DiagrammeR_1.0.1 brew_1.0-6

Any idea why this happens? Thanks a lot in advance.

l-psych commented 4 years ago

@Matherion

Matherion commented 4 years ago

That is very odd. It appears to be an error from a lavaan function.

The error suggests that either "se" is missing (NA), or "errorcheck" is.

Is the data open, and if so, could you link to it perhaps? Then I can see whether I can reproduce the error.

sebastianbock17 commented 1 year ago

Hello, I have the very same problem, and it happens with two almost identical data sets, as if randomly…. it happens with every scale analysis related function, scaleStructure, scaleReliability, scaleDiagnosis(). I also changed the colnames to not including any whitespace, dots or other weird characters. There are still some important variables that I simply cannot apply the usf related functions on, I would be very glad if this could be fixed, or at least, a workaround being shown, (for „beginneRs“).


Fehler in if (se != "none" && any(errorcheck <= 0)) converged <- FALSE :
  Fehlender Wert, wo TRUE/FALSE nötig ist
Zusätzlich: Warnmeldungen:
1: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats,  :
  lavaan WARNING:
    The variance-covariance matrix of the estimated parameters (vcov)
    does not appear to be positive definite! The smallest eigenvalue
    (= -5.947578e-18) is smaller than zero. This may be a symptom that
    the model is not identified.
2: In lavaan::lavaan(model = model, sample.cov = S, sample.nobs = N,  :
  lavaan WARNING:
    the optimizer warns that a solution has NOT been found!
3: In lavaan::lavaan(model = model, sample.cov = S, sample.nobs = N,  :
  lavaan WARNING:
    the optimizer warns that a solution has NOT been found!
4: In lavaan::lavaan(model = model, sample.cov = S, sample.nobs = N,  :
  lavaan WARNING:
    the optimizer warns that a solution has NOT been found!
5: In lavaan::lavaan(model = model, sample.cov = S, sample.nobs = N,  :
  lavaan WARNING:
    the optimizer warns that a solution has NOT been found!