SachaEpskamp / psychonetrics

An R package for Network Psychometrics
43 stars 5 forks source link

Error message in stepup #13

Closed LangeJens closed 1 year ago

LangeJens commented 2 years ago

Hi psychonetrics team, thank you for this great package! I am running into a weird error message when using stepup (see minimal example below). I have used this code successfully with other data sets. Moreover, I can use the data set below and estimate the network in all kinds of different ways. Also, wenn I used only data_noMiss[4:10], the code also works. But there is nothing weird with the first three variables as confirmed by psych::describe(data_noMiss). Because the error message is not very helpful (it does not stem from stepup itself), I do not know what happens.

Best, Jens

library(CliquePercolation)
library(psychonetrics)
library(dplyr)

data(Obama)
data_noMiss <- na.omit(Obama)
GGM_net_stepup <- ggm(data_noMiss, omega = "empty") %>% runmodel %>% stepup

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 
  'data' must be of a vector type, was 'NULL'

# sessionInfo()
# R version 4.1.2 (2021-11-01)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 22000)
# 
# Matrix products: default
# 
# locale:
#   [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
# [4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252    
# system code page: 65001
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] dplyr_1.0.8             psychonetrics_0.10      CliquePercolation_0.3.0
# 
# loaded via a namespace (and not attached):
#   [1] tidyr_1.2.0         splines_4.1.2       foreach_1.5.2       tmvnsim_1.0-2       gtools_3.9.2       
# [6] Formula_1.2-4       stats4_4.1.2        latticeExtra_0.6-29 yaml_2.2.2          pbivnorm_0.6.0     
# [11] numDeriv_2016.8-1.1 pillar_1.7.0        backports_1.4.1     lattice_0.20-45     glue_1.6.1         
# [16] digest_0.6.29       RColorBrewer_1.1-2  checkmate_2.0.0     minqa_1.2.4         colorspace_2.0-2   
# [21] htmltools_0.5.2     Matrix_1.4-0        plyr_1.8.6          psych_2.1.9         pkgconfig_2.0.3    
# [26] purrr_0.3.4         corpcor_1.6.10      mvtnorm_1.1-3       scales_1.1.1        glasso_1.11        
# [31] jpeg_0.1-9          lme4_1.1-28         fdrtool_1.2.17      tibble_3.1.6        htmlTable_2.4.0    
# [36] combinat_0.0-8      mgcv_1.8-38         generics_0.1.2      ggplot2_3.3.5       ellipsis_0.3.2     
# [41] pbapply_1.5-0       nnet_7.3-16         cli_3.1.1           mnormt_2.0.2        survival_3.2-13    
# [46] magrittr_2.0.2      crayon_1.5.0        evaluate_0.14       fansi_1.0.2         MASS_7.3-54        
# [51] nlme_3.1-153        foreign_0.8-81      tools_4.1.2         data.table_1.14.2   lifecycle_1.0.1    
# [56] bnlearn_4.7         stringr_1.4.0       munsell_0.5.0       cluster_2.1.2       IsingSampler_0.2.1 
# [61] compiler_4.1.2      rlang_1.0.1         nloptr_2.0.0        grid_4.1.2          iterators_1.0.14   
# [66] rstudioapi_0.13     htmlwidgets_1.5.4   igraph_1.2.11       lavaan_0.6-10       base64enc_0.1-3    
# [71] rmarkdown_2.13      boot_1.3-28         GA_3.2.2            VCA_1.4.3           gtable_0.3.0       
# [76] codetools_0.2-18    abind_1.4-5         reshape2_1.4.4      qgraph_1.9          R6_2.5.1           
# [81] gridExtra_2.3       knitr_1.37          optimx_2021-10.12   fastmap_1.1.0       utf8_1.2.2         
# [86] Hmisc_4.6-0         stringi_1.7.6       parallel_4.1.2      Rcpp_1.0.8          vctrs_0.3.8        
# [91] rpart_4.1-15        png_0.1-7           tidyselect_1.1.1    xfun_0.30
KJKan commented 2 years ago

Hi Sacha and Jens,

For your information: I did not get any error when I ran Jens' example.

Sessioninfo: R version 4.0.4 (2021-02-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)

Best, Kees-Jan

From: Jens Lange @.> Sent: vrijdag 18 maart 2022 16:15 To: SachaEpskamp/psychonetrics @.> Cc: Subscribed @.***> Subject: [SachaEpskamp/psychonetrics] Error message in stepup (Issue #13)

Hi psychonetrics team, thank you for this great package! I am running into a weird error message when using stepup (see minimal example below). I have used this code successfully with other data sets. Moreover, I can use the data set below and estimate the network in all kinds of different ways. Also, wenn I used only data_noMiss[4:10], the code also works. But there is nothing weird with the first three variables as confirmed by psych::describe(data_noMiss). Because the error message is not very helpful (it does not stem from stepup itself), I do not know what happens.

Best, Jens

library(CliquePercolation) library(psychonetrics) library(dplyr)

sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000) Matrix products: default locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252 system code page: 65001 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] dplyr_1.0.8 psychonetrics_0.10 CliquePercolation_0.3.0 loaded via a namespace (and not attached): [1] tidyr_1.2.0 splines_4.1.2 foreach_1.5.2 tmvnsim_1.0-2 gtools_3.9.2 [6] Formula_1.2-4 stats4_4.1.2 latticeExtra_0.6-29 yaml_2.2.2 pbivnorm_0.6.0 [11] numDeriv_2016.8-1.1 pillar_1.7.0 backports_1.4.1 lattice_0.20-45 glue_1.6.1 [16] digest_0.6.29 RColorBrewer_1.1-2 checkmate_2.0.0 minqa_1.2.4 colorspace_2.0-2 [21] htmltools_0.5.2 Matrix_1.4-0 plyr_1.8.6 psych_2.1.9 pkgconfig_2.0.3 [26] purrr_0.3.4 corpcor_1.6.10 mvtnorm_1.1-3 scales_1.1.1 glasso_1.11 [31] jpeg_0.1-9 lme4_1.1-28 fdrtool_1.2.17 tibble_3.1.6 htmlTable_2.4.0 [36] combinat_0.0-8 mgcv_1.8-38 generics_0.1.2 ggplot2_3.3.5 ellipsis_0.3.2 [41] pbapply_1.5-0 nnet_7.3-16 cli_3.1.1 mnormt_2.0.2 survival_3.2-13 [46] magrittr_2.0.2 crayon_1.5.0 evaluate_0.14 fansi_1.0.2 MASS_7.3-54 [51] nlme_3.1-153 foreign_0.8-81 tools_4.1.2 data.table_1.14.2 lifecycle_1.0.1 [56] bnlearn_4.7 stringr_1.4.0 munsell_0.5.0 cluster_2.1.2 IsingSampler_0.2.1 [61] compiler_4.1.2 rlang_1.0.1 nloptr_2.0.0 grid_4.1.2 iterators_1.0.14 [66] rstudioapi_0.13 htmlwidgets_1.5.4 igraph_1.2.11 lavaan_0.6-10 base64enc_0.1-3 [71] rmarkdown_2.13 boot_1.3-28 GA_3.2.2 VCA_1.4.3 gtable_0.3.0 [76] codetools_0.2-18 abind_1.4-5 reshape2_1.4.4 qgraph_1.9 R6_2.5.1 [81] gridExtra_2.3 knitr_1.37 optimx_2021-10.12 fastmap_1.1.0 utf8_1.2.2 [86] Hmisc_4.6-0 stringi_1.7.6 parallel_4.1.2 Rcpp_1.0.8 vctrs_0.3.8 [91] rpart_4.1-15 png_0.1-7 tidyselect_1.1.1 xfun_0.30

data(Obama) data_noMiss <- na.omit(Obama) GGM_net_stepup <- ggm(data_noMiss, omega = "empty") %>% runmodel %>% stepup

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), : 'data' must be of a vector type, was 'NULL'

- Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSachaEpskamp%2Fpsychonetrics%2Fissues%2F13&data=04%7C01%7Ck.j.kan%40uva.nl%7C0bde4780091c456f9d3d08da08f20f03%7Ca0f1cacd618c4403b94576fb3d6874e5%7C0%7C0%7C637832132965511435%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=dCMKdpw6OtgKn%2BUd6lCDGM6VIFFwj4HdLRl%2BL0LCJDs%3D&reserved=0, or unsubscribehttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIIS25NOXW3KVZTGVC6TIBLVASMW5ANCNFSM5RCEBDCQ&data=04%7C01%7Ck.j.kan%40uva.nl%7C0bde4780091c456f9d3d08da08f20f03%7Ca0f1cacd618c4403b94576fb3d6874e5%7C0%7C0%7C637832132965511435%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=n0GsbpBvHTZ8sTvWeGA9XRFoAdN%2Bic7IJZV%2FlKn57Ns%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>

SachaEpskamp commented 2 years ago

Hi Jens,

I reproduce the error but this will take some time to figure out.. But you don't need to do step-up estimation. This also works:


library(CliquePercolation)
library(psychonetrics)
library(dplyr)

data(Obama)
data_noMiss <- na.omit(Obama)
GGM_net_stepup <- ggm(data_noMiss) %>% runmodel %>% prune %>% modelsearch
LangeJens commented 2 years ago

Thanks for your super quick replies! The code is for a workshop I am giving next week. I just wanted to show the full suite of possible estimation procedures. However, other model selection algorithms will also do it to just present some options.

SachaEpskamp commented 1 year ago

Fixed in devel version; sorry for the delay!