79171736

Date: 2024-11-08 22:25:32
Score: 0.5
Natty:
Report link

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 ) ) ) )
Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-1):
Posted by: Anthony Damico