jorgetendeiro / GGUM

GGUM
6 stars 4 forks source link

Problems with GGUM() estimation - subscript out of bounds #13

Closed rameliaz closed 4 months ago

rameliaz commented 4 months ago

Dear Jorge,

Thank you very much for developing this awesome package!

I ran a GGUM() model with a data frame containing nine items with four response categories. According to the documentation, I should specify C=3, but received an error. Here I attached the reproducible example and the dataset.

Dataset: co.csv

library(GGUM); library(readr); library(psych); library(reprex)
#> Warning: package 'readr' was built under R version 4.3.2
#> Warning: package 'psych' was built under R version 4.3.2

co <- (read_csv("co.csv")) # importing dataset
#> Rows: 611 Columns: 9
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (9): co1, co2, co3, co4, co5, co6, co7, co8, co9
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
describe(co) # data frame consists of items with response categories ranging from 1-4, then C = 3
#>     vars   n mean   sd median trimmed  mad min max range  skew kurtosis   se
#> co1    1 611 2.19 0.94      2    2.12 1.48   1   4     3  0.29    -0.88 0.04
#> co2    2 611 1.72 0.88      1    1.58 0.00   1   4     3  1.02     0.09 0.04
#> co3    3 611 2.35 0.91      2    2.31 1.48   1   4     3  0.07    -0.84 0.04
#> co4    4 611 2.42 0.95      2    2.40 1.48   1   4     3  0.03    -0.93 0.04
#> co5    5 611 2.36 1.01      2    2.33 1.48   1   4     3  0.18    -1.06 0.04
#> co6    6 611 2.54 0.91      3    2.55 1.48   1   4     3 -0.07    -0.79 0.04
#> co7    7 611 2.09 0.87      2    2.04 1.48   1   4     3  0.38    -0.59 0.04
#> co8    8 611 1.98 0.95      2    1.86 1.48   1   4     3  0.67    -0.52 0.04
#> co9    9 611 1.76 0.86      2    1.65 1.48   1   4     3  0.86    -0.17 0.03
co.m <- as.matrix(co) # transforming co to a matrix
co.ggum <- GGUM(co.m, 3) # estimating the model
#> 
#> Step 1 of 3: Calibrating initial parameters by means of GUM...
#> Error in `[<-`(`*tmp*`, s, i, data.condensed[s, i] + 1, value = 1): subscript out of bounds
sessionInfo()
#> R version 4.3.1 (2023-06-16 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19045)
#> 
#> Matrix products: default
#> 
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: Europe/Berlin
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] reprex_2.1.0 psych_2.3.12 readr_2.1.5  GGUM_0.5    
#> 
#> loaded via a namespace (and not attached):
#>  [1] styler_1.10.2     viridis_0.6.4     xlsxjars_0.6.1    utf8_1.2.4       
#>  [5] generics_0.1.3    lattice_0.22-5    hms_1.1.3         digest_0.6.33    
#>  [9] magrittr_2.0.3    evaluate_0.23     grid_4.3.1        fastmap_1.1.1    
#> [13] R.oo_1.25.0       R.cache_0.16.0    R.utils_2.12.3    gridExtra_2.3    
#> [17] purrr_1.0.2       fansi_1.0.6       viridisLite_0.4.2 scales_1.3.0     
#> [21] abind_1.4-5       mnormt_2.1.1      Rdpack_2.6        cli_3.6.2        
#> [25] crayon_1.5.2      rlang_1.1.2       rbibutils_2.2.16  R.methodsS3_1.8.2
#> [29] bit64_4.0.5       munsell_0.5.0     withr_2.5.2       yaml_2.3.8       
#> [33] tools_4.3.1       parallel_4.3.1    tzdb_0.4.0        dplyr_1.1.4      
#> [37] colorspace_2.1-0  ggplot2_3.4.4     vctrs_0.6.5       R6_2.5.1         
#> [41] lifecycle_1.0.4   bit_4.0.5         fs_1.6.3          vroom_1.6.5      
#> [45] pkgconfig_2.0.3   rJava_1.0-10      pillar_1.9.0      gtable_0.3.4     
#> [49] glue_1.6.2        xfun_0.41         tibble_3.2.1.9012 tidyselect_1.2.0 
#> [53] rstudioapi_0.15.0 knitr_1.45        xlsx_0.6.5        htmltools_0.5.7  
#> [57] nlme_3.1-164      rmarkdown_2.25    compiler_4.3.1

Created on 2024-02-27 with reprex v2.1.0

rameliaz commented 4 months ago

I rescaled the response categories into 0 - 3, and the estimation works! Apologies for this.. I'm closing the issue :)