does the na.rm
option shown on the ?svymean
help page give you the behavior you're looking for? thanks!!
# fails
MIcombine( with( nsch_design , svymean( ~ ace5 ) ) )
# works but gives wrong answer since it's averaging ones and twos
MIcombine( with( nsch_design , svymean( ~ ace5 , na.rm = TRUE ) ) )
# works
MIcombine( with( nsch_design , svymean( ~ factor( ace5 ) , na.rm = TRUE ) ) )
# works
MIcombine( with( nsch_design , svymean( ~ as.numeric( ace5 == 1 ) , na.rm = TRUE ) ) )
# works
MIcombine( with( subset( nsch_design , !is.na( ace5 ) ) , svymean( ~ as.numeric( ace5 == 1 ) ) ) )
# works but wrong! incorrectly includes missings in the denominator
MIcombine( with( nsch_design , svymean( ~ as.numeric( ace5 %in% 1 ) ) ) )