I’m trying to run a t-test using a survey design object with the survey package. When the variable of interest is a subset of two groups in an ordered factor variable, I get an error message:
“error in evaluating the argument ‘x’ in selecting a method for function ‘format’: group must be binary”
If I convert the variable to a non-ordered factor variable, the svyttest() function works fine. Is there a way to use svyttest() with an ordered factor variable?
I expected the svyttest() result to be the same whether my variable was ordered=T or ordered=F. It only works if ordered=F.
svyttest(obesityAdultCalc~education1, subset(adult_obesity_2123_design (education1=="low"|education1=="high")))
education1 = case_when(level==1 ~ 'low', level==2 ~ 'medium', level==3 ~ 'high', TRUE ~ NA_character_) %>% factor(.,levels=c('low','medium','high'), ordered=T)
education1 = case_when(level==1 ~ 'low', level==2 ~ 'medium', level==3 ~ 'high', TRUE ~ NA_character_) %>% factor(.,levels=c('low','medium','high'), ordered=F)
Sam Emmerich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.