SachaEpskamp / psychonetrics

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

Error in zero[k, 1] : subscript out of bounds #4

Closed Deleetdk closed 1 year ago

Deleetdk commented 4 years ago

Following your example but with my code, I get a runtime error when attempting to prune():

library("psychonetrics")
library("dplyr")

model <- ggm(SPI_imputed, vars = SPI_imputed[2:52] %>% names(), omega = "full")
model <- model %>% runmodel()
model

#prune to sparse
#these give runtime errors
prunedmodel_1 <- model %>% runmodel() %>% stepup() %>% prune()
prunedmodel_2 <- model %>% runmodel() %>% prune() %>% stepup()

#just one of them
prunedmodel_3 <- model %>% runmodel() %>% prune()
prunedmodel_4 <- model %>% runmodel() %>% stepup()

The error happens with the prune() call, not the stepup() call.

> prunedmodel_3 <- model %>% runmodel() %>% prune()
Error in zero[k, 1] : subscript out of bounds

I attach my data. It's the Social Progress Index dataset from here (https://www.socialprogress.org/index/global/methodology), but I imputed the missing data for countries with at most 30% missing data (with VIM's irmi()). It's a dataset of 51 indicators of country well-being. Some countries are so bad they don't have proper data, so that's why the imputation is needed, but we still end up with some 20% of the cases with too little data, so we end with 176 cases.

SPI_imputed.xlsx

Versions: R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Linux Mint 19.3

SachaEpskamp commented 4 years ago

Hi,

Looking at this, there are many variables and not that many observations. This may be too complex for psychonetrics to handle. I think it would be better to use LASSO regularization instead here perhaps.

SachaEpskamp commented 1 year ago

I am closing this issue because the error is no longer there (although the data does give a lot of warnings in psychonetrics, see my comment above).