I am trying to include an independent variable in my logistic regression model using the function surveyglm
.
It keeps giving me the error code
"Error in
contrasts
<-(*tmp*
, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels".
The code is:
finaldes<-svydesign(id=~CPSUM, strata=~CSTRATM, weights=~PATWT, nest=TRUE,data=newpts)
(log<-svyglm(formula=offlabel ~ AGER + siteofcare + MSA, design=finaldes))
summary(log)
And the variable that is giving me trouble is siteofcare. When I check the number of levels, I get 2 as an output so I don't understand why this isn't working.
> levels(newpts$siteofcare)
[1] "Outpt" "Hosp"
> nlevels(newpts$siteofcare)
[1] 2