NErler/JointAI

Error: Variables of type “labelled” can not be handled.

Opened this issue · 0 comments

Hello all,

I was having trouble running some initial models using JointAI with a data.frame that once had labelled data. I wondered if others had run into this previously and/or had any workarounds?

In brief, I'm using a data.frame that was once SPSS (that wasn't my choosing or doing FYI), but I tried to run this glme_imp model specification:

TEMP<-glme_imp(depress_22_R_Alt ~ raceASIA_22_F_L + famstruct5_22_F_L + AdultEduc_22_F_L + povlev4_22_F_L + sex_22_R_L + PlacesLived_22_R_F_L + EverHomeless_22_R_F_L + MothPhyH_22_R_F_L + LowBWght_22_R_F_L + BornPre_22_R_F_L + FoodSit_22_R + ACE2more11_22_R_F_L + SC_AGE_YEARS_Z * HomeEvic_22_R_Z, random = ~1|FIPSST, family = binomial(), data = NSCH_Topical_DRC_CAHMI, n.iter = 10, seed = 2019)

I however get out this error:

Error: 
Variables of type “labelled” (variables: raceASIA_22_F_L1,
famstruct5_22_F_L1, AdultEduc_22_F_L1, povlev4_22_F_L1, sex_22_R_L1,
PlacesLived_22_R_F_L1, EverHomeless_22_R_F_L1, MothPhyH_22_R_F_L1,
LowBWght_22_R_F_L1, BornPre_22_R_F_L1, FoodSit_22_R1,
ACE2more11_22_R_F_L1) can not be handled.

Notably, I thought I had removed all the labels from things, using this command:

NSCH_Topical_DRC_CAHMI$raceASIA_22_F_L<-as.factor(labelled::remove_labels(NSCH_Topical_DRC_CAHMI$raceASIA_22_F_L))

Checking the data type, it looks to be unlabeled:

> typeof(NSCH_Topical_DRC_CAHMI$raceASIA_22_F_L)
[1] "integer"

> head(NSCH_Topical_DRC_CAHMI$raceASIA_22_F_L)
[1] White, non-Hispanic Hispanic            White, non-Hispanic
[4] White, non-Hispanic Hispanic            White, non-Hispanic
5 Levels: White, non-Hispanic Hispanic ... Multi-racial, non-Hispanic

Here's info about my R session:

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.0.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] JointAI_1.0.6

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5       cli_3.6.3         rlang_1.1.4       forcats_1.0.0    
 [5] haven_2.5.4       generics_0.1.3    rjags_4-16        glue_1.8.0       
 [9] listenv_0.9.1     gtsummary_2.0.3   hms_1.1.3         fansi_1.0.6      
[13] grid_4.4.1        tibble_3.2.1      lifecycle_1.0.4   compiler_4.4.1   
[17] mathjaxr_1.6-0    dplyr_1.1.4       codetools_0.2-20  coda_0.19-4.1    
[21] Rcpp_1.0.13       timechange_0.3.0  pkgconfig_2.0.3   labelled_2.13.0  
[25] rstudioapi_0.16.0 future_1.34.0     lattice_0.22-6    digest_0.6.37    
[29] R6_2.5.1          tidyselect_1.2.1  utf8_1.2.4        splines_4.4.1    
[33] parallelly_1.38.0 parallel_4.4.1    pillar_1.9.0      magrittr_2.0.3   
[37] Matrix_1.7-0      tools_4.4.1       globals_0.16.3    lubridate_1.9.3  

Any thoughts for troubleshooting are much appreciated! (Also happy to share my data.frame... but it is fairly large... if that's useful).

Thanks in advance,
Jamie.