gswart
gswart

Reputation: 45

How to fit ordered logistic regression using svyglm()?

I am trying to fit an ordered logistic regression glm for weighted data using svyglm() from the survey library:

model <- svyglm(freehms ~ agea, design = wave9_design, family=binomial(link= "logit"))

freehms is numeric ranging 1 to 5 (I've tried setting it as a factor) and agea is numeric too. I have many more variables, but didn't include them here for simplicity.

But for some reason I get the following error message:

"Error in eval(family$initialize) : y values must be 0 <= y <= 1"

I have looked at online examples, tutorials, and I just can't find what I'm doing wrong. I don't understand why Rstudio insists my independent variable be binary when I have specified the link function (logit) to address this very problem.

Upvotes: 2

Views: 3352

Answers (1)

Thomas Lumley
Thomas Lumley

Reputation: 2765

You want the svyolr() function in the survey pacakge. Or the new svyVGAM package, which does a wide range of ordinal models. svyglm doesn't fit this model because it isn't a generalised linear model.

For example

library(survey)
data(api)
dclus2<-svydesign(id=~dnum+snum, fpc=~fpc1+fpc2, data=apiclus2)
dclus2<-update(dclus2, mealcat=as.ordered(cut(meals,c(0,25,50,75,100))))

svyolr(mealcat~avg.ed+mobility+stype, design=dclus2)

library(svyVGAM)
svy_vglm(mealcat~avg.ed+mobility+stype, design=dclus2, family=propodds())

Upvotes: 6

Related Questions