Closed ajdamico closed 1 year ago
# load libraries library( survey ) library( convey ) library( laeken ) # collect and format data data( eusilc ) names( eusilc ) <- tolower( names( eusilc ) ) # set up survey design objects des_eusilc <- svydesign( ids = ~rb030 , strata = ~db040 , weights = ~rb050 , data = eusilc ) des_eusilc_rep <-as.svrepdesign( des_eusilc , type= "bootstrap" , replicates = 50 ) # prepare for convey des_eusilc <- convey_prep( des_eusilc ) des_eusilc_rep <- convey_prep( des_eusilc_rep ) # filter positive des_eusilc <- subset( des_eusilc , py010n > 0 | is.na( py010n ) ) des_eusilc_rep <- subset( des_eusilc_rep , py010n > 0 | is.na( py010n ) ) # all three functions work fine with na.rm = TRUE svygpg( ~ py010n , sex = ~ rb090 , des_eusilc_rep , na.rm = TRUE ) svyjdivdec( ~ py010n , ~ rb090 , des_eusilc_rep , na.rm = TRUE ) svygeidec( ~ py010n , ~ rb090 , des_eusilc_rep , na.rm = TRUE ) # removing na.rm = TRUE # # all three behave the same linearized svygpg( ~ py010n , sex = ~ rb090 , des_eusilc ) svyjdivdec( ~ py010n , ~ rb090 , des_eusilc ) svygeidec( ~ py010n , ~ rb090 , des_eusilc ) # svyjdivdec gives an error, even though similar functions do not # and linearized svyjdivdec also does not svygpg( ~ py010n , sex = ~ rb090 , des_eusilc_rep ) svyjdivdec( ~ py010n , ~ rb090 , des_eusilc_rep ) svygeidec( ~ py010n , ~ rb090 , des_eusilc_rep ) # there are non-missing values in all groups of py010n with( des_eusilc_rep$variables , table( is.na( py010n ) , rb090 ) )
whoops sorry this is fixed